Paypal checkout (smart button) handle error in create order function
jisna
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Apr-03-2019
05:10 AM
Hi,
I am new to paypal. I have started to use paypal checkout for my application.
From the paypal doc, below is the create order function to the server side.
createOrder: function() {
return fetch('/my-server/create-paypal-transaction', {
method: 'post',
headers: {
'content-type': 'application/json'
}
}).then(function(res) {
return res.json();
}).then(function(data) {
return data.orderID;
});
}
How can I handle error if for any reason I couldn't get the order id? I have the code
onError: function (err) {
// Show an error page here, when an error occurs
console.log(err);
}
If there is any error and if I didn't get order id , now it just show in console that "Expected a promise for a string order id to be passed to createOrder".
How can I show the exact error message?
Labels:
Login to Me Too
- Labels:
-
PayPal HTML Buttons
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
- How do you create subscriptions with PayPal Advanced Checkout? in SDKs
- PHP SDK error: broken content-length header in SDKs
- Create Pay Links using PayPal API in REST APIs
- Selected Shipping Method amount not updating to cart for card payment in SDKs
- CHECKOUT.ORDER.APPROVED webhook event not triggered if payment_source is passed in in REST APIs