-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improve Stripe payment provider logic #505
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
Open
FranjoMindek
wants to merge
53
commits into
main
Choose a base branch
from
franjo/refactor-stripe-payment-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
809e982
Stripe only changes
FranjoMindek 3df17a2
changes
FranjoMindek d0a2e15
further improvements
FranjoMindek 1560833
remove typ catch
FranjoMindek fec25ab
split payment details funcs
FranjoMindek 05b0fad
add awaits
FranjoMindek 91e2f0d
name
FranjoMindek de70c30
Merge branch 'main' into franjo/refactor-stripe-payment-provider
FranjoMindek 0cbe24c
formatting
FranjoMindek 5dce0da
fix format
FranjoMindek 4d6a64f
update
FranjoMindek 1541759
map to switch
FranjoMindek dddc128
wording
FranjoMindek d7b5f8f
fix typo
FranjoMindek b764193
Merge branch 'main' into franjo/refactor-stripe-payment-provider
FranjoMindek d6a608a
format
FranjoMindek 346da0f
fix diffs?
FranjoMindek 4d9fb58
Merge remote-tracking branch 'origin/main' into franjo/refactor-strip…
FranjoMindek 8371bd4
docs: update LLM files after documentation changes
FranjoMindek e5caba8
comments
FranjoMindek 2e5ea07
wording
FranjoMindek f09865f
wording
FranjoMindek b4f80d3
wording
FranjoMindek 2c82386
Merge branch 'main' into franjo/refactor-stripe-payment-provider
FranjoMindek 34209ae
fix typo
FranjoMindek f288f9b
to 204
FranjoMindek 0bd0b73
Merge remote-tracking branch 'origin/main' into franjo/refactor-strip…
FranjoMindek 375cf1a
Merge remote-tracking branch 'origin/main' into franjo/refactor-strip…
FranjoMindek 4673ec6
update env
FranjoMindek fb0ff94
formatting
FranjoMindek 1adc2d0
Merge branch 'main' into franjo/refactor-stripe-payment-provider
FranjoMindek cd0988e
work
FranjoMindek a86021d
Update opensaas-sh/blog/src/content/docs/guides/deploying.mdx
FranjoMindek 68220cc
Apply suggestion from @infomiho
FranjoMindek ddbe28e
Apply suggestion from @infomiho
FranjoMindek 9a4ea86
link change
FranjoMindek 76b9a32
Merge branch 'franjo/refactor-stripe-payment-provider' of franjo:wasp…
FranjoMindek 5441ffc
rename
FranjoMindek 4088bca
changes
FranjoMindek 2262a2c
capitalize
FranjoMindek 5fab9a3
fix trailing slash bug, formatting
FranjoMindek ae1b458
update diff
FranjoMindek 8b649e0
abstract more user stuff, move to user.ts, fixes
FranjoMindek 17586a7
diff
FranjoMindek 631f237
fix diffs
FranjoMindek b9c8304
env to config
FranjoMindek 221a549
Merge remote-tracking branch 'origin/main' into franjo/refactor-strip…
FranjoMindek 39381df
user import
FranjoMindek 99f01ad
move jsdoc to comment + simplify logic
FranjoMindek 0e17428
simplify
FranjoMindek 6928c60
improve opensaas map
FranjoMindek abb546c
fix comment
FranjoMindek 5f894c0
remove logs
FranjoMindek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| --- template/app/src/payment/paymentProcessor.ts | ||
| +++ opensaas-sh/app/src/payment/paymentProcessor.ts | ||
| @@ -27,9 +27,4 @@ | ||
| @@ -28,9 +28,4 @@ | ||
| webhookMiddlewareConfigFn: MiddlewareConfigFn; | ||
| } | ||
|
|
||
| -/** | ||
| - * Choose which payment processor you'd like to use, then delete the | ||
| - * other payment processor code that you're not using from `/src/payment` | ||
| - */ | ||
| -// export const paymentProcessor: PaymentProcessor = lemonSqueezyPaymentProcessor; | ||
| export const paymentProcessor: PaymentProcessor = stripePaymentProcessor; | ||
| -// export const paymentProcessor: PaymentProcessor = lemonSqueezyPaymentProcessor; |
15 changes: 0 additions & 15 deletions
15
opensaas-sh/app_diff/src/payment/stripe/paymentDetails.ts.diff
This file was deleted.
Oops, something went wrong.
49 changes: 43 additions & 6 deletions
49
opensaas-sh/app_diff/src/payment/stripe/paymentProcessor.ts.diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,48 @@ | ||
| --- template/app/src/payment/stripe/paymentProcessor.ts | ||
| +++ opensaas-sh/app/src/payment/stripe/paymentProcessor.ts | ||
| @@ -32,7 +32,7 @@ | ||
| id: userId, | ||
| }, | ||
| data: { | ||
| @@ -13,8 +13,8 @@ | ||
| } from "./checkoutUtils"; | ||
| import { stripeClient } from "./stripeClient"; | ||
| import { | ||
| - fetchUserPaymentProcessorUserId, | ||
| - updateUserPaymentProcessorUserId, | ||
| + fetchUserStripeId, | ||
| + updateUserStripeId | ||
| } from "./user"; | ||
| import { stripeMiddlewareConfigFn, stripeWebhook } from "./webhook"; | ||
|
|
||
| @@ -28,10 +28,10 @@ | ||
| }: CreateCheckoutSessionArgs) => { | ||
| const customer = await ensureStripeCustomer(userEmail); | ||
|
|
||
| - await updateUserPaymentProcessorUserId( | ||
| + await updateUserStripeId( | ||
| { | ||
| userId, | ||
| - paymentProcessorUserId: customer.id, | ||
| + stripeId: customer.id, | ||
| }, | ||
| }); | ||
| if (!stripeSession.url) | ||
| prismaUserDelegate, | ||
| ); | ||
| @@ -59,18 +59,18 @@ | ||
| prismaUserDelegate, | ||
| userId, | ||
| }: FetchCustomerPortalUrlArgs) => { | ||
| - const paymentProcessorUserId = await fetchUserPaymentProcessorUserId( | ||
| + const stripeId = await fetchUserStripeId( | ||
| userId, | ||
| prismaUserDelegate, | ||
| ); | ||
|
|
||
| - if (!paymentProcessorUserId) { | ||
| + if (!stripeId) { | ||
| return null; | ||
| } | ||
|
|
||
| const billingPortalSession = | ||
| await stripeClient.billingPortal.sessions.create({ | ||
| - customer: paymentProcessorUserId, | ||
| + customer: stripeId, | ||
| return_url: `${config.frontendUrl}/account`, | ||
| }); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- template/app/src/payment/stripe/user.ts | ||
| +++ opensaas-sh/app/src/payment/stripe/user.ts | ||
| @@ -3,7 +3,7 @@ | ||
| import type { SubscriptionStatus } from "../plans"; | ||
| import { PaymentPlanId } from "../plans"; | ||
|
|
||
| -export async function fetchUserPaymentProcessorUserId( | ||
| +export async function fetchUserStripeId( | ||
| userId: User["id"], | ||
| prismaUserDelegate: PrismaClient["user"], | ||
| ): Promise<string | null> { | ||
| @@ -12,20 +12,20 @@ | ||
| id: userId, | ||
| }, | ||
| select: { | ||
| - paymentProcessorUserId: true, | ||
| + stripeId: true, | ||
| }, | ||
| }); | ||
|
|
||
| - return user.paymentProcessorUserId; | ||
| + return user.stripeId; | ||
| } | ||
|
|
||
| -interface UpdateUserPaymentProcessorUserIdArgs { | ||
| +interface UpdateUserStripeIdArgs { | ||
| userId: User["id"]; | ||
| - paymentProcessorUserId: NonNullable<User["paymentProcessorUserId"]>; | ||
| + stripeId: NonNullable<User["stripeId"]>; | ||
| } | ||
|
|
||
| -export function updateUserPaymentProcessorUserId( | ||
| - { userId, paymentProcessorUserId }: UpdateUserPaymentProcessorUserIdArgs, | ||
| +export function updateUserStripeId( | ||
| + { userId, stripeId }: UpdateUserStripeIdArgs, | ||
| prismaUserDelegate: PrismaClient["user"], | ||
| ): Promise<User> { | ||
| return prismaUserDelegate.update({ | ||
| @@ -33,7 +33,7 @@ | ||
| id: userId, | ||
| }, | ||
| data: { | ||
| - paymentProcessorUserId, | ||
| + stripeId | ||
| }, | ||
| }); | ||
| } | ||
| @@ -54,7 +54,7 @@ | ||
| ): Promise<User> { | ||
| return userDelegate.update({ | ||
| where: { | ||
| - paymentProcessorUserId: customerId, | ||
| + stripeId: customerId, | ||
| }, | ||
| data: { | ||
| datePaid, | ||
| @@ -81,7 +81,7 @@ | ||
| ): Promise<User> { | ||
| return userDelegate.update({ | ||
| where: { | ||
| - paymentProcessorUserId: customerId, | ||
| + stripeId: customerId, | ||
| }, | ||
| data: { | ||
| subscriptionPlan: paymentPlanId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
How come we have these changes in this PR?
Should we maybe do a separate PR that only updates the diffs?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yep, this often happens.
We should have a CI workflow for this.
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.
What kind of workflow were you thinking? It is something we should encode in an improvement issue?
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.
A workflow which would check if generating a diff makes changes to the working directory. If it does it fails. Just to make sure your diffs are up to date with your template.