Create stripe customer for 2 companies in the same time

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

I have 2 different stripe accounts :

# Stripe Keys Account 1
STRIPE_KEY=pk_test_abc
STRIPE_SECRET=sk_test_abc

# Stripe Keys Account 2
STRIPE_KEY_MAPPING=pk_test_opr
STRIPE_SECRET_MAPPING_MASTER=sk_test_opr

I put in an array :

$stripe_accounts = [
  env('STRIPE_SECRET'),
  env('STRIPE_SECRET_MAPPING_MASTER')
];

I want to create customer in both accounts in the same time :

foreach ($stripe_accounts as $item) {
  $stripe = new StripeStripeClient($item);
  $hotel = session('hotel');
  $stripeUser = $hotel->createOrGetStripeCustomer();
  $hotel->updateDefaultPaymentMethodFromStripe();
}

Is not working as expected, because create customer just for Account 1 that have STRIPE_KEY.

Have you an idea about that ?

Source: Laravel

Leave a Reply