ApplePay on website

Hello. I try to set ApplePay button on my saite, my code is:

const paymentRequest = {
   total: {
       label: 'merchant.MyTest',
       amount: 1
   },
   countryCode: 'UA',
   currencyCode: 'UAH',
   merchantCapabilities: ['supports3DS', 'supportsEMV', 'supportsCredit', 'supportsDebit'],
   supportedNetworks: ['masterCard', 'visa']
};

const applePaySession = new window.ApplePaySession(3, paymentRequest);

applePaySession.begin();


applePaySession.onvalidatemerchant = (event) => {

     let promise = performValidation(event.validationURL);
    promise.then(function (merchantSession) {

document.getElementById("logs").innerHTML = JSON.stringify(merchantSession);
        applePaySession.completeMerchantValidation(merchantSession);
    }).catch((error) => alert(error));

And when I click on ApplePay button I get an error:

How you can saw on screenshot I get ApplePay session.

I found some info, that firs it's need to add test email to sandbox and then add test-card, but when I make login by Appleid from sandbox and add test card, I get next error:

Please, help: how to correct add ApplePay to my site and get payment token? Thanks!

I found some info, that firs it's need to add test email to sandbox and then add test-card, but when I make login by Appleid from sandbox and add test card, I get next error:

Yes, you will need to add a test card to a test account on a device that does not have a production Apple Pay account setup on it. See Sandbox Testing.

Regarding your error, I would suggest looking here:

applePaySession.onvalidatemerchant = (event) => {

     let promise = performValidation(event.validationURL);
    promise.then(function (merchantSession) {

document.getElementById("logs").innerHTML = JSON.stringify(merchantSession);
        applePaySession.completeMerchantValidation(merchantSession);
    }).catch((error) => alert(error));
And when I click on ApplePay button I get an error:

I would checkout the interaction between sending the payment request to your server, your server interacting with the Apple Pay servers, then your server responding back with an appropriate merchantSession. Checkout your server side logs and makesure that entire flow is working correctly.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
ApplePay on website
 
 
Q