0

我的返回 URL 不适用于paypi-rest-sdkNodeJS。

付款后页面:https ://space.zeo.net/g/2x2n1

页面应该是:http ://www.mywebsite.fr/confirm

      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);
          }
        }
      });
4

2 回答 2

1

嘿,尝试使用 developer.paypal.com/webapps/developer/docs/integration/direct/... 创建付款,即只发送 curl 请求。如果您能够做到这一点并且重定向有效,那么您可以消除这是您的帐户设置或凭据的问题,并且返回 url 的格式正确。然后尝试来自 github.com/paypal/rest-api-sdk-nodejs/samples 的示例,如果示例有效,则问题可能与您的应用程序有关。

Eshan 的建议也可能是这里的问题。

于 2014-10-13T20:23:22.637 回答
0

使用 npm paypal-rest-sdk 包。我曾经有同样的问题。然后在我重定向支付页面之后。你给了response.redirect(redirectUrl); 它在读取所有代码异步过程时正在执行,因此重定向不起作用。您在执行 if 条件时提供重定向代码!

于 2020-03-13T10:32:49.060 回答