Laravel\Cashier\SubscriptionBuilder::create PHP Method

create() public method

Create a new Braintree subscription.
public create ( string | null $token = null, array $customerOptions = [], array $subscriptionOptions = [] ) : Subscription
$token string | null
$customerOptions array
$subscriptionOptions array
return Subscription
    public function create($token = null, array $customerOptions = [], array $subscriptionOptions = [])
    {
        $payload = $this->getSubscriptionPayload($this->getBraintreeCustomer($token, $customerOptions), $subscriptionOptions);
        if ($this->coupon) {
            $payload = $this->addCouponToPayload($payload);
        }
        $response = BraintreeSubscription::create($payload);
        if (!$response->success) {
            throw new Exception('Braintree failed to create subscription: ' . $response->message);
        }
        if ($this->skipTrial) {
            $trialEndsAt = null;
        } else {
            $trialEndsAt = $this->trialDays ? Carbon::now()->addDays($this->trialDays) : null;
        }
        return $this->user->subscriptions()->create(['name' => $this->name, 'braintree_id' => $response->subscription->id, 'braintree_plan' => $this->plan, 'quantity' => 1, 'trial_ends_at' => $trialEndsAt, 'ends_at' => null]);
    }