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

[Question] How to close Stripe PaymentSheet programatically from code? #6804

Closed
shaileshe2logy opened this issue May 31, 2023 · 3 comments
Closed

Comments

@shaileshe2logy
Copy link

I have implemented Stripe PaymentIntent using JAVA code described here.

I have opened this PaymentSheet in a separate Activity to display the timer above this sheet because I am not able to add any view in the PaymentSheet. I have achieved this by adding a timer view in the activity layout which is opening this PaymentSheet.

Now, I want to close the PaymentSheet programmatically when my timer gets off. I have tried to finish the activity when timer gets off but PaymentSheet keeps open and only the Activity gets finished. There is no method to close PaymentSheet from Stipe SDK.

Stripe react-native SDK is having timeout parameter to close the PaymentSheet but similar thing is not available in the native Android SDK. Reference for react-native

Any idea/suggestion would be appreciated.

Screenshot_20230531_191526

@jaynewstrom-stripe
Copy link
Collaborator

The Android platform doesn't provide a mechanism to finish an activity from another activity, which is why we don't offer it in the SDK.

(PaymentSheet also launches an Activity to display it's UI).

You can likely find a way to hack around this platform limitation by doing something like what react native has done here: https://github.com/stripe/stripe-react-native/pull/1287/files#diff-688d93031546b1fd3acc947f95a0b701ec313bd29a22ff955f826408ca8c20afR177

This isn't something we'll support in our SDK as it's prone to bugs, and limits what we can do in the future.

@shaileshe2logy
Copy link
Author

@jaynewstrom-stripe It helped to implement the close hack. Thanks 👍

I think Stripe SDK should provide closePaymentSheet() method which will finish the intent and just provide a canceled callback result similar to the close button click of PaymentSheet.

@jameswoo-stripe
Copy link
Contributor

Hi @shaileshe2logy, I am going to mark this as won't fix. It is unlikely that we will be adding this feature.

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

No branches or pull requests

3 participants