-
-
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
30
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 3 commits
Commits
Show all changes
30 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 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
21 changes: 13 additions & 8 deletions
21
opensaas-sh/app_diff/src/payment/stripe/paymentDetails.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,15 +1,20 @@ | ||
--- template/app/src/payment/stripe/paymentDetails.ts | ||
+++ opensaas-sh/app/src/payment/stripe/paymentDetails.ts | ||
@@ -14,10 +14,10 @@ | ||
) => { | ||
@@ -26,7 +26,7 @@ | ||
) { | ||
return userDelegate.update({ | ||
where: { | ||
- paymentProcessorUserId: userStripeId | ||
+ stripeId: userStripeId | ||
- paymentProcessorUserId: customerId, | ||
+ stripeId: customerId, | ||
}, | ||
data: { | ||
- paymentProcessorUserId: userStripeId, | ||
+ stripeId: userStripeId, | ||
subscriptionPlan, | ||
subscriptionStatus, | ||
datePaid, | ||
@@ -48,7 +48,7 @@ | ||
) { | ||
return userDelegate.update({ | ||
where: { | ||
- paymentProcessorUserId: customerId, | ||
+ stripeId: customerId, | ||
}, | ||
data: { | ||
subscriptionPlan: paymentPlanId, |
14 changes: 7 additions & 7 deletions
14
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,11 @@ | ||
--- template/app/src/payment/stripe/paymentProcessor.ts | ||
+++ opensaas-sh/app/src/payment/stripe/paymentProcessor.ts | ||
@@ -20,7 +20,7 @@ | ||
id: userId | ||
@@ -24,7 +24,7 @@ | ||
id: userId, | ||
}, | ||
data: { | ||
- paymentProcessorUserId: customer.id | ||
+ stripeId: customer.id | ||
} | ||
}) | ||
if (!stripeSession.url) throw new Error('Error creating Stripe Checkout Session'); | ||
- paymentProcessorUserId: customer.id, | ||
+ stripeId: customer.id, | ||
}, | ||
}); | ||
|
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
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 |
---|---|---|
|
@@ -14,15 +14,18 @@ export enum PaymentPlanId { | |
} | ||
|
||
export interface PaymentPlan { | ||
// Returns the id under which this payment plan is identified on your payment processor. | ||
// E.g. this might be price id on Stripe, or variant id on LemonSqueezy. | ||
/** | ||
* Returns the id under which this payment plan is identified on your payment processor. | ||
* | ||
* E.g. price id on Stripe, or variant id on LemonSqueezy. | ||
*/ | ||
getPaymentProcessorPlanId: () => string; | ||
effect: PaymentPlanEffect; | ||
} | ||
|
||
export type PaymentPlanEffect = { kind: 'subscription' } | { kind: 'credits'; amount: number }; | ||
|
||
export const paymentPlans: Record<PaymentPlanId, PaymentPlan> = { | ||
export const paymentPlans = { | ||
[PaymentPlanId.Hobby]: { | ||
getPaymentProcessorPlanId: () => requireNodeEnvVar('PAYMENTS_HOBBY_SUBSCRIPTION_PLAN_ID'), | ||
effect: { kind: 'subscription' }, | ||
|
@@ -35,7 +38,7 @@ export const paymentPlans: Record<PaymentPlanId, PaymentPlan> = { | |
getPaymentProcessorPlanId: () => requireNodeEnvVar('PAYMENTS_CREDITS_10_PLAN_ID'), | ||
effect: { kind: 'credits', amount: 10 }, | ||
}, | ||
}; | ||
} as const satisfies Record<PaymentPlanId, PaymentPlan>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allows us to do e.g. |
||
|
||
export function prettyPaymentPlanName(planId: PaymentPlanId): string { | ||
const planToName: Record<PaymentPlanId, string> = { | ||
|
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.
This hasn't been run in a while so more changes pop up.