JS PayPal REST integration error: MALFORMED_REQUEST
andrOl
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Jul-02-2018
07:40 AM
Hello, guys!
I try to integrate PayPal API to my app. When I try to make call to API in my script I got an error:
Incoming JSON request does not map to API request. This is the full object of error:
{ debug_id:"8280412cbada", information_link:"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST", message:"Incoming JSON request does not map to API request", name:"MALFORMED_REQUEST" }
But when I try to make call via EasyRest with the same parameters all is working OK.
This is the code which I used to make call:
function payPalStep3(gAccessToken, gPrice, gCurrency, gOrderNumber){ return new Promise((resolve, reject) => { let newPayment = { intent: 'sale', redirect_urls: { return_url: 'http://localhost:3000/success.html', cancel_url: 'http://localhost:3000/reject.html' }, payer: { payment_method: 'paypal' }, transactions: [{ amount: { total: parseFloat(gPrice), currency: gCurrency } }] } let req = new XMLHttpRequest(); let UrlReq = 'https://api.sandbox.paypal.com/v1/payments/payment'; req.open('POST', UrlReq, true); req.setRequestHeader('Content-Type', 'application/json'); req.setRequestHeader('Authorization', 'Bearer '+gAccessToken); req.onreadystatechange = function(){ if(req.readyState == 4){ let shopUserResponse = req.response; shopUserResponse = JSON.parse(shopUserResponse); resolve(shopUserResponse); } req.onerror = () => err(false); } req.send(newPayment) }) }
Maybe somebody can help me, please.
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Using Paypal Smart Buttons for checkout sometimes fails with Debit/ Credit Cards Form in Braintree Client-side Integration (JS, iOS, Android SDKs)
- Sandbox account not generating IPNs in Sandbox Environment
- Need help to integrate PayPal Checkout (PPCP) with OpenCart? in PayPal Upgrade Community
- How can I integrate PayPal to enable direct tipping features between users on a content platform? in REST APIs
- Need help to integrate PayPal Checkout with Ecwid in PayPal Upgrade Community