onError function help... checkout.js

sipi41
Contributor
Contributor

Dear friends, I do have a question regarding the onError function on the checkout.js used by paypal. I basically understand that I can execute any javascript there but I would like to get the details or the message given from the page that failed... take as example this case:  I have a page that will produce a Payment,(http://localhost:63733/Paypal/create-payment), I have decided to include an invalid credential and managed to get a nice error message delivered in json as follow: 

{"error":"invalid_client","error_description":"Client Authentication failed"}

The idea here is, I did the request, the server found a problem 500x and return a json that JS can manage, the big question here is... how do I get these json on my client side so I can display a msg in the client browser saying: "Ups, something went wrong! Client Authentication failed." than just a generic ugly error like the one in the variable err content, take a look... 

Error: Error: No value passed to payment at https://www.paypalobjects.com/api/checkout.js:12849:43 at _loop (https://www.paypalobjects.com/api/checkout.js:8869:54) at ZalgoPromise.value (https://www.paypalobjects.com/api/checkout.js:8893:61) at ZalgoPromise.value (https://www.paypalobjects.com/api/checkout.js:8824:26) at https://www.paypalobjects.com/api/checkout.js:8799:48 at _loop (https://www.paypalobjects.com/api/checkout.js:8869:54) at ZalgoPromise.value (https://www.paypalobjects.com/api/checkout.js:8893:61) at ZalgoPromise.value (https://www.paypalobjects.com/api/checkout.js:8824:26) at _loop (https://www.paypalobjects.com/api/checkout.js:8892:42) at ZalgoPromise.value (https://www.paypalobjects.com/api/checkout.js:8893:61) at Object.postrobot_message_response (https://www.paypalobjects.com/api/checkout.js:2797:31) at receiveMessage (https://www.paypalobjects.com/api/checkout.js:2842:60) at messageListener (https://www.paypalobjects.com/api/checkout.js:2863:13)

is there a way that I can see the request response, parse it and use wherever I want from the server response?  Thank you in advance! 🙂

Login to Me Too
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.