我一直在关注苹果网站上有关苹果薪酬的相关文件。
onValidateMerchant和completeMerchantValidation工作得很好,但就在那之后,它跳到了oncancel。
我有信息被打印到屏幕上,在onpaymentselected和onpaymentauthorized中,但它们从未被打印过。
我添加了一个try catch来捕获任何弹出的错误,结果显示onpaymentselect和onpaymentauthorized在onValidateMerchant和completeMerchantValidation之前运行。
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}
发布于 2022-03-15 10:47:25
我也遇到了同样的问题,当onvalidatemerchant失败时,这个{"isTrusted":true}似乎是因为:
没有启用
Safari的validate的H 211F 212如果这些部件正常工作,那么您应该可以看到Apple Pay模式,并且应该能够使一切正常工作(希望如此)。
https://stackoverflow.com/questions/69113168
复制相似问题