Optimize code for accounts and roles management

The large update includes optimization for account and role management. The code has been revised for better readability and efficiency. Changes include formatting updates and enhancements to the creation and handling of accounts, roles, and memberships. Privacy settings have also been adjusted to provide more secure handling of user data. Code comments have been updated for better understanding of the functions.
This commit is contained in:
giancarlo
2024-04-28 12:55:01 +07:00
parent 2382d6485c
commit 3efbf6029f
6 changed files with 1023 additions and 647 deletions

View File

@@ -19,6 +19,12 @@ import { createStripeBillingPortalSession } from './create-stripe-billing-portal
import { createStripeCheckout } from './create-stripe-checkout';
import { createStripeClient } from './stripe-sdk';
/**
* @name StripeBillingStrategyService
* @description The Stripe billing strategy service
* @class StripeBillingStrategyService
* @implements {BillingStrategyProviderService}
*/
export class StripeBillingStrategyService
implements BillingStrategyProviderService
{

View File

@@ -30,6 +30,7 @@ export class StripeWebhookHandlerService
private readonly namespace = 'billing.stripe';
/**
* @name verifyWebhookSignature
* @description Verifies the webhook signature - should throw an error if the signature is invalid
*/
async verifyWebhookSignature(request: Request) {
@@ -57,14 +58,6 @@ export class StripeWebhookHandlerService
return event;
}
private async loadStripe() {
if (!this.stripe) {
this.stripe = await createStripeClient();
}
return this.stripe;
}
async handleWebhookEvent(
event: Stripe.Event,
params: {
@@ -354,6 +347,14 @@ export class StripeWebhookHandlerService
return onInvoicePaid(payload);
}
private async loadStripe() {
if (!this.stripe) {
this.stripe = await createStripeClient();
}
return this.stripe;
}
}
function getISOString(date: number | null) {