Paypal Checkout - Set up a Transaction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there,
I am trying to add more information to this step: paypal.Buttons({ createOrder: function(data, actions)}), such as shipping address, etc ...
In this doc page /docs/checkout/reference/server-integration/set-up-transaction/ is shown how to do it:
createOrder on the server, return results
{"statusCode":201,"result":{"id":"3Y963135SM0142709","intent":"CAPTURE","purchase_units":[{"reference_id":"default","amount":{"currency_code":"EUR","value":"220.00"},"payee":{"email_address":"facilitator(at)fakeemail.com)","merchant_id":"xxxxxxxxxxxxxx"}}],"create_time":"2019-03-05T06:55:36Z","links":[{"links":"the links"}],"status":"CREATED"},"headers":{"":"","Date":"Tue, 05 Mar 2019 06","Server":"Apache","paypal-debug-id":"2416d43ead646","HTTP_X_PP_AZ_LOCATOR":"sandbox.slc","Paypal-Debug-Id":"xxxxxxx","Set-Cookie":"X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00","Vary":"Authorization","Content-Length":"751","Connection":"close","Content-Type":"application/json"}}
add result to client
createOrder: function() { return fetch('/my-server/create-paypal-transaction') .then(function(res) { return res.json(); }).then(function(data) { return data.orderID; }); }
By following the indication in the docs i have always 4 error:
no_orderid_passed_to_createorder
and 3 times Uncaught Error: Expected a promise for a string order id to be passed to createOrder
It seems that createOrder can't find order id, which I presume to be this one "result":{"id":"3Y963135SM0142709"}, as shown also in here /docs/api/orders/v2/#orders-create-response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@jacofda I kept getting the following error myself, too
Error: Expected a promise for a string order id to be passed to createOrder
This got me for a minute, too, but I realized what the issue is, at least in my case. I was pretty much just following the example documentation paypal has except I'm making a server side call to create an order object. The example js that paypal says you should use in that case is this:
createOrder: function() { return fetch('/my-server/create-paypal-transaction') .then(function(res) { return res.json(); }).then(function(data) { return data.orderID; }); }
What paypal returns is a node called "id" for the order id. This example code is expecting a node called "orderID". All I basically did was just update the node to this
createOrder: function() { return fetch('/my-server/create-paypal-transaction') .then(function(res) { return res.json(); }).then(function(data) { return data.id; }); }
and server side for the create order response, I'm just outputting
{ id: "<order id>", ... }
and now its working. Hope that helps!
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Getting errors when integrating standard checkout with my web site. Probably a beginner problem. in SDKs
- Need help to integrate Advanced Checkout (PPCP) With WHMCS in PayPal Upgrade Community
- IPN works in sandbox but not live in Sandbox Environment
- Need help to integrate PayPal Checkout with Ecwid in PayPal Upgrade Community
- Change the button from Sandbox to Production in PayPal Payments Standard