首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Apple Pay,支付未完成Web

Apple Pay,支付未完成Web
EN

Stack Overflow用户
提问于 2021-09-09 06:21:29
回答 2查看 758关注 0票数 1

我一直在关注苹果网站上有关苹果薪酬的相关文件。

onValidateMerchant和completeMerchantValidation工作得很好,但就在那之后,它跳到了oncancel。

我有信息被打印到屏幕上,在onpaymentselected和onpaymentauthorized中,但它们从未被打印过。

我添加了一个try catch来捕获任何弹出的错误,结果显示onpaymentselect和onpaymentauthorized在onValidateMerchant和completeMerchantValidation之前运行。

代码语言:javascript
复制
applePayButton.addEventListener("click", function(){

const request = {
    countryCode: 'US',
    currencyCode: 'USD',
    merchantCapabilities: [
        'supports3DS'
    ],
    supportedNetworks: [
        'visa',
        'masterCard',
        'amex',
        'discover'
    ],
    lineItems: [{
            label: 'Amount',
            amount: 0.95,
        },
        {
            label: 'Tax',
            amount: 0.05,
        }
    ],
    total: {
        label: 'Total',
        amount: 10,
    }
};
var session = new ApplePaySession(10, request);
session.begin();

try{
    session.onvalidatemerchant = function(event){
        printMessage("starting session.onvalidatemerchant" + JSON.stringify(event));

        var promise = performValidation(event.validationURL);

        promise.then(function(merchantSession) {
            printMessage("Merchant Session: "+ JSON.stringify(merchantSession));
            session.completeMerchantValidation(merchantSession);
        });
    }
}
catch(error){
    printMessage("On Validate Merchant Error: " + error)
}

try{
    printMessage("onpaymentmethodselected");

    session.onpaymentmethodselected = function(event) {
        printMessage("In On Payment Method Selected");
        //var myPaymentMethod = event.paymentMethod;

        const update = {};
        session.completePaymentMethodSelection(update);
    };

}
catch(error){
    printMessage("On Payment Method Selected Error: " + error)
}

try{
    printMessage("onpaymentauthorized");
    session.onpaymentauthorized = function(event) {
        printMessage("starting session.onpaymentauthorized");

        var applePaymentToken = event.payment.token;

        printMessage("Token" + applePaymentToken);

        // Define ApplePayPaymentAuthorizationResult
        session.completePayment(session.STATUS_SUCCESS);
    };

}
catch(error){
    printMessage("On Payment Authorized Error: " + error)
}

try{
    session.oncancel = function(event) {
        printMessage("starting session.oncancel" + JSON.stringify(event));

        // Payment cancelled by WebKit
    };
}
catch(error){
    printMessage("On Cancel Error: " + error)
}

});

这是付款未完成后的信息。

会话:步骤1: applePay工作

步骤2:选择onpaymentmethodselected

第3步:授权支付

步骤4:启动session.onvalidatemerchant{"isTrusted":true}

步骤5:完整的商人验证:

步骤6:启动session.oncancel{"isTrusted":true}

EN

Stack Overflow用户

发布于 2022-03-15 10:47:25

我也遇到了同样的问题,当onvalidatemerchant失败时,这个{"isTrusted":true}似乎是因为:

没有启用

  • ,或者没有使用Safari
  • ,或者在后端调用validate
  • 都是错误的H 211F 212

如果这些部件正常工作,那么您应该可以看到Apple Pay模式,并且应该能够使一切正常工作(希望如此)。

票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69113168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档