protected function addDiscount(array $params, array $options)
    {
        $discount = (int) Arr::get($options, 'discount');

        if ($discount > 0) {
            $itemsTotal = $params['transactions'][0]['amount']['details']['subtotal'] * 100;
            $shipping = Arr::get($options, 'shipping_address', []);
            $shipping = Arr::get($shipping, 'price');

            $discountType = Arr::get($options, 'discount_type');
            if ($discountType === 'shipping' && $shipping > 0) {
                $shipping -= $discount;
                if ($shipping < 0) {
                    $itemsTotal += $shipping;
                    $shipping = 0;
                }
                $params['transactions'][0]['amount']['details']['shipping'] = $this->gateway->amount($shipping);
            } else {
                $itemsTotal -= $discount;
            }

            $params['transactions'][0]['amount']['details']['subtotal'] = $this->gateway->amount($itemsTotal);

            $params['transactions'][0]['item_list']['items'][] = [
                'name'        => Arr::get($options, 'discount_concept', 'Discount'),
                'description' => $options['discount_type'],
                'price'       => '-'.$this->gateway->amount($discount),
                'currency'    => Arr::get($options, 'currency', $this->gateway->getCurrency()),
                'sku'         => Arr::get($options, 'discount_code'),
                'quantity'    => 1,
            ];
        }

        return $params;
    }
protected function addDiscount(array $params, array $options)
    {
        $discount = (int) Arr::get($options, 'discount');

        if ($discount > 0) {
            $itemsTotal = $params['transactions'][0]['amount']['details']['subtotal'] * 100;
            $shipping = Arr::get($options, 'shipping_address', []);
            $shipping = Arr::get($shipping, 'price');

            $discountType = Arr::get($options, 'discount_type');
            if ($discountType === 'shipping' && $shipping > 0) {
                $shipping -= $discount;
                if ($shipping < 0) {
                    $itemsTotal += $shipping;
                    $shipping = 0;
                }
                $params['transactions'][0]['amount']['details']['shipping'] = $this->gateway->amount($shipping);
            } else {
                $itemsTotal -= $discount;
            }

            $params['transactions'][0]['amount']['details']['subtotal'] = $this->gateway->amount($itemsTotal);

            $params['transactions'][0]['item_list']['items'][] = [
                'name'        => Arr::get($options, 'discount_concept', 'Discount'),
                'description' => $options['discount_type'],
                'price'       => '-'.$this->gateway->amount($discount),
                'currency'    => Arr::get($options, 'currency', $this->gateway->getCurrency()),
                'sku'         => Arr::get($options, 'discount_code'),
                'quantity'    => 1,
            ];
        }

        return $params;
    }
protected function addDiscount ( array $ params , array $ options ) { $ discount = ( int ) Arr :: get ( $ options , 'discount' ) ; if ( $ discount > 0 ) { $ itemsTotal = $ params [ 'transactions' ] [ 0 ] [ 'amount' ] [ 'details' ] [ 'subtotal' ] * 100 ; $ shipping = Arr :: get ( $ options , 'shipping_address' , [ ] ) ; $ shipping = Arr :: get ( $ shipping , 'price' ) ; $ discountType = Arr :: get ( $ options , 'discount_type' ) ; if ( $ discountType === 'shipping' && $ shipping > 0 ) { $ shipping -= $ discount ; if ( $ shipping < 0 ) { $ itemsTotal += $ shipping ; $ shipping = 0 ; } $ params [ 'transactions' ] [ 0 ] [ 'amount' ] [ 'details' ] [ 'shipping' ] = $ this -> gateway -> amount ( $ shipping ) ; } else { $ itemsTotal -= $ discount ; } $ params [ 'transactions' ] [ 0 ] [ 'amount' ] [ 'details' ] [ 'subtotal' ] = $ this -> gateway -> amount ( $ itemsTotal ) ; $ params [ 'transactions' ] [ 0 ] [ 'item_list' ] [ 'items' ] [ ] = [ 'name' => Arr :: get ( $ options , 'discount_concept' , 'Discount' ) , 'description' => $ options [ 'discount_type' ] , 'price' => '-' . $ this -> gateway -> amount ( $ discount ) , 'currency' => Arr :: get ( $ options , 'currency' , $ this -> gateway -> getCurrency ( ) ) , 'sku' => Arr :: get ( $ options , 'discount_code' ) , 'quantity' => 1 , ] ; } return $ params ; }
Add discount params.

@param string[] $params
@param string[] $options

@return array
Add discount params .