Apple this week made the Payment Request API available for Apple Pay. The W3C-developed API works in Safari 11.1 on MacOS and Safari on iOS 11.3, allowing merchants and retailers to conduct transactions through Apple Pay, rather than alternatives such as credit/debt cards or PayPal.
Apple Pay on the web has been around for several years, since macOS Sierra and iOS 10. The idea then and now is to make it easy for Apple Pay users to find support for Apple Pay online. Fans of the iPhone love Apple Pay for its simplicity, security, and privacy. The system generates unique tokens for each transaction, meaning consumer credit card data is never shared directly with the merchant. Because merchants need to support multiple payment methods, Apple created the Payment Request API. The goal is to reduce the complexity of actually adding various payment methods to individual retailer sites with a standard API.
One of the first steps is to display the Apple Pay button. This is what end users tap or click to initiate payments. WebKit offers a handful of preconfogured versions of the Apple Pay button that can be pasted into your web site. Apple would prefer that retailers only show the Apple Pay button to produtcs that support Apple Pay (iPhones, iPads, Mac computers.) Developers will need to make a separate call to the ApplePaySession.canMakePayments API. This tells the web site that, yes, the device supports Apple Pay and the site should display the Apple Pay button.
Clicking the Apple Pay button should automayically generate the Apple Pay sheet, which is a pop-up that appears on top of browser screens. It includes the basic transaction details: item, price, payment method, billing address, shipping address, and so on. (Customers who've not enrolled in Apple Pay will be prompted to do so if they click the button.) Apple says the ApplePaySession is required to bridge this action, but the rest can be handled by the Payment Request API.
The Payment Request API spells out quite a lot of details, such as shipping instructions (standard rates, express, etc.), modifiers, valid payment details, and sales tax. It helps sort through payment options, as Apple Pay users can store multiple cards and methods in their account. For example, it can opt for the default card, or allow users to see all their payment options when using Apple Pay to make an online payment. These are detail data sets that include name, address, phone number, email, and other details pertinent to the transaction.
The API goes on to control what happens with custimers abort a purchase, or need to select an alternate payment method. It serves to validate merchants as well as shipping information. And of course, it handles the payment authorization between the card holder, the card issuer, and the merchant.