Skip to content

Commit

Permalink
added prorate parameter to changing plans on a subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared King committed Apr 8, 2015
1 parent be39db9 commit a95abad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/libs/BillingSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ public function create($token = false, $noTrial = false)
*
* @param string $plan stripe plan id
* @param boolean $noTrial when true, immediately ends (skips) the trial period for the new subscription
* @param boolean $prorate when true, prorates the plan change
*
* @return boolean result
*/
public function change($plan, $noTrial = false)
public function change($plan, $noTrial = false, $prorate = true)
{
if (empty($plan) || !in_array($this->status(), ['active', 'trialing', 'past_due', 'unpaid'])
|| $this->model->not_charged) {
Expand All @@ -112,7 +113,7 @@ public function change($plan, $noTrial = false)

$params = [
'plan' => $plan,
'prorate' => true,
'prorate' => $prorate,
];

// maintain the same trial end date if there is one
Expand Down
4 changes: 2 additions & 2 deletions tests/BillingSubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function testChange()
$customer = Mockery::mock('StripeCustomer');
$customer->shouldReceive('updateSubscription')->withArgs([[
'plan' => 'blah',
'prorate' => true,
'prorate' => false,
'trial_end' => $trialEnds, ]])
->andReturn($resultSub)->once();

Expand All @@ -271,7 +271,7 @@ public function testChange()

$subscription = new BillingSubscription($testModel, 'test', TestBootstrap::app());

$this->assertTrue($subscription->change('blah'));
$this->assertTrue($subscription->change('blah', false, false));
$this->assertEquals('blah', $subscription->plan());
}

Expand Down

0 comments on commit a95abad

Please sign in to comment.