W3C Payment API changes in Chrome 74

28 views
Skip to first unread message

Rouslan Solomakhin

unread,
May 9, 2019, 9:24:26 AM5/9/19
to payment...@chromium.org

TL;DR: If you don’t use canMakePayment() and languageCode, you can stop reading now.


Here are the new features shipped in Chrome 74 (on April 30th):


  • A new method PaymentRequest.hasEnrolledInstrument() is shipped and behaves the same as the old method PaymentRequest.canMakePayment() -- it checks for instrument presence.


To adapt to the hasEnrolledInstrument() roll out, change your code that looks like this:

// Checking for instrument presence before M74.

request.canMakePayment().then(handleInstrumentPresence).catch(handleError);


Into code that looks like this:

// Checking for instrument presence.
if (request.hasEnrolledInstrument) {

 // In M74 and after.

 request.hasEnrolledInstrument().then(handleInstrumentPresence).catch(handleError);

} else {

 // Before M74.

 request.canMakePayment().then(handleInstrumentPresence).catch(handleError);

}


  • The new PaymentRequest.canMakePayment() method no longer checks for instrument presence, only for payment app availability.


// Checking for payment app availability without checking for instrument presence.

if (request.hasEnrolledInstrument) {

 // In M74 and after.

 request.canMakePayment().then(handlePaymentAppAvailable).catch(handleError);

} else {

 // Before M74.

 console.log(“Cannot check for payment app availability without checking for instrument presence before M74.”);

}


  • PaymentAddress.languageCode is removed from shipping addresses and billing addresses for basic-card. The billing addresses of other payment methods (such as Google Pay) are not affected.


Make sure to clear your flags to test out these features locally:
- Copy-paste chrome://flags into the address bar.
- Click the “Reset all to default” button.
- Click the “Relaunch Now” button.

Reply all
Reply to author
Forward
0 new messages