Apple Pay付款表无法打开

佐哈尔

我正在尝试调试Apple代码示例以打开付款表。昨天它起作用了,付款单也打开了,但是今天我想我无法通过session.onvalidatemerchant阶段。当我调试时,它不会在getApplePaySession(event.validationURL)中停止,而是会直接跳到session.onshippingmethodselected(这没有意义,因为尚未打开灯箱,对吗?)。

我的控制台没有任何错误。“验证商家”未写入控制台。这是苹果提供的JS代码,我正在使用:

const session = new ApplePaySession(1, paymentRequest);

/**
* Merchant Validation
* We call our merchant session endpoint, passing the URL to use
*/
session.onvalidatemerchant = (event) => {
    console.log("Validate merchant");
    const validationURL = event.validationURL;
    getApplePaySession(event.validationURL).then(function(response) {
        console.log(response);
        session.completeMerchantValidation(response);
    });
};

/**
* Shipping Method Selection
* If the user changes their chosen shipping method we need to recalculate
* the total price. We can use the shipping method identifier to determine
* which method was selected.
*/
session.onshippingmethodselected = (event) => {
    const shippingCost = event.shippingMethod.identifier === 'free' ? '0.00' : '5.00';
    const totalCost = event.shippingMethod.identifier === 'free' ? '8.99' : '13.99';

    const lineItems = [
        {
            label: 'Shipping',
            amount: shippingCost,
        },
    ];

    const total = {
        label: 'Apple Pay Example',
        amount: totalCost,
    };

    session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, total, lineItems);
};
佐哈尔

我解决了问题。Mac和iPhone未配置相同的iCloud用户。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章