fix: Listen to payment webhooks

This commit is contained in:
Ahmed Bouhuolia
2024-08-24 18:50:12 +02:00
parent bf66b31679
commit 278d61ce61
10 changed files with 221 additions and 22 deletions

View File

@@ -3,6 +3,10 @@ import SystemModel from '@/system/models/SystemModel';
import { PlanSubscription } from '..';
export default class Plan extends mixin(SystemModel) {
price: number;
invoiceInternal: number;
invoicePeriod: string;
/**
* Table name.
*/

View File

@@ -198,14 +198,16 @@ export default class Tenant extends BaseModel {
planId,
invoiceInterval,
invoicePeriod,
subscriptionSlug
subscriptionSlug,
payload?,
) {
return Tenant.newSubscription(
this.id,
planId,
invoiceInterval,
invoicePeriod,
subscriptionSlug
subscriptionSlug,
payload
);
}
@@ -217,7 +219,8 @@ export default class Tenant extends BaseModel {
planId: number,
invoiceInterval: 'month' | 'year',
invoicePeriod: number,
subscriptionSlug: string
subscriptionSlug: string,
payload?: { lemonSqueezyId: string }
) {
const period = new SubscriptionPeriod(invoiceInterval, invoicePeriod);
@@ -227,6 +230,7 @@ export default class Tenant extends BaseModel {
planId,
startsAt: period.getStartDate(),
endsAt: period.getEndDate(),
lemonSubscriptionId: payload?.lemonSqueezyId || null,
});
}
}