简体   繁体   English

贝宝快速结帐-400错误的要求

[英]paypal express checkout - 400 bad request

I'm using this instruction https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/advanced-integration/ to set up paypal. 我正在使用此指令https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/advanced-integration/来设置贝宝。 The only different is that I need to send data to CREATE_PAYMENT_URL endpoint, so I transfer it as second parameter 唯一的不同是,我需要将数据发送到CREATE_PAYMENT_URL端点,因此我将其作为第二个参数进行传输

paypal.request.post(
                CREATE_PAYMENT_URL,
                JSON.stringify([{"name": "test", "price": 10}]),
                { headers: { 'Content-Type': 'application/json' } }

            )

after that I'm getting 400 error 之后,我得到400错误

{"success":false,"errors":{"statuscode":400,"message":"Invalid json message received"}}

Backend doesn't matter, cause it's never reached. 后端无关紧要,因为它从未达到。 Also I'm almost sure it worked fine few days ago Any ideas? 另外,我几乎可以肯定,几天前它能正常工作吗?有什么想法吗?

Fiddler screen 提琴手屏幕 在此处输入图片说明

Try setting the second param to null, and send an options object as the third param with an object named json in the third with a plain JS object inside. 尝试将第二个参数设置为null,并发送一个options对象作为第三个参数,其中第三个参数名为json ,第三个参数中包含一个普通的JS对象。

paypal.request.post(PAYMENT_URL, null, {
    json : {
        name:'test',
        price:10
      }
  })

It's not in the documentation, I was having similar issues but dug around in the source code to get it to work. 它不在文档中,我遇到了类似的问题,但在源代码中进行了挖掘以使其正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM