【问题标题】:Create a payment with Paypal REST API使用 Paypal REST API 创建付款
【发布时间】:2014-05-24 06:41:49
【问题描述】:

这就是我从我的 web 应用创建 Paypal 付款的方式:

paypal.configure(paypal_config.api);
var payment = {
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  //"receiver_email":  "business@place.fr",
  "redirect_urls": {
    "return_url": "http://yoururl.com/execute",
    "cancel_url": "http://yoururl.com/cancel"
  },

  "transactions": [{
    "item_list": {
        "items": [{
            "name": "item",
            "sku": "item",
            "price": "1.00",
            "currency": "USD",
            "quantity": 1
        }]
    },
    "amount": {
        "currency": "USD",
        "total": "1.06",
        "details": {
          "subtotal": "1.00",
          "tax": "0.03",
          "shipping": "0.03"
        }
    },
    "description": "This is the payment description."
  }]
};

paypal.payment.create(payment, function (error, payment) {
  if (error) {
    console.log(error);
  } else {
    if(payment.payer.payment_method === 'paypal') {
      req.session.paymentId = payment.id;
      var redirectUrl;
      for(var i=0; i < payment.links.length; i++) {
        var link = payment.links[i];
        if (link.method === 'REDIRECT') {
          redirectUrl = link.href;
        }
      }
      res.redirect(redirectUrl);
    }
  }
});

效果很好,但我有两个问题,我需要设置receiver email,当我添加密钥“receiver_email”时,据说请求格式不正确。

我的第二个问题实际上更多的是一个问题,使用这种方法我直接知道付款是否经过验证,但是当付款需要更多时间来验证时会发生什么(银行转账等),没有 ipn要给的网址?

谢谢!

【问题讨论】:

  • 你解决了吗?我也有同样的问题。
  • 不幸的是没有...:/我目前不在同一个项目上工作,但我必须尽快回来!如果您找到解决方案,请告诉我。谢谢。
  • 重定向时出现 CORS 错误。我该如何解决?

标签: node.js api paypal payment-gateway


【解决方案1】:

我认为目前不支持将接收者设置为与 client_id 不同。

【讨论】:

    【解决方案2】:

    目前使用 PayPal 余额付款,您无法配置收款人,因此收款人必须是具有 client_id/client_secret 对的人。

    关于您的第二个问题,目前 ipn 支持不支持 REST 付款,但“付款状态更改时将 http 发布到您的服务器”功能将很快用于 REST 付款。目前最好的选择是通过执行 GET 检查状态变化来获取带有 PAY-XXX id 的付款。

    【讨论】:

      猜你喜欢
      • 2017-07-13
      • 2013-08-29
      • 2017-10-04
      • 2013-07-04
      • 2014-04-27
      • 2016-10-14
      • 2017-05-13
      • 2016-05-20
      • 2017-11-20
      相关资源
      最近更新 更多