-
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
Should a payment request be just data, or a programmable object? #47
Comments
The design of the PaymentRequest API allows events to be fired in any order. A promise can only be fulfilled or rejected. I recommend that this issue be closed. |
@adrianba it's unclear to me how your comment relates to the question being asked. I assume you mean that the current design is required because it uses events to notify the website of user choices with regard to things like the shipping address and therefore an event emitting object is required. I don't dispute that, I agree that we do need a valid event emitter to support the current design. However, my understanding of the crux of this question is whether:
In my proposal in PR #133 I have used your existing model of a PaymentRequest object but made a clear separation between data passed in that is consumed and used by the user agent ( |
I'm trying to answer the question raised by this issue. i.e. "Should a payment request be just data, or a programmable object?" and consider whether this is an issue we need. I don't believe that issue #47 helps us make progress and I recommend that we close it. |
This issue has nothing to do with events vs promises which is all your comment discussed. This issue has to do with the idea of "messages" and the need to encapsulate the full content of a payment request as a single JSON-serializable object that can be passed across process or network boundaries. The current design splits all of the data that must be passed to the payment app among a variety of parameters so it is unclear how a JSON-serialized payment request would be created from a PaymentRequest object or what it would look like. The question at hand is whether or not it would be better for there to be a clear separation of concerns in the API so that the payment request is constructed entirely by the website as a single pure data object and passed to the PaymentRequest constructor in the same form the website expects to be passed on to the payment app. I don't consider the other functions of the PaymentRequest object (such as emitting events) as the issue at hand because, as you say, that's the design we have chosen to adopt. |
I was comparing the code snippets in the original comment. In the first snippet, which calls the PaymentRequest constructor, the only programmable object is the PaymentRequest object. In the second code example, there is no programmable object. A promise is returned. Since the issue asks whether a programmable object should be involved I concluded that the comparison was between code that returned an object and code that didn't but returned a promise. Hence my comment. All of the arguments to the current PaymentRequest constructor can be serialized as JSON. In fact that is a requirement for some of them. None of them are "programmable". There is also a separate issue (#15) about combining arguments into a JSON serializable object. As you say, we've already adopted a design with a programmable object. Another reason I think this issue should be closed. |
From the discussion it seems this issue is unclear on what is being addressed:
With regards to 1. the current API uses events and the motivations for this provided by @adrianba appear to be uncontested. There is another issue, #51, which discusses the option of a more fluid API shape that is a better place to address this discussion of shape and preferred patterns. With regards to 2. this is discussed and addressed in the comments on #133. I am closing this issue and requesting that if there are other issues that were intended to be encapsulated here they be logged as new issues with concrete proposals for addressing them. |
Migrating from w3c/webpayments#36:
The paymentRequest API asserts that a payment request is a programmable object:
http://wicg.github.io/paymentrequest/specs/paymentrequest.html#paymentrequest-interface
that is instantiated like so
and can have methods called on it like so:
The Web Payments CG's Browser API asserts that a payment request is just data:
http://wicg.github.io/web-payments-browser-api/#processing-a-payment-request
and that data is processed by functions:
These are two different general design approaches for the browser API:
So, what is our design approach for the browser API?
The text was updated successfully, but these errors were encountered: