Apple Pay JS - completeMerchantValidation not triggered

When I click to my Apple Pay button, my function below doesn't trigger the completeMerchantValidation method as expected, but the oncancel method (which logs errorCode "unknown" in Safari developer tools) :

const processApplePayment = async () => {
        if (window.ApplePaySession) {
            const session = new window.ApplePaySession(6, {
                countryCode: 'FR',
                currencyCode: 'EUR',
                merchantCapabilities: ['supports3DS'],
                supportedNetworks: ['visa', 'masterCard'],
                total: {
                    label: `Bon d'achat ${partnerName}`,
                    type: 'final',
                    amount: cartTotalValue.toString()
                }
            });
            session.onvalidatemerchant = async event => {
                try {
                    const merchantSession = await validateMerchantSession(event.validationURL);
                    console.log('merchant session : ', merchantSession);
                    if (!merchantSession) {
                        console.error('Invalid Apple Pay merchant session');
                    }
                    session.completeMerchantValidation(merchantSession);
                } catch (error) {
                    console.error('merchant validation error : ', error);
                    session.abort();
                }
            };
            session.onpaymentauthorized = async event => {
                console.log('payment authorization event : ', event);
                try {
                    const link = await authorizePayment(
                        event.payment.token,
                        userInfo,
                        partnerId,
                        order.id
                    );
                    console.log('payment authorized link : ', link);
                    window.location.href = link;
                } catch (error) {
                    console.error('Apple Payment authoriation error : ', error);
                    const errorUrl = `${PATH.EBON_ERROR_PATH}-${partnerId}?paiement=error&orderId=${order.id}`;
                    window.location.href = errorUrl;
                }
            };
            session.oncancel = event => console.log('Apple Pay cancel event : ', event);
            session.begin();
        }
    };

The validateMerchantSession function successfully returns this payment session from Apple server :

{
"epochTimestamp":1739279973502,
"expiresAt":1739283573502,
"merchantSessionIdentifier":"SSH108C7ED6746A48E38EA8D253D33CCAA5_916523AAED1343F5BC5815E12BEE9250AFFDC1A17C46B0DE5A943F0F94927C24",
"nonce":"150de193",
"merchantIdentifier":"11CA4E31493E748848A91A0DAB1685A8417C41B62B9863EF59A618B91239471A",
"domainName":"lesnumeriques-bonsdachat.htmal1.com",
"displayName":"Les Numériques",
"signature":"308006092a86...779cd643c000000000000", // long string
"operationalAnalyticsIdentifier":"Les Numériques:11CA4E31493E748848A91A0DAB1685A8417C41B62B9863EF59A618B91239471A",
"retries":0,
"pspId":"11CA4E31493E748848A91A0DAB1685A8417C41B62B9863EF59A618B91239471A"
}

What could I do wrong and how could I fix it please ?

Answered by seb_carret in 824923022

My bad the issue was caused by a bad configuration server side...

We passed as initiativeContext parameter a domain name with https://, while our verified domain in our developer account doesn't include this prefix...

Now it's fixed and operational.

Accepted Answer

My bad the issue was caused by a bad configuration server side...

We passed as initiativeContext parameter a domain name with https://, while our verified domain in our developer account doesn't include this prefix...

Now it's fixed and operational.

Apple Pay JS - completeMerchantValidation not triggered
 
 
Q