feat(core): impl billing settings (#4652)

This commit is contained in:
liuyi
2023-10-20 09:42:33 +08:00
committed by forehalo
parent 1d62133f4f
commit 858a1da35f
16 changed files with 480 additions and 27 deletions

View File

@@ -117,6 +117,9 @@ class UserInvoiceType implements Partial<UserInvoice> {
@Field(() => String, { nullable: true })
lastPaymentError?: string | null;
@Field(() => String, { nullable: true })
link?: string | null;
@Field(() => Date)
createdAt!: Date;
@@ -183,6 +186,13 @@ export class SubscriptionResolver {
return session.url;
}
@Mutation(() => String, {
description: 'Create a stripe customer portal to manage payment methods',
})
async createCustomerPortal(@CurrentUser() user: User) {
return this.service.createCustomerPortal(user.id);
}
@Mutation(() => UserSubscriptionType)
async cancelSubscription(@CurrentUser() user: User) {
return this.service.cancelSubscription(user.id);