Has anyone here managed to get Apple Pay to work via the Square Web Pay plugin. On Square's developer site it seems to say that as well as verifying the domain we need to add some code to certain pages on our site.
Can anyone help with this as ApplePay seems to be getting quite popular.
Thanks as always
Step 2: Attach Apple Pay to the page
The Apple Pay payment method needs information about the buyer and the payment amount before it can open the Apple Pay sheet. Your application creates a PaymentRequest object to provide that information and then gets a new ApplePay object initialized with it.
The following code creates the payment request and attaches the ApplePay method to the page:
Add an HTML element to the prerequisite walkthrough form with an ID of apple-pay-button. The HTML for the body of index.html should look like the following:
<form id="payment-form">
<!-- Add the below element -->
<div id="apple-pay-button"></div>
<div id="card-container"></div>
<button id="card-button" type="button">Pay $1.00</button>
</form>
<div id="payment-status-container"></div>
Add a style element and button style properties in the <head> tag. For a reference of Apple Pay button styles, see Styling the Apple Pay Button Using CSS.
Add the following functions to the script tag:
function buildPaymentRequest(payments) {
return payments.paymentRequest({
countryCode: 'US',
currencyCode: 'USD',
total: {
amount: '1.00',
label: 'Total',
},
});
}
async function initializeApplePay(payments) {
const paymentRequest = buildPaymentRequest(payments)
const applePay = await payments.applePay(paymentRequest);
// Note: You don't need to `attach` applePay.
return applePay;
}
In the DOMContentLoaded event listener, add the following code after you initialize the ApplePay method:
let applePay;
try {
applePay = await initializeApplePay(payments);
} catch (e) {
console.error('Initializing Apple Pay failed', e);
// There are a number of reason why Apple Pay might not be supported.
// (such as Browser Support, Device Support, Account). Therefore you should
// handle
// initialization failures, while still loading other applicable payment
// methods.
}


Reply With Quote
