gpt4 book ai didi

交易失败的Paypal交易对象

转载 作者:太空宇宙 更新时间:2023-11-03 16:09:41 26 4
gpt4 key购买 nike

我们使用 Paypal Pro 进行直接信用卡处理。当我在请求中放入 2 笔交易时,信用卡批准了一个交易对象,但由于资金不足而拒绝了另一个交易对象,会发生什么情况。 PayPal 会丢弃整个交易并返回错误吗?

直接从 node.js 的 paypals rest api 中获取以下代码

var payment_details = {
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [{
"credit_card": {
"type": "visa",
"number": "4417119669820331",
"expire_month": "11",
"expire_year": "2018",
"cvv2": "874",
"first_name": "Joe",
"last_name": "Shopper",
"billing_address": {
"line1": "52 N Main ST",
"city": "Johnstown",
"state": "OH",
"postal_code": "43210",
"country_code": "US" }}}]},
"transactions": [{
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.41",
"tax": "0.03",
"shipping": "0.03"}},
"description": "This is the payment transaction description." }]};

paypal_sdk.payment.create(payment_details, function(error, payment){
if(error){
console.error(error);
} else {
console.log(payment);
}
});

当我们将 2 个交易对象放在那里时会发生什么情况,我们是否必须处理信用卡在第二次交易中被拒绝的情况?

最佳答案

这就是我们最终使用的。我们使用 items 字段来告诉 paypal 有关交易中的多个项目。 Items 是一个项目数组:

items.push({
quantity: "1",
name: classList[i].name,
price: price.toFixed(2),
currency: "USD"
});

var create_payment_json = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://"+config.host+"/payment/success/"+paymentId,
"cancel_url": "http://"+config.host+"/payment/cancel/"+paymentId
},
"transactions": [{
"item_list": {
"items": items
},
"amount": {
"currency": "USD",
"total": (total.toFixed(2))
},
"description": description
}]
};

关于交易失败的Paypal交易对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22231720/

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