cocoastorm / vue-paypal-checkout

A simple Vue.js wrapper component for paypal-checkout
MIT License
153 stars 66 forks source link

is there an event for errors? #79

Open pixelpaulaus opened 5 years ago

pixelpaulaus commented 5 years ago

seems like there is no way to catch errors, such as "DUPLICATE_TRANSACTION"? Unless i am mistaken?

JuanGongora commented 5 years ago

I would also like to know how to handle errors with this package. I know that there's payment-authorized, payment-completed, and payment-cancelled events. But what about one for errors? Even a generic one would be nice.

Is there a way to do this?

nicholi commented 5 years ago

Possible solution made in this PR: https://github.com/khoanguyen96/vue-paypal-checkout/pull/90

The underlying dependency paypal-checkout has an onError event that simply wasn't tied into before. It should allow you to catch any errors in checkout process. However I noticed identifying the exact underlying error maybe somewhat impossible (for example if it were actually a DUPLICATE_TRANSACTION). I was only able to confirm my own errors were DUPLICATE_TRANSACTION by using the dev console in Chrome open and noticing the last failed XHR network request to paypal returned that in its response. The object you get from the onError event only has a message property filled with a very boring stacktrace (and no real mention of the failed response code). But you can at the least notify end-use there was an error.

nicholi commented 5 years ago

Apparently the lack of useful error object is a known thing, semi-discussion in this issue: https://github.com/paypal/paypal-checkout-components/issues/479

nicholi commented 5 years ago

I missed the big Note in the official docs, https://developer.paypal.com/docs/checkout/integration-features/handle-errors/.

Just a very general event.