W3C Payment API changes in Chrome 75

18 views
Skip to first unread message

Rouslan Solomakhin

unread,
Jun 6, 2019, 10:08:49 AM6/6/19
to payment...@chromium.org

The following changes are live in Chrome 75.

   Stable: today


New features enabled by default:

Allow PaymentRequest.show() to take optional detailsPromise

This Payment Request API feature allows merchants to show the payment sheet before the final total is known. The merchant has 10 seconds to resolve the detailsPromise before a timeout. This feature is intended for a quick server-side roundtrip.


Merchant example:

// Not implemented in Chrome 74 and older.

// There’s no way to feature-detect this, so check a few

// older versions of Chrome that you’re seeing hit your servers.

if (/Chrome\/7[0-4]/g.exec(navigator.userAgent) !== null) {

 return;

}


// Supported in Chrome 75+.

request.show(new Promise(function(resolveDetailsPromise, rejectDetailsPromise) {
 // Find out the exact total amount and call resolveDetailsPromise(details).
 // Use a 3 second timeout as an example.
 window.setTimeout(function() {
   resolveDetailsPromise(details);
 }, 3000); // 3 seconds.
}))
.then(handleResponse)
.catch(handleError);


Demo: https://rsolomakhin.github.io/pr/wait/.

Reply all
Reply to author
Forward
0 new messages