Skip to content

Commit

Permalink
Add support for user plans
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbitron committed Feb 20, 2017
1 parent bba43d3 commit 2c344f8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Console/Commands/CreateStripePlans.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,25 @@ public function handle()
{
Stripe\Stripe::setApiKey(config('services.stripe.secret'));

$plans = Spark::$teamPlans;
$this->info('Creating user plans...');
$this->createStripePlans(Spark::$plans);

$this->info('Creating team plans...');
$this->createStripePlans(Spark::$teamPlans);

$this->info('Finished');
}

/**
* Try and create plans in Stripe
*
* @param array $plans
*/
protected function createStripePlans($plans)
{
foreach ($plans as $plan) {
if ($this->planExists($plan)) {
$this->info('Stripe plan ' . $plan->id . ' already exists');
$this->line('Stripe plan ' . $plan->id . ' already exists');
} else {
Stripe\Plan::create([
'id' => $plan->id,
Expand All @@ -60,8 +75,6 @@ public function handle()
$this->info('Stripe plan created: ' . $plan->id);
}
}

$this->info('Finished');
}

/**
Expand Down

0 comments on commit 2c344f8

Please sign in to comment.