public function cancel()
    {
        $subscription = $this->asStripeSubscription();

        $subscription->cancel_at_period_end = true;

        $subscription->save();

        // If the user was on trial, we will set the grace period to end when the trial
        // would have ended. Otherwise, we'll retrieve the end of the billing period
        // period and make that the end of the grace period for this current user.
        if ($this->onTrial()) {
            $this->ends_at = $this->trial_ends_at;
        } else {
            $this->ends_at = Carbon::createFromTimestamp(
                $subscription->current_period_end
            );
        }

        $this->save();

        return $this;
    }
public function cancel()
    {
        $subscription = $this->asStripeSubscription();

        $subscription->cancel_at_period_end = true;

        $subscription->save();

        // If the user was on trial, we will set the grace period to end when the trial
        // would have ended. Otherwise, we'll retrieve the end of the billing period
        // period and make that the end of the grace period for this current user.
        if ($this->onTrial()) {
            $this->ends_at = $this->trial_ends_at;
        } else {
            $this->ends_at = Carbon::createFromTimestamp(
                $subscription->current_period_end
            );
        }

        $this->save();

        return $this;
    }
public function cancel ( ) { $ subscription = $ this -> asStripeSubscription ( ) ; $ subscription -> cancel_at_period_end = true ; $ subscription -> save ( ) ; // If the user was on trial, we will set the grace period to end when the trial // would have ended. Otherwise, we'll retrieve the end of the billing period // period and make that the end of the grace period for this current user. if ( $ this -> onTrial ( ) ) { $ this -> ends_at = $ this -> trial_ends_at ; } else { $ this -> ends_at = Carbon :: createFromTimestamp ( $ subscription -> current_period_end ) ; } $ this -> save ( ) ; return $ this ; }
Cancel the subscription at the end of the billing period.

@return $this
Cancel the subscription at the end of the billing period .