-
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
Add way to update total
and displayItems
before .show()
#639
Comments
Hi @jenan-stripe, Thank you for bringing this to our attention. We've been recommending merchants with this requirement to call We don't recommend calling Is this helpful or do you still see room for improvement in the API? Cheers, P.S.: One neat trick in Chrome that not many people know is to "warm up" |
@rsolomakhin Ah, fascinating! Thanks for detailed response and Chrome details! That sounds like a great workaround, but it sort of falls out of some assumptions about the API rather than specific contracts, right?
|
It's true that the spec does not specify when the scan for the payment apps should happen. There's a fine line between predictability of API behavior and tying the hands of browser manufacturers. I see your point here, though. Perhaps this is good behavior to standardize across browsers, so that web developers can rely on it. @ianbjacobs Can we put this on agenda for the next call or the face-to-face in November?
The I have a proposal in the works to optionally fire In summary, the corresponding events between the merchant and the payment app are:
This can get a little confusing, so let's clarify a bit. According to the spec, calling // CASE 1: This is fine:
pr = new PaymentRequest();
pr.canMakePayment();
pr.show();
// CASE 2: This is also fine:
pr = new PaymentRequest();
pr.show();
// CASE 3: This will throw in canMakePayment():
pr = new PaymentRequest();
pr.show();
pr.canMakePayment(); // InvalidStateError Is it possible, however, that a browser implements the PaymentRequest spec correctly, but does not work in Note that the opposite is not true. The I hope this information is useful. Please let me know if I can help with any other concerns you might have. |
@rsolomakhin, I have added the topic to the agenda. |
@rsolomakhin Ahhh excellent -- so |
Closing in favor of #645. |
We’ve heard from merchants that they’d like a way to update the
total
of a PaymentRequest before.show()
is called. Concrete use case: render a button on page load after being sure thatcanMakePayment()
resolves totrue
, and then.update()
as a user selects between SKUs. Another: a donation site where the user can select how much to donate.One solution may be to just create new
PaymentRequest
instances when the user interacts with the page, butcanMakePayment()
makes network requests and can be slow, so you either end up with a race condition between the user changing the form and clicking the button or uncomfortable disabled+re-enabled UI.Payment Handlers get passed
total
whencanMakePayment
is called, so I could see an argument thatcanMakePayment()
needs to be re-run as totals change, but obviouslytotal
can also be updated after.show()
via the shipping callbacks.The text was updated successfully, but these errors were encountered: