public function applyCoupon($coupon, $removeOthers = false)
    {
        if (! $this->active()) {
            throw new InvalidArgumentException('Unable to apply coupon. Subscription not active.');
        }

        BraintreeSubscription::update($this->braintree_id, [
            'discounts' => [
                'add' => [[
                    'inheritedFromId' => $coupon,
                ]],
                'remove' => $removeOthers ? $this->currentDiscounts() : [],
            ],
        ]);
    }
public function applyCoupon($coupon, $removeOthers = false)
    {
        if (! $this->active()) {
            throw new InvalidArgumentException('Unable to apply coupon. Subscription not active.');
        }

        BraintreeSubscription::update($this->braintree_id, [
            'discounts' => [
                'add' => [[
                    'inheritedFromId' => $coupon,
                ]],
                'remove' => $removeOthers ? $this->currentDiscounts() : [],
            ],
        ]);
    }
public function applyCoupon ( $ coupon , $ removeOthers = false ) { if ( ! $ this -> active ( ) ) { throw new InvalidArgumentException ( 'Unable to apply coupon. Subscription not active.' ) ; } BraintreeSubscription :: update ( $ this -> braintree_id , [ 'discounts' => [ 'add' => [ [ 'inheritedFromId' => $ coupon , ] ] , 'remove' => $ removeOthers ? $ this -> currentDiscounts ( ) : [ ] , ] , ] ) ; }
Apply a coupon to the subscription.

@param  string  $coupon
@param  bool  $removeOthers
@return void
Apply a coupon to the subscription .