fix payments

This commit is contained in:
Emily
2024-06-11 23:01:54 +02:00
parent 7460ad5ed4
commit b7c3ef19ba
8 changed files with 101 additions and 124 deletions

View File

@@ -5,11 +5,13 @@ class StripeService {
private stripe?: Stripe;
private privateKey?: string;
private webhookSecret?: string;
public testMode?: boolean;
init(privateKey: string, webhookSecret: string) {
init(privateKey: string, webhookSecret: string, testMode: boolean = false) {
this.privateKey = privateKey;
this.webhookSecret = webhookSecret;
this.stripe = new Stripe(this.privateKey);
this.testMode = testMode;
}
parseWebhook(body: any, sig: string) {
@@ -87,7 +89,7 @@ class StripeService {
const subscription = await this.stripe.subscriptions.create({
customer: customer_id,
items: [
{ price: FREE_PLAN.PRICE, quantity: 1 }
{ price: this.testMode ? FREE_PLAN.PRICE_TEST : FREE_PLAN.PRICE, quantity: 1 }
]
});