-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensibility of PaymentResponse.complete(result) #817
Comments
Thank you for writing this up, @adrianhopebailie ! I agree that "complete data" should be defined in the payent method. For the sake of feature detection, may I also suggest to use a different name for the method that sends over an object instead of enum? I believe the method name |
@adrianhopebailie, to keep things backwards compatible, we could add a second argument.
That would keep things backwards compatible, but allow supporting new payment types. WDYT? Would that work? |
The underly question here is if |
@rsolomakhin said:
I worry that makes the API for a developer a little confusing. i.e. When do I call complete and when do I call confirm? That said, I'm not sure how else you could provide a feature detectable difference. @marcoscaceres said:
I think my proposal is already backwards compatible (at least from the perspective of a developer using the API). I've proposed changing the type of the argument from
I think it would be a mistake to assume we can design anything that "applies to all transactions". Even if that's true now it'll probably not be true for long. I could live with the two-argument solution, my only reservation is that this allows for ambiguous input (e.g. enum: |
Unfortunately, no. It would break :( For enums, IDL binding layer just converts whatever you pass into it into a string, so passing an object would become Alternative might be to do |
@mountainhippo would be great to hear more about the requirements around what needs to be passed. @adrianhopebailie wrote:
I'm mindful that we might not be able to model everything that is needed - but using the There are a number of ways to deal with the extensibility aspects. If we find a common base, we can use that and extend it using inheritance. But if it's obvious that it won't scale, then yeah... So, I'd say we start with the use cases and requirements for what this thing needs and see how we go. And |
Ah, makes sense.
This seems like a good direction.
The reason I think we have to use the JSON serialisable object is for the same reasons On the plus side, it's possible for browsers to enforce validation for known payment methods (like Would be interesting to explore the possibility of having an IDL definition in the manifest for payment methods that use a URL identifier? |
Would be nice. The challenge is that browser today can only use IDL statically: we literally take IDL as text input, run it through a Python-based processor, and spit out C++... which is then compiled into the browser itself (i.e., no way of doing some kind of JIT compilation today). So, before we start going too deep into technical solution, I think we should be clear about we might need to support SRC and other things. |
Let's leave this issue open for now. I expect we will make progress on an SRC payment method in the first quarter of this year, and then we will know if we need any changes for at least that payment method. |
In his analysis of SRC, @mountainhippo identified the need to have a post-authorization step where the merchant/website notifies the payment handler of the result of the payment.
I believe that this is roughly why we have
PaymentResult.complete(result)
driven by a similar requirement from Apple Pay (@aestes can confirm).My question is, how extensible can we make the
result
argument so we can support other payment methods with this requirement?result
is currently defined as being an optionalPaymentComplete
enum but I think it would be better if it was more generic.The ideal would be if payment method specs could define a format for this (JSON serializable object) in the same way they do for their custom payment request and response data.
This would allow an SRC payment method spec to define the exact format of
result
when a website callsPaymentResponse.complete(result)
after a payment.Concretely this would mean:
PaymentResponse.complete(response)
is defined as:where
object
is the object type (as used in the definition ofPaymentMethodData.data
).result
argument. Something like the following, copied fromPaymentMethodData.data
:PaymentComplete
enum out of the PR API spec and into payment method specs that use it as is (E.g. Apple Pay).The effect is that any payment method specification can then define 3 custom data formats:
PaymentMethodData.data
PaymentResponse.data
result
by the website when callingPaymentResponse.complete(result)
The text was updated successfully, but these errors were encountered: