Javascript 高级卡支付SDK在提交表单时显示错误
错误:“托管字段付款已在进行中。” 我已经从中复制了它,并在SDK URL中传递了一个正确的沙盒clientIDJavascript 高级卡支付SDK在提交表单时显示错误,javascript,paypal,paypal-buttons,Javascript,Paypal,Paypal Buttons,错误:“托管字段付款已在进行中。” 我已经从中复制了它,并在SDK URL中传递了一个正确的沙盒clientID if (paypal.HostedFields.isEligible()) { paypal.HostedFields.render({ createOrder: function () {return "order-ID";}, // replace order-ID with the order ID styles: {
if (paypal.HostedFields.isEligible()) {
paypal.HostedFields.render({
createOrder: function () {return "order-ID";}, // replace order-ID with the order ID
styles: {
'input': {
'font-size': '17px',
'font-family': 'helvetica, tahoma, calibri, sans-serif',
'color': '#3a3a3a'
},
':focus': {
'color': 'black'
}
},
fields: {
number: {
selector: '#card-number',
placeholder: 'card number'
},
cvv: {
selector: '#cvv',
placeholder: 'card security number'
},
expirationDate: {
selector: '#expiration-date',
placeholder: 'mm/yy'
}
}
}).then(function (hf) {
$('#my-sample-form').submit(function (event) {
event.preventDefault();
hf.submit({
// Cardholder Name
cardholderName: document.getElementById('card-holder-name').value,
// Billing Address
billingAddress: {
streetAddress: document.getElementById('card-billing-address-street').value, // address_line_1 - street
extendedAddress: document.getElementById('card-billing-address-unit').value, // address_line_2 - unit
region: document.getElementById('card-billing-address-state').value, // admin_area_1 - state
locality: document.getElementById('card-billing-address-city').value, // admin_area_2 - town / city
postalCode: document.getElementById('card-billing-address-zip').value, // postal_code - postal_code
countryCodeAlpha2: document.getElementById('card-billing-address-country').value // country_code - country
}
});
});
});
}
您需要将“订单ID”替换为为此签出创建的实际PayPal订单ID
有几种方法可以获得一个。有关如何从服务器调用orders API以“创建订单”和“捕获订单”,请参阅。您应该使用它们在服务器上创建两个只返回JSON数据(无HTML或文本)的路由
至于如何从JS UI获取和提交,请参阅以获取一些演示代码
或者,您可以尝试进行仅HTML/JS的集成(无服务器),如您的“订单ID”是什么?订单ID应该从Paypal返回吗?我必须先订购(通过API在paypal上),然后再点击按钮,你的意思是?。第三个选项你提供的很好,但我希望我的(借记卡和信用卡)表单始终处于打开状态。