I have implemented a website that makes payments with Apple Pay on the web.
After new Payment Session Created, ApplePayJS Executes ApplePaySession. begin();
But I only executed it once, The Error Occurs like Below
InvalidAccessError:there is already has an active payment session
Test Info
I had created Apple Pay merchant ID and certificates, and verify your domain and set up server for secure communications with Apple Pay.
Apple Pay JS Version is 11
I have been using Sandbox account (Visa, Mastercard), iOS 14.6, and iphone8
Here's my code
const version = 11;
const paymentRequest = {
countryCode: "JP",
currencyCode: "JPY",
supportedNetworks: supportedNetworks,
merchantCapabilities: ["supports3DS",],
total: { label: label, type: type, amount: amount } ,
applicationData: applicationData
};
applePaySession = new ApplePaySession(version, paymentRequest);
applePaySession.onvalidatemerchant = function (event) {
const reqParam = {
validationUrl: event.validationURL};
applePaySession.completeMerchantValidation(data.merchantSession);
applePaySession.onpaymentauthorized = function (event) {
const paymentDataStr =
JSON.stringify(event.payment.token.paymentData);
const paymentToken = common_base64_encode(paymentDataStr);
inJsonObj.applePayToken = paymentToken;
applePaySession.begin();