fix(server): wrong invoice recurring value saved (#4712)
This commit is contained in:
@@ -393,12 +393,18 @@ export class SubscriptionService {
|
|||||||
throw new Error('Unexpected invoice with no recurring price');
|
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({
|
await this.db.userInvoice.create({
|
||||||
data: {
|
data: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
stripeInvoiceId: stripeInvoice.id,
|
stripeInvoiceId: stripeInvoice.id,
|
||||||
plan: SubscriptionPlan.Pro,
|
plan,
|
||||||
recurring: price.lookup_key ?? price.id,
|
recurring,
|
||||||
reason: stripeInvoice.billing_reason ?? 'contact support',
|
reason: stripeInvoice.billing_reason ?? 'contact support',
|
||||||
...(data as any),
|
...(data as any),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user