Skip to content

Instantly share code, notes, and snippets.

@Brotzka
Last active March 2, 2019 21:09
Show Gist options
  • Save Brotzka/c07282bdc68659d63b55cb014946b6bc to your computer and use it in GitHub Desktop.
Save Brotzka/c07282bdc68659d63b55cb014946b6bc to your computer and use it in GitHub Desktop.
Stripe Shared Customer problems with payment method sepa_debit
// Get Customer Details from local subscription (with Payment-Data from Stripe-Elements)
$localSubscription = Subscription::findOrFail($this->argument('subscriptionId'));
$localVehicleProduct = $localSubscription->vehicle;
$localCustomer = $localSubscription->consumer;
$localProducer = $localSubscription->producer;
$stripePlatformSource = $localSubscription->getDetail('stripe_payment_source');
$this->info("Platform-Stripe-Source: {$stripePlatformSource}");
// Start Communication with Stripe-API
Stripe::setApiKey(config('services.stripe.secret'));
// Create/retrieve custom account
$stripeConnectedAccount = Account::retrieve("acct_1E9ePKFcSjiaodu2");
$this->info("Connected-Account: {$stripeConnectedAccount->id}");
// Create/retrieve Product on/from Connected Account
$stripeProduct = Product::retrieve('prod_EcuLCnmLovcKVk', ["stripe_account" => $stripeConnectedAccount->id]);
$this->info("Stripe-Product: {$stripeProduct->id}");
// Create/retrieve Plan on Connected Account
$stripePlan = Plan::retrieve('plan_EcuV7wgFGHpEkn', ["stripe_account" => $stripeConnectedAccount->id]);
$this->info("Stripe-Plan: {$stripePlan->id}");
// Create/retrieve Customer on/from platform-account
$stripePlatformCustomer = Customer::retrieve('cus_EcuaTfeS4POkKN');
$this->info("Stripe Platform Customer: {$stripePlatformCustomer->id}");
// Create Stripe Token to transfer customer from platform to connected account
$stripeToken = Token::create([
"customer" => $stripePlatformCustomer->id
],["stripe_account" => $stripeConnectedAccount->id]);
$this->info("Stripe-Token: {$stripeToken}");
// Get Customer Details from local subscription (with Payment-Data from Stripe-Elements)
$localSubscription = Subscription::findOrFail($this->argument('subscriptionId'));
$localVehicleProduct = $localSubscription->vehicle;
$localCustomer = $localSubscription->consumer;
$localProducer = $localSubscription->producer;
$stripePlatformSource = $localSubscription->getDetail('stripe_payment_source');
$this->info("Platform-Stripe-Source: {$stripePlatformSource}");
// Start Communication with Stripe-API
Stripe::setApiKey(config('services.stripe.secret'));
// Create/retrieve custom account
$stripeConnectedAccount = Account::retrieve("acct_1E9ePKFcSjiaodu2");
$this->info("Connected-Account: {$stripeConnectedAccount->id}");
// Create/retrieve Product on/from Connected Account
$stripeProduct = Product::retrieve('prod_EcuLCnmLovcKVk', ["stripe_account" => $stripeConnectedAccount->id]);
$this->info("Stripe-Product: {$stripeProduct->id}");
// Create/retrieve Plan on Connected Account
$stripePlan = Plan::retrieve('plan_EcuV7wgFGHpEkn', ["stripe_account" => $stripeConnectedAccount->id]);
$this->info("Stripe-Plan: {$stripePlan->id}");
// Create/retrieve Customer on/from platform-account
$stripePlatformCustomer = Customer::retrieve('cus_EcuaTfeS4POkKN');
$this->info("Stripe Platform Customer: {$stripePlatformCustomer->id}");
// Create Stripe Token to transfer customer from platform to connected account
$stripeToken = Source::create(
[
"customer" => $stripePlatformCustomer->id,
"original_source" => $stripePlatformSource,
"usage" => "reusable",
],
["stripe_account" => $stripeConnectedAccount->id]);
$this->info("Stripe-Token: {$stripeToken}");
/*
$token = \Stripe\Source::create([
"customer" => "cus_AFGbOSiITuJVDs",
"original_source" => "src_19YP2AAHEMiOZZp1Di4rt1K6",
"usage" => "reusable",
], ["stripe_account" => "{CONNECTED_STRIPE_ACCOUNT_ID}"]);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment