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

Connect Stripe with the frontend #1169

Merged
merged 4 commits into from
Dec 7, 2023
Merged

Connect Stripe with the frontend #1169

merged 4 commits into from
Dec 7, 2023

Conversation

nilsreichardt
Copy link
Member

@nilsreichardt nilsreichardt commented Dec 5, 2023

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

  • Pass cancel_url and success_url to the createStripeCheckoutSession cloud function
  • Add link for Stripe portal session
  • Add Stripe to our website

Demo

Screen.Recording.2023-12-07.at.14.48.27.mov

@github-actions github-actions bot added the feature: sharezone plus Includes everything that is related to the Sharezone Plus subscription label Dec 5, 2023
@github-actions github-actions bot added code quality Code quality itself (readable) but e.g. also how we might enforce better quality automatically. testing dependencies Changing, updating, adding or removing one or more dependencies. labels Dec 7, 2023
Copy link

github-actions bot commented Dec 7, 2023

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

Comment on lines +82 to +94
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",
);
Copy link
Member Author

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.

@nilsreichardt nilsreichardt marked this pull request as ready for review December 7, 2023 14:17
Copy link
Collaborator

@Jonas-Sander Jonas-Sander left a 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)

@nilsreichardt
Copy link
Member Author

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.

@nilsreichardt nilsreichardt added this pull request to the merge queue Dec 7, 2023
Merged via the queue into main with commit 0d33558 Dec 7, 2023
23 checks passed
@nilsreichardt nilsreichardt deleted the stripe branch December 7, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Code quality itself (readable) but e.g. also how we might enforce better quality automatically. dependencies Changing, updating, adding or removing one or more dependencies. feature: sharezone plus Includes everything that is related to the Sharezone Plus subscription testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants