Apple Pay не работает в браузере Safari на iPhone - PullRequest
0 голосов
/ 19 сентября 2019

Я перегружен функциональностью Apple Pay в веб-браузере Safari на устройствах iPhone.В настоящее время я работаю над реализацией на веб-сайте, и Apple Pay работает как положено.У меня есть этот обработчик кода реагирует на обработку платежа Apple.

const paymentRequest = createPaymentRequest(applePayInstance, order.price, order.deliveryInfo)
​
const ApplePaySession = window.ApplePaySession;
​
const session = new ApplePaySession(3, paymentRequest);
​
session.onvalidatemerchant = function(event) {
    applePayInstance.performValidation({
        validationURL: event.validationURL,
        displayName: "Name"
    }, function(err, merchantSession) {
        if (err) {
            actions.transitionError(err);
            return history.replace('/order/payment_method')
        }
        session.completeMerchantValidation(merchantSession);
    })
};
​
session.onpaymentauthorized = function(event) {
    applePayInstance.tokenize({
        token: event.payment.token
    }, function(tokenizeErr, payload) {
        if (tokenizeErr) {
            console.error(tokenizeErr)
            session.completePayment(ApplePaySession.STATUS_FAILURE);
            actions.transitionError(tokenizeErr);
            return history.replace('/order/payment_method')
        }
​
        session.completePayment(ApplePaySession.STATUS_SUCCESS);
        onNextStep({
            step,
            order,
            payload,
            onSuccess: () => navigate('/order/thanks'),
        });
    })
};
​
session.oncancel = function(event) {
    history.replace('/order/payment_method')
    actions.transitionError('Apple pay transaction canceled')
    actions.resetPaymentMethod()
};
​
session.begin();

При попытке обработать с помощью мобильного браузера не появляется предупреждение о подтверждении, и я получил следующий ответ:

[Log] APPLE_PAY_CANCEL – Event {isTrusted: true, type: "cancel", target: ApplePaySession, …} (1.b7ceb2c7.chunk.js, line 1)
Event {isTrusted: true, type: "cancel", target: ApplePaySession, currentTarget: ApplePaySession, eventPhase: 2, …}Eventbubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: nulldefaultPrevented: falseeventPhase: 0isTrusted: truereturnValue: truesrcElement: ApplePaySession {onvalidatemerchant: function, onpaymentmethodselected: null, onpaymentauthorized: function, onshippingmethodselected: null, onshippingcontactselected: null, …}ApplePaySessiontarget: ApplePaySession {onvalidatemerchant: function, onpaymentmethodselected: null, onpaymentauthorized: function, onshippingmethodselected: null, onshippingcontactselected: null, …}ApplePaySessiontimeStamp: 76322type: "cancel"Event Prototype

Я использую Braintree.Любые идеи, как это исправить?Спасибо.

...