Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(server): wrong invoice recurring value saved (#4712)

liuyi97d06432f00f
diff --git a/packages/backend/server/src/modules/payment/service.ts b/packages/backend/server/src/modules/payment/service.ts
index e724717777..e9e4374b0b 100644
--- a/packages/backend/server/src/modules/payment/service.ts
+++ b/packages/backend/server/src/modules/payment/service.ts
@@ -393,12 +393,18 @@ export class SubscriptionService {
throw new Error('Unexpected invoice with no recurring price');
}
+ if (!price.lookup_key) {
+ throw new Error('Unexpected subscription with no key');
+ }
+
+ const [plan, recurring] = decodeLookupKey(price.lookup_key);
+
await this.db.userInvoice.create({
data: {
userId: user.id,
stripeInvoiceId: stripeInvoice.id,
- plan: SubscriptionPlan.Pro,
- recurring: price.lookup_key ?? price.id,
+ plan,
+ recurring,
reason: stripeInvoice.billing_reason ?? 'contact support',
...(data as any),
},