[w3c/payment-request] Add way to update `total` and `displayItems` before `.show()` (#639)

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 that `canMakePayment()` resolves to `true`, 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, but `canMakePayment()` 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` when `canMakePayment` is called, so I could see an argument that `canMakePayment()` needs to be re-run as totals change, but obviously `total` can also be updated after `.show()`  via the shipping callbacks.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/issues/639

Received on Friday, 6 October 2017 02:56:31 UTC