title: Stripe API subscriptions
body: <p>I'm having a bit of a hard time updating a subscription with a new plan.
  What I'm trying to do is the following:</p>
  
  <p>Check if the subscription is still in trial mode. Get trial_end timestamp</p>
  
  <ol>
  <li><p>If trial_end has not happened yet. Create new plan. Subscribe customer to new plan. Do not prorate anything. Carry the trial_end for the new plan. (In other words, don't charge the customer until after the trial period ends.)</p></li>
  <li><p>If trial_end has already passed, create new plan, Sub customer to the new plan. Prorate the new plan. Carry the next billing date. (Meaning, again, don't charge the customer right now but add the prorated amount to the next invoice)</p></li>
  </ol>
  
  <p>Here's the code I have so far:</p>
  
  <pre><code>//CREATE NEW PLAN
  $plan = \Stripe\Plan::create(array(
        "id" =&gt; $usremail.'_'.time(),
        "name" =&gt; $usremail.'-'.time(),
        "currency" =&gt; "usd",
        "amount" =&gt; $totalamount,
        "interval" =&gt; "month",
      ));
  
  $planid = $plan-&gt;id;
  $proration_date = time();
  
  //UPDATE SUBSCRIPTION
  $subscription = \Stripe\Subscription::retrieve($subid);
  $subscription-&gt;plan = $planid;
  $subscription-&gt;proration_date = $proration_date;
  $subscription-&gt;save();
  </code></pre>
  
  <p>When I do it this way, if the customer is in a trial subscription and signs up for a new plan, the subscription becomes active and the customer is charged right away the amount of the new plan.</p>
  
  <p>I'm sure it is an easy thing, just can't figure it out.
  Any help is greatly appreciated.</p>
  
  <p>T</p>