You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
paypal-j, react-paypal-js and direct implementation
🐞 Describe the Bug
Whenever there is an asynchronous operation in the onClick hook, the PayPal modal appears with a loading screen. If the user closes the modal before the async operation resolves, the onError callback is executed. The error passed to that callback is Window is closed, can not determine type. The onCancel is not called
If the asynchronous operation happens on the createOrder hook and the customer closes the modal before the login or account page has fully loaded(see additional information to what I believe is the difference), both the onCancel and onError callbacks are executed. However, the onError gets a different error: Detected popup close
On the other hand, if the customer closes the popup when the operation has finished(therefore the customer is on the login or account page), the onCancel callback is executed.
The onError and onCancel callbacks are executed differently on each case.
Case 1 (user closes popup - no overlay visible)
Only onError is called with the error.message being Window is closed, can not determine type
Case 2 (user closes popup - overlay visible)
Both onCancel and onError is called:
onError is called with the error.message being Detected popup close
onCancel is called with the canceled order_id
Case 3 (user closes popup when the paypal page has fully loaded - user is on login or account page)
Only onCancel is called with the canceled order_id
🤔 Expected Behavior
As a developer, I would expect the onCancel callback to be executed if the customer has closed the popup modal during the loading spinner/validation. If that is not possible, I would expect the error message to be the same, so I could perform my own actions should the customer abort willingly.
🌍 Environment
Node.js/npm: No node, bare HTML. But also tested in node 18 and 20
OS: macOS Sequoia 15.1.1
Browser: Google Chrome 132.0.6834.110 (Official Build) (x86_64) and Mozilla Firefox 134.0.2 (64-bit)
➕ Additional Context
I believe that the overlay is shown when the createOrder has resolved with an order_id and right before the modal gets redirected to the paypal login/account page. Before the order_id(ie, before createOrder has resolved), I believe that the overlay is not rendered. However, that is only my guess based on some tests I've run, so it could be far from the actual code implementation/behaviour.
The video should better describe what I'm trying to say.
The text was updated successfully, but these errors were encountered:
Library used
paypal-j, react-paypal-js and direct implementation
🐞 Describe the Bug
Whenever there is an asynchronous operation in the
onClick
hook, the PayPal modal appears with a loading screen. If the user closes the modal before the async operation resolves, theonError
callback is executed. The error passed to that callback isWindow is closed, can not determine type
. TheonCancel
is not calledIf the asynchronous operation happens on the
createOrder
hook and the customer closes the modal before the login or account page has fully loaded(see additional information to what I believe is the difference), both theonCancel
andonError
callbacks are executed. However, theonError
gets a different error:Detected popup close
On the other hand, if the customer closes the popup when the operation has finished(therefore the customer is on the login or account page), the
onCancel
callback is executed.🔬 Minimal Reproduction
Code to reproduce
Image when cancelling without the overlay(no onCancel, only onError)
Image when cancelling with the overlay(both onCancel and onError)
Image when cancelling on the login page(only onCancel, no onError)
Video
Screen.Recording.2025-01-24.at.2.45.02.PM.mov
😕 Actual Behavior
The onError and onCancel callbacks are executed differently on each case.
Case 1 (user closes popup - no overlay visible)
Only onError is called with the error.message being
Window is closed, can not determine type
Case 2 (user closes popup - overlay visible)
Both onCancel and onError is called:
Detected popup close
Case 3 (user closes popup when the paypal page has fully loaded - user is on login or account page)
Only onCancel is called with the canceled order_id
🤔 Expected Behavior
As a developer, I would expect the
onCancel
callback to be executed if the customer has closed the popup modal during the loading spinner/validation. If that is not possible, I would expect the error message to be the same, so I could perform my own actions should the customer abort willingly.🌍 Environment
➕ Additional Context
I believe that the overlay is shown when the createOrder has resolved with an order_id and right before the modal gets redirected to the paypal login/account page. Before the order_id(ie, before createOrder has resolved), I believe that the overlay is not rendered. However, that is only my guess based on some tests I've run, so it could be far from the actual code implementation/behaviour.
The video should better describe what I'm trying to say.
The text was updated successfully, but these errors were encountered: