我试图调试Apple代码示例以打开付款表。昨天它工作了,付款单打开了,但今天我想我无法通过session.onvalidatemerchant阶段。当我调试时,它不会在getApplePaySession(event.validationURL)中停止,而是直接跳转到session.onshippingmethodselected(这没有意义,因为灯箱还没有打开) ,对吧?!)。
我在控制台中没有任何错误。 "验证商家"没有写入控制台。 这是Apple提供的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);
};
答案 0 :(得分:0)
我解决了这个问题。 Mac和iPhone没有配置相同的iCloud用户。