Showing results for 
Search instead for 
Did you mean: 

"Expected an order id to be passed" when integrating with paypal smart payment buttons.

This has to be something really simple. I am able to use fetch to make a server call to my rest api and return the response without any issues. I can receive the data.orderID, but after the thens for the fetch complete, I continually get the "Expected an order id to be passed" message. I have tried returning the transId and the token as the id and orderID, but I still get the same message. Can someone please tell me what I am doing wrong?



createOrder: function () {

return fetch('http://localhost:22553/ewsmainservice.svc/AuthorizationOnly', {
method: 'post',
body: JSON.stringify({"foo": "bar"}),
headers: {'Content-Type': 'application/json'}
}).then(function (res) {
return res.json();
}).then(function (data) {
var getData = JSON.parse(data);
return getData.orderID;
// Finalize the transaction
onApprove: function(data, actions) {
return fetch('/demo/checkout/api/paypal/order/' + data.orderID + '/capture/', {
method: 'post'
}).then(function (res) {
return res.json();
}).then(function (details) {
// Show a success message to the buyer
alert('Transaction completed by ' + + '!');
onError: function(err) {
// Show an error page here, when an error occurs
//alert('in onError');
$('#AddShippingInfoDiv').css('display', 'block');