Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing the Google Pay payment sheet with the cancel button does not emit event or throw #41

Open
1 of 3 tasks
rdlabo opened this issue Oct 7, 2023 · 0 comments
Open
1 of 3 tasks

Comments

@rdlabo
Copy link
Collaborator

rdlabo commented Oct 7, 2023

FROM: capacitor-community/stripe#276

Platform

  • Web
  • iOS
  • Android

Describe the bug
If the user presses the close button in the Google Pay interface, GooglePayEventsEnum.Canceled is not emitted nor is any error thrown. In my experience only the events GooglePayEventsEnum.Loaded and GooglePayEventsEnum.Completed work.

This bug seems to be present in the demo as well.

It should at the very least throw an unknown error: right now it appears that the Promise is never resolved or rejected

I have not tested with Apple Pay as I have not set it up yet, but this problem could be relevant to it as well.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://capacitor-community-stripe.netlify.app/tabs/demo'
  2. Click on 'Google Pay - create'
  3. Click on 'Google Pay - present'
  4. From the appearing modal, close the window.
  5. No cancel event is emitted nor error is thrown.

Expected behavior
I expect an event to be emitted when user deliberately closes the Google Pay interface, either via the close button or clicking outside of the modal.

If resolving the Promise with a specific event is not possible, at least throw an error so async logic can complete. Code such as

const { paymentResult } = await stripe.presentGooglePay();

if (paymentResult !== GooglePayEventsEnum.Completed) {
       throw new Error(ERROR_GOOGLE_PAY);
}

Works fine when user enters their payment information correctly and does not cancel, but if they do cancel, the code will be stuck indefinitely awaiting presentGooglePay to resolve.

Listening to events such as

 stripe.addListener(GooglePayEventsEnum.Canceled, () => {
            console.log('Canceled')
 });

Does not work either, only Loaded / Completed seem to be emitted.

Screenshots

Additional context
"@stripe-elements/stripe-elements": "2.0.2"
"@capacitor-community/stripe": "^4.2.0"
"react": "^18.2.0"

I use the useCapacitorStripe hook which works fine otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant