gpt4 book ai didi

Integrating PayPal into an eCommerce platform using JS(使用JS将PayPal集成到电子商务平台中)

转载 作者:bug小助手 更新时间:2023-10-24 23:01:16 25 4
gpt4 key购买 nike



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."

如果我将数组中的三封电子邮件替换为合作伙伴帐户的电子邮件,则付款成功。然而,如果我使用另一个帐户,它会告诉我:“发生错误。请稍后再试。”


更多回答
优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com