/** * Save the current subscription with the given parameters. * * @param array $params * @return \Stripe\Subscription */ protected function saveSubscription($params) { foreach ($params as $key => $value) { $this->subscription->{$key} = $value; } $this->subscription->save(); return $this->subscription; }
/** * Update a subscription. * * @param array $properties * * @return Subscription */ public function update(array $properties = array()) { $this->info(); if (!empty($properties['plan'])) { $this->stripe_subscription->plan = $properties['plan']; } if (!empty($properties['quantity'])) { $this->stripe_subscription->quantity = $properties['quantity']; } if (!empty($properties['trial_ends_at'])) { if (strtotime($properties['trial_ends_at']) <= time()) { $this->stripe_subscription->trial_end = 'now'; } else { $this->stripe_subscription->trial_end = strtotime($properties['trial_ends_at']); } } if (isset($properties['prorate'])) { $this->stripe_subscription->prorate = $properties['prorate']; } if (!empty($properties['coupon'])) { $this->stripe_subscription->coupon = $properties['coupon']; } if (!empty($properties['card_token'])) { $this->stripe_subscription->source = $properties['card_token']; } else { if (!empty($properties['source'])) { $this->stripe_subscription->source = $properties['source']; } } $this->stripe_subscription->save(); $this->stripe_subscription = null; return $this; }