The Apple Pay widget enables customers to use the Apple Wallet to pay in the online store without redirecting to external payment pages and without entering bank card details.
Apple Pay is supported on iOS and macOS devices.
By sight, the widget is presented in the form of an Apple Pay button, the process of authorization and payment of the order is started by clicking on this button.
To organize the payment, you must perform the following preparatory steps:
To deploy a widget on an online store page, do the following:
The widget is an HTML code and a JS script that you need to place and configure on the payment page of your online store.
In that place of the online store page where you plan to place the Apple Pay payment button, you need to add the following code:
<button id="apple-pay-button"></button> |
You can specify the color, type and size of the button. Examples of button types and their description are available on the site https://developer.apple.com/design/human-interface-guidelines/apple-pay/overview/buttons-and-marks/.
To customize the appearance of the button, you must add a description of the style in the tag <head></head>.
<style> #apple-pay-button { display: none; background-color: black; background-image: -webkit-named-image(apple-pay-logo-white); background-size: 100% 100%; background-origin: content-box; background-repeat: no-repeat; width: 100%; height: 44px; padding: 10px 0; border-radius: 10px; } </style> |
For more information on customizing the appearance of the button, see https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons.
After clicking on the Apple Pay button on the page of the online store, an applePaySession session is created in which you need to transfer the order parameters.
The order amount and currency of the order, as well as supported card types, should be passed as order parameters.
Const currency = $('#currency').val(); // currency Const paymentRequest = { countryCode: region.toUpperCase(), currencyCode: currency.toUpperCase(), total: { label: 'Your label', // payment name amount: $('#amount').val() //order amount }, supportedNetworks:['masterCard', 'visa'], merchantCapabilities: [ 'supports3DS' ] //supported cards }; Const applePaySession = new window.ApplePaySession(1, paymentRequest); |