错误:响应状态:PayPal Rest SDK为400

卡林·奥纳卡(Calin Onaca)

我在NodeJS的帮助下使用一些PayPal Payments创建了一个平台,到目前为止一切正常,我不知道为什么它会引发这个错误。大约1小时前,我付款了,现在还不允许我付款。我还没有修改任何代码或类似的内容。]

这是错误

/ Users / calinonaca / Desktop / PEDIGREE-NOTES复制/控制器/feed.js:863抛出错误;^

错误:响应状态:IncomingMessage处为400。(/ Users / calinonaca / Desktop / PEDIGREE-NOTES copy / node_modules / paypal-rest-sdk / lib / client.js:130:23)位于EndReadableNT(_stream_visible.js)的IncomingMessage.emit(events.js:203:15) :1145:12)在process._tickCallback(internal / process / next_tick.js:63:19)

这是我的功能

exports.postPayment = (req,res,next) => {
    const uploadedBy = req.body.noteOwner;
    const finalprice = req.body.finalprice;
    const notename = req.body.notename;
    const loggedInUser = req.session.user._id;
    const noteprice = req.body.noteprice;




    const create_payment_json = {
        "intent": "sale",
        "payer": {
            "payment_method": "paypal"
        },
        "redirect_urls": {
            "return_url": "http://localhost/successPayment/"+finalprice+"/"+notename+"/"+uploadedBy+"/"+noteprice+"/"+loggedInUser,
            "cancel_url": "http://localhost/cancel"
        },
        "transactions": [{
            "item_list": {
                "items": [{
                    "name": "Note",
                    "sku": "001",
                    "price": finalprice,
                    "currency": "USD",
                    "quantity": 1
                }]
            },
            "amount": {
                "currency": "USD",
                "total": finalprice
            },
            "description": "Note you ordered"
        }]
    };



    paypal.payment.create(create_payment_json, function (error, payment) {
        if (error) {
            throw error;
        } else {
        for(let i = 0; i < payment.links.length; i++)
        {
            if(payment.links[i].rel === 'approval_url')
            {
                res.redirect(payment.links[i].href);
            }
        }
        }
    });

}

到现在为止一切都很好,我不知道出什么问题了,您能帮我吗?谢谢!

阿图尔·奥

我希望这会有所帮助,我遇到了同样的问题,我不得不挖掘几乎所有可能的链接和资源,我发现您必须在这里映射完全相同的对象

  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "total": "30.11",
        "currency": "USD",
        "details": {
          "subtotal": "30.00",
          "tax": "0.07",
          "shipping": "0.03",
          "handling_fee": "1.00",
          "shipping_discount": "-1.00",
          "insurance": "0.01"
        }
      },
      "description": "The payment transaction description.",
      "custom": "EBAY_EMS_90048630024435",
      "invoice_number": "48787589673",
      "payment_options": {
        "allowed_payment_method": "INSTANT_FUNDING_SOURCE"
      },
      "soft_descriptor": "ECHI5786786",
      "item_list": {
        "items": [
          {
            "name": "hat",
            "description": "Brown hat.",
            "quantity": "5",
            "price": "3",
            "tax": "0.01",
            "sku": "1",
            "currency": "USD"
          },
          {
            "name": "handbag",
            "description": "Black handbag.",
            "quantity": "1",
            "price": "15",
            "tax": "0.02",
            "sku": "product34",
            "currency": "USD"
          }
        ],
        "shipping_address": {
          "recipient_name": "Brian Robinson",
          "line1": "4th Floor",
          "line2": "Unit #34",
          "city": "San Jose",
          "country_code": "US",
          "postal_code": "95131",
          "phone": "011862212345678",
          "state": "CA"
        }
      }
    }
  ],
  "note_to_payer": "Contact us for any questions on your order.",
  "redirect_urls": {
    "return_url": "https://example.com/return",
    "cancel_url": "https://example.com/cancel"
  }

只有复制并粘贴此对象后,我才能获得带有重定向URL的成功响应。我希望这能帮到您。我将和对象一起玩耍,看看是否有什么可以忽略的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

PayPal REST API OAuth响应错误

Google Apps 脚本中的 PayPal REST API 错误 400

与PayPal连接:获取状态400(错误请求)

使用okHttp 4.将json数据发布到rest api时,响应代码为400的错误请求

如何使用Paypal-rest-SDK摆脱验证错误?

PHP Paypal REST 创建付款错误的 JSON 响应

tweepy错误响应状态码400

错误:响应失败:收到状态码400

Paypal Rest Api错误

批准后无法从Laravel中的PayPal响应(SDk rest api)获取用户电子邮件

当状态为类似400的错误并引发异常时,如何读取Python urllib上的响应正文?

spring post无法加载资源:服务器响应状态为400(错误请求)

PHP 表单:服务器响应状态为 400(错误请求)

http响应状态为400时,使用fetch api获取自定义错误消息

angularjs:加载资源失败:服务器响应状态为 400(错误请求)

反应 - 加载资源失败:服务器响应状态为 400(错误请求)

PayPal-PHP-SDK使用异常[Http响应代码400]

如何在春季JPA应用程序中集成Paypal Rest API。错误代码400

当 HTTP 响应状态为 400 时,我想念响应 .status,

基于REST的响应状态代码

在WebResponse响应处获得的Paypal 400错误请求错误响应= request.GetResponse();

PayPal SDK沙盒模式会返回错误链接的响应

不建议使用PayPal REST SDK

PayPal Rest SDK API-获取令牌

C ++ Rest SDK将长数据类型传递到请求正文中会导致400错误请求

返回的响应状态为415不支持的媒体类型REST客户端

在 react-native 项目中包含 paypal-rest-sdk 会产生错误

使用Axioson 400和401状态代码检索响应错误

远程服务器返回了意外的响应:(400)错误的请求WCF REST