Paypal的交易对象,交易失败

时间:2014-03-06 17:29:32

标签: paypal transactions paypal-rest-sdk

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

直接从pay.als rest api for node.js

获取以下代码
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个交易对象时会发生什么,我们是否必须处理第二笔交易中信用卡减少的情况?

1 个答案:

答案 0 :(得分:0)

这就是我们最终使用的内容。我们使用项目feild告诉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
    }]
};