From 0f80cbe2f10be8e6c308ebc4d8b13760f7915527 Mon Sep 17 00:00:00 2001 From: Xavier Abad <77491413+masterprog-cmd@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:34:00 +0200 Subject: [PATCH] feat(payments): send country and companyVatId to create a customer --- src/drive/payments/index.ts | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/drive/payments/index.ts b/src/drive/payments/index.ts index 1e8308a..d5b101a 100644 --- a/src/drive/payments/index.ts +++ b/src/drive/payments/index.ts @@ -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(