-
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 the payment API be more conversational or less conversational? #51
Comments
I don't like the .request().send().start().then() chaining API. It doesn't feel very familiar based on other platform APIs. So far I think we can say up front which options a web page needs without multiple calls to request() and (I think) the current updateWith method accomplishes the same as the send() method in response to interaction. I would prefer that we close this issue without making changes. |
This appears to simply be an issue of personal style in the design of the API. I have certainly seen both approaches in the wild but I believe the current design is more familiar in browser APIs. To justify changing this design we'd need to see examples of how the API will likely be used by developers and evidence that the proposed design is easier to use than what we have today. |
Generic design question that would be better raised again as a concrete proposal now that the API shape has matured |
Partial migration from w3c/webpayments#55:
@dlongley proposed a more conversational shape to the browser payment API here:
http://sites.local/web-payments-browser-api/checkout-api.html#the-checkout-interface
For example:
and @dlongley noted this is how it would work:
With the Checkout API, we want to be able to do things like make shipping options depend on the shipping address selected. What we're exploring essentially works like this:
send
the line item estimate is made on the Checkout object. This call essentially just sets "options" that will be read once the checkout is started.request
shipping address is made on the Checkout object. Again, this call is like setting options as it simply "indicates" that a shipping address is requested. It won't do anything until the checkout is started.shippingAddressChanged
event is dispatched.request
to request shipping option selection along with a list of possible shipping options (or a Promise that resolves to such a list).request
was called, it will wait for its Promise to settle and then display the shipping options in the UI, keeping the "Buy" button disabled. Otherwise, there's nothing to wait on and the "Buy" button will be enabled.shippingOptionChanged
event is dispatched.send
to send updated checkout details such as new calculated line items that include, eg: shipping, tax. Again, this information can be sent as a Promise, to enable the website to generate this information asynchronously. Similarly,request
can also be called to request other information at this point (that depended on shipping option selection).request
was called, it will wait for its Promise to settle and then display the UI for whatever was requested this time, keeping the "Buy" button disabled. Otherwise, there's nothing to wait on and the "Buy" button will be enabled.checkout.start
resolves.checkout.finish
.So, the question is - do we want this sort of conversational API vs. the more rigid API proposed in the current spec?
The text was updated successfully, but these errors were encountered: