Skip to content

onAuthorized reject is typed as 0 args but its the raw promise reject #4129

Description

@chrisneven

Describe the bug

The reject passed to onAuthorized is typed as taking no arguments, so you write actions.reject(). At runtime its the raw promise reject, so that rejects with undefined. PayPal's zalgo-promise then throws Expected reject to be called with Error, got [object Undefined], adyen-web catches that and surfaces it as "Something went wrong while parsing PayPal Order".

End result is that any deliberate reject on our side reaches us as a parsing error with the real reason gone.

To Reproduce

  1. Set up the PayPal component in the sessions flow
  2. Implement onAuthorized and reject it, e.g. catch (e) { return actions.reject() }. Passing anything else doesnt compile, actions.reject(e) gives "Expected 0 arguments, but got 1"
  3. Trigger whatever your reject path is (we validate the cart total against the authorized amount)
  4. onError fires with AdyenCheckoutError: Something went wrong while parsing PayPal Order, cause is Error: Expected reject to be called with Error, got [object Undefined]

Expected behavior

Rejecting should surface our reason. Either widen the type to reject(reason?: unknown) so we can pass an Error, or wrap it with a default like you already do for beforeSubmit in the same file:

reject: () => t(new CancelError("beforeSubmitRejected"))

Also a merchant reject isnt a parse failure, so the message shouldnt say it is.

Screenshots

n/a, sentry stacktraces instead. The relevant frame is components/PayPal/Paypal.tsx:175.

Desktop / Smartphone

Not device specific, its deterministic. We see it across everything, for example:

  • Android 10 / Chrome Mobile 150
  • iOS 26.5.2 / iPhone / in-app browser

Version: adyen-web 6.41.0, sessions flow

Additional context

Been our biggest PayPal issue for ~17 months, around 164 shoppers. Took us ages to find because the error message points at order parsing. We're casting to a wider signature and always passing an Error for now.

Full disclosure, I had Claude do the digging here. But these are real errors straight out of our Sentry, not something it made up.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions