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

Hi @jenan-stripe,

Thank you for bringing this to our attention. We've been recommending merchants with this requirement to call `canMakePayment()` once and reuse its result as the shopping cart updates:

https://github.com/w3c/payment-request-info/wiki/CodeExamples#check-whether-user-can-make-payment-before-all-prices-are-known

We don't recommend calling `canMakePayment()` for every instance of `PaymentRequest`, if the only differences among them are the total and line items. This is because the browser should not pass the total and the line items into the payment apps during the `canMakePayment()` call. Chrome used to do this a while ago for Android payment apps, but we've since removed this functionality to improve user privacy.

Is this helpful or do you still see room for improvement in the API?

Cheers,
Rouslan

P.S.: One neat trick in Chrome that not many people know is to "warm up" `PaymentRequest` by creating an instance as soon as the page loads or shopping cart contents change. Constructing an instance of `PaymentRequest` will scan the device for installed payment apps that the merchant requested. This scan can take up to 2 seconds on older mobile devices with cold start or as few as 50 milliseconds on newer devices. This period of time is the "warm up" period. You may have noticed that `canMakePayment()` takes a while to return. This is because `canMakePayment()` returns after the payment app scan is complete. It is important to note, however, that `canMakePayment()` does not start the scan, but only waits for the end of the scan, which was started by constructing a `PaymentRequest` instance. If you call `show()` during the "warm up" period, Chrome will show a "Loading..." spinner as it completes the scan for apps. If you call `show()` after the "warm up" period, Chrome will show the payment sheet immediately. There's a lot of nuance involved here, so please don't hesitate to reach out with more questions.

-- 
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#issuecomment-334760851

Received on Friday, 6 October 2017 13:52:19 UTC