/** * Subscribe to the plan for the first time. * * @param string $token * @param array $properties * @param object|null $customer * @return void */ public function create($token, array $properties = array(), $customer = null) { $freshCustomer = false; if (!$customer) { $customer = $this->createStripeCustomer($token, $properties); $freshCustomer = true; } elseif (!is_null($token)) { $this->updateCard($token); } $this->billable->setStripeSubscription($customer->updateSubscription($this->buildPayload())->id); $customer = $this->getStripeCustomer($customer->id); if ($freshCustomer && ($trialEnd = $this->getTrialEndForCustomer($customer))) { $this->billable->setTrialEndDate($trialEnd); } $this->updateLocalStripeData($customer); }