Skip to content

Commit

Permalink
feat(payments): send country and companyVatId to create a customer
Browse files Browse the repository at this point in the history
  • Loading branch information
xabg2 committed Aug 29, 2024
1 parent aa4873d commit 0f80cbe
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/drive/payments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,13 @@ export class Payments {
this.apiSecurity = apiSecurity;
}

private createCustomer(name: string, email: string): Promise<{ customerId: string; token: string }> {
return this.client.post('/create-customer', { name, email }, this.headers());
}

public getCustomerId(name: string, email: string): Promise<{ customerId: string; token: string }> {
const query = new URLSearchParams();
query.set('email', email);
return this.client
.get<{ customerId: string; token: string }>(`/get-customer-id?${query.toString()}`, this.headers())
.catch((err) => {
const error = err as AppError;
if (error.status === 404) {
return this.createCustomer(name, email);
} else {
throw error;
}
});
public createCustomer(
name: string,
email: string,
country?: string,
companyVatId?: string,
): Promise<{ customerId: string; token: string }> {
return this.client.post('/create-customer', { name, email, country, companyVatId }, this.headers());
}

public createSubscription(
Expand Down

0 comments on commit 0f80cbe

Please sign in to comment.