I've encountered an issue with Apple Pay in PC Chrome with iOS 18. Below is the scenario and code for reference:
Issue Scenario:
- A button is clicked to initiate the Apple Pay process.
- A QR code window pops up, which I scan with my phone.
- As soon as the session is established, the window closes immediately, not allowing the user to select a payment card.
- No errors appear in the console.
Here's the code snippet for handling the Apple Pay button click:
const onApplePayButtonClicked = () => {
if (!window.ApplePaySession) {
return;
}
log('Apple Pay button clicked');
const request = {
countryCode: 'UA',
currencyCode: 'UAH',
merchantCapabilities: ['supports3DS'],
supportedNetworks: ['visa', 'masterCard'],
total: {
label: 'PoC Merchant Apple Pay',
type: 'final',
amount: amount.toString(),
},
};
const session = new window.ApplePaySession(3, request);
session.onvalidatemerchant = async (event) => {
try {
log('Creating ApplePaySession');
const response = await fetchAppleSessionAPI(event.validationURL, applePayMercantId, { deviceId, refreshToken });
log('validateMerchantResponse', response);
session.completeMerchantValidation(response.applePaySessionData);
} catch (error) {
log('validateMerchantError', error);
}
};
session.onshippingmethodselected = () => {
const newTotal = {
label: 'PoC Merchant Apple Pay',
type: 'final',
amount: amount.toString(),
};
session.completeShippingMethodSelection(window.ApplePaySession.STATUS_SUCCESS, {}, newTotal);
};
session.onpaymentauthorized = async (event) => {
log('onpaymentauthorized', event);
const result = {
status: window.ApplePaySession.STATUS_SUCCESS,
};
session.completePayment(result);
log('TOKEN', event.payment.token);
};
session.begin();
};
Troubleshooting Steps Taken:
- Verified that window.ApplePaySession is available.
- Checked for any console errors—none found.
- Confirmed that the QR code scanning and session initiation work as expected.
Expected Behavior:
- After scanning the QR code and establishing the session, the user should be able to select a payment card and proceed with the payment flow.
Current Behavior:
- The window closes immediately after the session is established, preventing card selection.
Has anyone else faced this issue or has insights on how to resolve it?
Thanks in advance!