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

[BUG] Tapping cross on the payment sheet triggers flow for any previous payment option that was selected before #9138

Open
omertanveer opened this issue Aug 28, 2024 · 2 comments
Labels

Comments

@omertanveer
Copy link

Hi

I am using PaymentSheet.FlowController.
I initialise it using PaymentSheet.FlowController.create which takes a paymentOptionCallback

Any time when user taps the pay button on my activity, I call configureWithIntentConfiguration() on the flow controller.
It has a ConfigCallback which returns success or an error.
In case of success, I call presentPaymentOptions() method on the flow controller.

Now on the payment sheet if I don't select anything and tap cross, the payment sheet dismisses and the paymentOptionCallback is triggered which shows the paymentOption as null.

Now if reopen the payment sheet, and select a payment method, lets say "Pay with link", then paymentOptionCallback is triggered and has a paymentOption and then I trigger confirm() method of the flow controller which then takes me to the browser where it asks me for login details. At this point if I just don't fill anything and close browser, then the payment option is not null anymore and paymentResultCallback is called as Canceled.

Now the user is back to the app. At this point if I open then payment sheet again and just tap cross, the paymentOptionCallback is triggered and it still shows the paymentOption as the stripe link and then it takes me to the browser again asking me for login details for "Pay with link". Because in paymentOptionCallback I trigger confirm() method of the flow controller.

In paymentOptionCallback how can I distinguish if the user actually just closed the payment sheet or has actually started the flow again with the said option?

Don't you think that if I just tap cross on the payment sheet, then it shouldn't trigger anything even if any other payment option was selected earlier which was not successful?

Would be great if someone can shed some light on this.

@samer-stripe
Copy link
Collaborator

samer-stripe commented Aug 28, 2024

Hey @omertanveer! Seems like you have an integration error with FlowController. The intention of FlowController is to allow you to show the selected payment option in your UI before proceeding with payment. Inside your own UI, you would have your own Pay button that would call confirm.

In this case, it seems you call confirm on every paymentOptionCallback call which isn't right. The Canceled will return a payment option because there is a chance the original selected payment option was removed if the selected option was a saved card for instance.

If you don't plan on showing the payment option inside of your own UI, you can instead use PaymentSheet rather than PaymentSheet.FlowController which handles the entire payment flow process within the sheet itself. See instructions on how to implement it here.

@omertanveer
Copy link
Author

Well initially I started using Paymentsheet instead of the FlowController.

But there are some challenges with using the PaymentSheet itself. It normally closes only in case of a full successful flow. So there were scenarios where we wanted to close it via code but there seemed to be no possibility. Also in case of authentication, if the user tapped "Fail", there was no callback returned at all. So had to switch to FlowController.

Yes with the FlowController I am calling confirm() on every paymentOptionCallback. I see what you mean by the intention of the FlowController. That's why on my activity the button that I show says "Continue to payment" (along with the order total) and tapping on this triggers the configureWithIntentConfiguration of the flowController and once the callback is success we call the presentPaymentOptions of the flow controller. Also the primaryButtonLabel that I am using in the configuration says "Place order". So when the user actually selects a payment method like credit card and fill in their card details with valid info, then tapping on the "Place order" then actually triggers the call to process the order.

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

No branches or pull requests

2 participants