Create or get stripe customer in 2 differents stripe accounts

  laravel, laravel-8, laravel-cashier, php, stripe-payments

I have 2 stripe account :

# Stripe API Keys
STRIPE_KEY=pk_test_abc
STRIPE_SECRET=sk_test_abc
STRIPE_KEY_MAPPING=pk_test_opr
STRIPE_SECRET_MAPPING_MASTER=sk_test_opr

I put both in an array :

'stripe_accounts'           => [
    env('STRIPE_SECRET'),
    env('STRIPE_SECRET_MAPPING_MASTER')
]

Now I want to create user in both accounts :

foreach ($stripe_accounts as $item) {
  Stripe::setApiKey($item);
  $hotel = session('hotel');
  $stripeUser = $hotel->createOrGetStripeCustomer();
  $hotel->updateDefaultPaymentMethodFromStripe();
}

I have no errors, but when I check stripe dashboard for this account : STRIPE_KEY_MAPPING I don’t see any test data. Have you an idea how I can made this flow ? Create same stripe customer in both differents account. Thx in advance.

Source: Laravel

Leave a Reply