cancel
Showing results for 
Search instead for 
Did you mean: 

Paypal checkout (smart button) handle error in create order function

Options
jisna
Contributor
Posted on

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?

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.