From d2fec9342a260b6bd36f1af87c112f030dbaeb15 Mon Sep 17 00:00:00 2001 From: Benyam Seifu <45682486+benyam7@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:43:55 +0300 Subject: [PATCH] fix: trigger stripe account creation on sign-in (#559) * create stripe account on sign in * create stripe account on sign in * account submitter --------- Co-authored-by: Ankur Banerjee --- src/controllers/api/account.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/controllers/api/account.ts b/src/controllers/api/account.ts index 46e521bd..34ff3c7e 100644 --- a/src/controllers/api/account.ts +++ b/src/controllers/api/account.ts @@ -244,6 +244,17 @@ export class AccountController { await UserService.instance.update(user.logToId, customer); } else { customer = user.customer; + // this time user exists, so notify stripe account should be created. + if (process.env.STRIPE_ENABLED === 'true' && !customer.paymentProviderId) { + eventTracker.submit({ + operation: OperationNameEnum.STRIPE_ACCOUNT_CREATE, + data: { + name: customer.name, + email: customer.email, + customerId: customer.customerId, + } satisfies ISubmitStripeCustomerCreateData, + } satisfies ISubmitOperation); + } } // 4. Check is paymentAccount exists for the customer