【问题标题】:Paypal's transaction object with failing transactionsPaypal 的交易对象,交易失败
【发布时间】:2014-04-09 12:23:00
【问题描述】:

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

直接从 paypals 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);
  }
});

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

【问题讨论】:

  • 刚刚意识到您必须在贝宝中使用列表项对象。文档中没有真正提到。每个请求只能有 1 个事务对象。

标签: paypal transactions paypal-rest-sdk


【解决方案1】:

这就是我们最终使用的。我们使用项目字段来告诉贝宝交易中的多个项目。 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
    }]
};

【讨论】:

  • 我也是这样做的。但我收到“验证错误”!!有什么想法吗?
猜你喜欢
  • 2013-05-09
  • 2018-10-03
  • 2021-05-11
  • 2012-03-12
  • 2011-09-03
  • 2015-08-27
  • 1970-01-01
  • 2013-02-24
  • 1970-01-01
相关资源
最近更新 更多