Refactor billing code and add error monitoring
Refactored the code that retrieves the billing customer id by renaming the function getBillingCustomerId to getCustomerId. Also, bolstered error handling: implemented exception capture in particular scenarios across multiple files. If an error occurs, it's now captured and reported to the configured provider.
This commit is contained in:
@@ -39,7 +39,7 @@ export const loadPersonalAccountBillingPageData = cache((userId: string) => {
|
||||
? api.getSubscription(userId)
|
||||
: api.getOrder(userId);
|
||||
|
||||
const customerId = api.getBillingCustomerId(userId);
|
||||
const customerId = api.getCustomerId(userId);
|
||||
|
||||
return Promise.all([data, customerId]);
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ class UserBillingService {
|
||||
// find the customer ID for the account if it exists
|
||||
// (eg. if the account has been billed before)
|
||||
const api = createAccountsApi(this.client);
|
||||
const customerId = await api.getBillingCustomerId(accountId);
|
||||
const customerId = await api.getCustomerId(accountId);
|
||||
|
||||
const product = billingConfig.products.find(
|
||||
(item) => item.id === productId,
|
||||
@@ -139,7 +139,7 @@ class UserBillingService {
|
||||
|
||||
const accountId = data.id;
|
||||
const api = createAccountsApi(this.client);
|
||||
const customerId = await api.getBillingCustomerId(accountId);
|
||||
const customerId = await api.getCustomerId(accountId);
|
||||
const returnUrl = getBillingPortalReturnUrl();
|
||||
|
||||
if (!customerId) {
|
||||
|
||||
@@ -31,7 +31,7 @@ export const loadTeamAccountBillingPage = cache((accountId: string) => {
|
||||
? api.getSubscription(accountId)
|
||||
: api.getOrder(accountId);
|
||||
|
||||
const customerId = api.getBillingCustomerId(accountId);
|
||||
const customerId = api.getCustomerId(accountId);
|
||||
|
||||
return Promise.all([data, customerId]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user