When I try to test payments, my code works only if I use an account of type 'partner' (the account provided when I created the REST API app). However, if I use an account from the testing tools, the payment fails.
当我尝试测试支付时,我的代码只有在我使用‘Partner’类型的帐户(我创建rest API应用程序时提供的帐户)时才能工作。但是,如果我使用测试工具中的帐户,付款将失败。
This is my code:
这是我的代码:
paypal.Buttons({
createOrder: function(data, actions) {
// Seller information with amount and email
const sellers = [
{ amount: '2', email: '[email protected]' },
{ amount: '2', email: '[email protected]' },
{ amount: '2', email: '[email protected]' }
];
// Prepare an array of purchase units for each seller
const purchase_units = sellers.map((seller, index) => {
return {
reference_id: `seller_${index + 1}`, // Unique reference ID for each purchase unit
amount: {
value: seller.amount
},
payee: {
email_address: seller.email
}
};
});
// Create the order with the array of purchase units
return actions.order.create({
purchase_units: purchase_units
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert("Payment succeeded");
});
},
onCancel: function(data) {
alert("Payment canceled.");
},
onError: function(err) {
alert("An error occurred. Please try again later.");
console.error(err);
}
}).render('#paypal-button-container');
If I replace the three emails in the array with the email of a partner account, the payment succeeds. However, if I use another account, it tells me: "An error occurred. Please try again later."
如果我将数组中的三封电子邮件替换为合作伙伴帐户的电子邮件,则付款成功。然而,如果我使用另一个帐户,它会告诉我:“发生错误。请稍后再试。”
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!