Laravel\Cashier\Subscription::getDiscountForSwitchToYearly PHP Method

getDiscountForSwitchToYearly() protected method

Get the discount to apply when switching to a yearly plan.
protected getDiscountForSwitchToYearly ( ) : object
return object
    protected function getDiscountForSwitchToYearly()
    {
        $amount = 0;
        foreach ($this->asBraintreeSubscription()->discounts as $discount) {
            if ($discount->id == 'plan-credit') {
                $amount += (double) $discount->amount * $discount->numberOfBillingCycles;
            }
        }
        return (object) ['amount' => $amount, 'numberOfBillingCycles' => 1];
    }