-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Connect Stripe with the frontend #1169
Conversation
Visit the preview URL for this PR (updated for commit 257f719): https://sharezone-test--pr1169-stripe-8oqubjma.web.app (expires Sun, 10 Dec 2023 14:21:40 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b |
final checkoutUrl = await _stripeCheckoutSession.create( | ||
userId: '$_userId', | ||
); | ||
|
||
await launchUrl( | ||
Uri.parse(checkoutUrl), | ||
// Since the request for creating the checkout session is asynchronous, we | ||
// can't open the checkout in a new tab due to the browser security | ||
// policy. | ||
// | ||
// See https://github.com/flutter/flutter/issues/78524. | ||
webOnlyWindowName: "_self", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very basis implementation since error handling, analytics, etc. for Sharezone Plus will be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think I personally would prefer it opening a new tab (just as a general thought, no need to change it)
I agree, but it's a bit difficult due to browser security policies (see flutter/flutter#78524). We can either make the URL available synchronously or open it in the same tab. What I have done for AnkiGPT is to request a checkout session URL immediately upon opening the page, hoping that by the time the user reaches the subscribe button, the URL is already loaded (mixing both solutions, when the URL isn't available yet, open in the same tab). However, this also has a few edge cases that need to be addressed when implementing. |
Description
This PR connects the Stripe with the frontend. For now, it's only creating a checkout session to buy Sharezone Plus. Later, things like the Stripe portal will be added.
Things for future pull requests
cancel_url
andsuccess_url
to thecreateStripeCheckoutSession
cloud functionDemo
Screen.Recording.2023-12-07.at.14.48.27.mov