【问题标题】:Make payment using paypal and NodeJS使用 paypal 和 NodeJS 付款
【发布时间】:2014-10-16 10:18:05
【问题描述】:

我想使用 NodeJS 和 PayPal API 付款,但它不起作用,因为我创建的应用程序使用的是 Sandbox,而不是实时...

如何实时使用PayPal?

我的 JSON 配置:

{
  "api" : {
    "host" : "api.sandbox.paypal.com",
    "port" : "",
    "client_id" : "*****",
    "client_secret" : "*****"
  },
  "returnUrl" : "http://localhost:3000/returnurl",
  "cancelUrl" : "http://localhost:3000/order/user/"
}

我的 NodeJS 代码:

this.paypal.configure(paypalConfigs.api);

var payment = {
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "redirect_urls": {
    "return_url": paypalConfigs.returnUrl,
    "cancel_url": paypalConfigs.cancelUrl+request.user.id
  },
  "transactions": [{
    "amount": {
      "total": total,
      "currency": "EUR"
    },
    "description": "Commande Printwithlove"
  }]
};

paypal.payment.create(payment, function (error, payment) {
  if (error) {
    console.log(error);
  } else {
    if(payment.payer.payment_method === 'paypal') {
      request.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;
        }
      }
      response.redirect(redirectUrl);
    }
  }
});

还有我在 PayPal 上的应用:

编辑:

[**.fr.3008-13 (out)] { [Error: Response Status : 401]
[**.fr.3008-13 (out)]   response: 
[**.fr.3008-13 (out)]    { error: 'invalid_client',
[**.fr.3008-13 (out)]      error_description: 'The client credentials are invalid',
[**.fr.3008-13 (out)]      httpStatusCode: 401 },
[**.fr.3008-13 (out)]   httpStatusCode: 401 }

【问题讨论】:

    标签: paypal


    【解决方案1】:

    从沙盒转为实时所需的唯一更改是将端点从“api.sandbox.paypal.com”更改为“api.paypal.com”并使用来自 developer.paypal 的实时凭据.com

    【讨论】:

    • 使用实时凭据时出现错误消息:“客户端凭据无效”
    • 检查这个问题以获得一些解决方案link
    猜你喜欢
    • 2011-04-21
    • 2014-03-23
    • 2018-07-08
    • 2016-03-07
    • 2020-11-04
    • 2013-09-04
    • 2012-01-06
    • 2018-12-12
    相关资源
    最近更新 更多