Disables the discount component after payment step.

@param array $jsLayout
@return array
161323
private function disableDiscountComponent($jsLayout)
    {
        if ($this->scopeConfig->getValue(self::CONFIG_DISABLE_DISCOUNT_PATH, ScopeInterface::SCOPE_STORE)) {
            unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
                ['payment']['children']['afterMethods']['children']['discount']);
        }
        return $jsLayout;
    }
500146
public function renderSlide($isFirst = false, $isMiddle = false, $isLast = false)
    {
        return $this->customise([
            'isFirst' => $isFirst,
            'isMiddle' => $isMiddle,
            'isLast' => $isLast
        ])->renderWith($this->getTemplate());
    }
208964
public function ignoreJs($aliasOrUrl)
    {
        if (is_array($aliasOrUrl)) {
            foreach ($aliasOrUrl as $item) {
                $this->ignoreJs($item);
            }
            return $this;
        }
        $url = $this->getJsUrl($aliasOrUrl);
        if (!$this->included->isIncluded($url)) {
            $this->included->markAsIncluded($url);
        }
        return $this;
    }
85609
function (discount, cb) {

		Discount.destroy(discount.id)
	    .exec(function (err, destroyedDiscounts){
	      if (err) return cb(err);
	      if (!destroyedDiscounts) return cb(null, null);
	      Discount.afterStripeCustomerDiscountDeleted(destroyedDiscounts[0], function(err, discount){
	      	cb(err, discount);
	      });
	    });
	}
745841
public function usediscount()
    {
        $this->extend("onBeforeUseDiscount");

        $code_to_search = $this->request->param("ID");
        $code = false;

        if (!$code_to_search) {
            return $this->httpError(404, "Page not found");
        }

        // First check if the discount is already added (so we don't
        // query the DB if we don't have to).
        if (!$this->discount || ($this->discount && $this->discount->Code != $code_to_search)) {
            $codes = Discount::get()
                ->filter("Code", $code_to_search)
                ->exclude("Expires:LessThan", date("Y-m-d"));

            if ($codes->exists()) {
                $code = $codes->first();
                $this->discount = $code;
                $this->save();
            }
        } elseif ($this->discount && $this->discount->Code == $code_to_search) {
            $code = $this->discount;
        }

        return $this
            ->customise(array(
                "Discount" => $code
            ))->renderWith(array(
                'ShoppingCart_discount',
                'Checkout',
                'Page'
            ));
    }
224540
public function decrement($byAmount = 1) {
		if ($this->name === null) {
			throw new InvalidConfigException(get_class($this)." requires a name!");
		}
		return $this->_value = (int) $this->getConnection()->getClient()->decrBy($this->name,$byAmount);
	}
955105
public function payment($cart, $partialPaymentMethod = null)
    {
        $currency = new \Currency($cart->id_currency);

        $sumInCentsIncVat = (float)$cart->getOrderTotal(true, \Cart::BOTH) * 100;
        $sumInCentsExcVat = (float)$cart->getOrderTotal(false, \Cart::BOTH) * 100;

        $vatInCents = $sumInCentsIncVat - $sumInCentsExcVat;

        $referenceId = (string)$cart->id . "_" . \Tools::passwdGen();

        // Terms of Services
        $tosUrl = "https://payapi.io/terms";

        // Assume the schema will take care of empty/null payment method
        $order = array( 'sumInCentsIncVat' => $sumInCentsIncVat,
            'sumInCentsExcVat' => $sumInCentsExcVat,
            'vatInCents' => $vatInCents,
            'currency' => $currency->iso_code,
            'referenceId' => $referenceId,
            'tosUrl' => $tosUrl,
        );
        if ($partialPaymentMethod) {
            $order = array_merge($order, array('preselectedPartialPayment' => $partialPaymentMethod));
        }

        $products_array = array();
        foreach ($cart->getProducts() as $product) {
            // Price calculations
            $prodPriceInCentsExcVat = round($product['price'] * 100);
            $prodPriceInCentsIncVat = round($product['price_with_reduction'] * 100);
            $prodVatInCents = $prodPriceInCentsIncVat - $prodPriceInCentsExcVat;
            $prodVatPercentage = round($prodVatInCents / $prodPriceInCentsExcVat * 100);

            //error_log("attributes: ".$product['attributes'], 0);
            if (array_key_exists('attributes', $product)) {
                $name_with_attributes = $product['name']." ".$product['attributes'];
            } else {
                $name_with_attributes = $product['name'];
            }

            $productObject = array(
                'id' => $product['id_product'],
                'quantity' => $product['quantity'],
                'title' => $name_with_attributes,
                'description' => $product['description_short'],
                'category' => $product['category'],
                'priceInCentsIncVat' => $prodPriceInCentsIncVat,
                'priceInCentsExcVat' => $prodPriceInCentsExcVat,
                'vatInCents' => $prodVatInCents,
                'vatPercentage' => $prodVatPercentage,
            );
            //-> florin added 20180418
            if (isset($cart->gallery) === true && isset($cart->gallery[$product['id_product']]['imageUrl']) === true) {
                $productObject['imageUrl'] = $cart->gallery[$product['id_product']]['imageUrl'];
                $this->debug('[product][image] ' . $productObject['imageUrl']);
            }
            array_push($products_array, $productObject);
        }

        //-> discount with/taxes (true)
        $discount = (float)$cart->getOrderTotal(true, \Cart::ONLY_DISCOUNTS);
        if ($discount > 0) {
            $discounted = (int)(0 - round(($discount * 100), 2));
            $discountedExcTaxes = (int)(0 - round(($cart->getOrderTotal(false, \Cart::ONLY_DISCOUNTS) * 100), 2));
            $discountVatInCents = -($discounted - $discountedExcTaxes);
            $discountVatPercentage = -(round($discountVatInCents / $discountedExcTaxes * 100));
            $productDiscount = array(
                'id' => '0',
                'quantity' => 1,
                'title' => 'Discount',
                'description' => 'Discount',
                'category' => 'discount', //-> handled by category
                'priceInCentsIncVat' => $discounted,
                'priceInCentsExcVat' => $discountedExcTaxes,
                'vatInCents' => -$discountVatInCents,
                'vatPercentage' => $discountVatPercentage,
            );
            array_push($products_array, $productDiscount);
        }

        $shipping_cost = (float)$cart->getOrderTotal(true, \Cart::ONLY_SHIPPING) * 100;
        $shipping_cost_no_tax = (float)$cart->getOrderTotal(false, \Cart::ONLY_SHIPPING) * 100;
        // Add shipping cost as a last product
        $shippingObject = array(
            //-> @FIXED 201804031322 florin (added string to shipping ID)
            //   *NOTE @FIXME (using shipping method ID means could get duplicated 'product' ID)
            'id' => (string) $cart->id_carrier,
            //->
            'quantity' => 1,
            'title' => "Shipping cost",
            'description' => "",
            'category' => "shipping",
            'priceInCentsIncVat' => $shipping_cost,
            'priceInCentsExcVat' => $shipping_cost_no_tax,
            'vatInCents' => 0,
            'vatPercentage' => 0,
        );
        array_push($products_array, $shippingObject);

        // Get shipping address info.
        $shipping_address = null;
        // In case when user is not registered we will not send shipping address
        if ((int)$cart->id_address_delivery) {
            $address = new \Address((int)$cart->id_address_delivery);

            $customer = new \Customer((int)$address->id_customer);

            $country = new \Country((int)$address->id_country);

            $shipping_address = array(
                'recipientName' => $customer->firstname." ".$customer->lastname,
                'co' => $address->company,
                'streetAddress' => $address->address1,
                'streetAddress2' => $address->address2,
                'postalCode' => $address->postcode,
                'city' => $address->city,
                'countryCode' => $country->iso_code,
            );
        }

        $shop_url = \Tools::getHttpHost(true).__PS_BASE_URI__;

        $returnUrls = array(
            'success' => $shop_url.'index.php?payapireturn=success',
            'cancel' => $shop_url.'index.php?payapireturn=cancel',
            'failed' => $shop_url.'index.php?payapireturn=failed',
        );

        $callbacks = array(
            'processing' => $shop_url.'index.php?fc=module&module=payapi&controller=callback',
            'success' => $shop_url.'index.php?fc=module&module=payapi&controller=callback',
            'failed' => $shop_url.'index.php?fc=module&module=payapi&controller=callback',
            'chargeback' => $shop_url.'index.php?fc=module&module=payapi&controller=callback',
        );

        $secureformObject = array();
        if ($shipping_address) {
            $secureformObject = array(
                'order' => $order,
                'products' => $products_array,
                'shippingAddress' => $shipping_address,
                'callbacks' => $callbacks,
                'returnUrls' => $returnUrls
            );
        } else {
            $secureformObject = array(
                'order' => $order,
                'products' => $products_array,
                'callbacks' => $callbacks,
                'returnUrls' => $returnUrls
            );
        }
        $this->debug('[cart][payment] ' . json_encode($secureformObject));
        return $secureformObject;
    }
945681
protected function _fillOutTaxDiscount(ITaxDiscount $discountPayload, array $discountData)
    {
        return $discountPayload
            ->setAmount($this->_nullCoalesce($discountData, 'amount', null))
            ->setId($this->_nullCoalesce($discountData, 'id', null));
    }
649083
public static function ignoreTransaction()
    {
        if (self::$mode !== self::MODE_DISABLED) {
            self::$mode = self::MODE_DISABLED;

            if (self::$extension === self::EXTENSION_XHPROF) {
                xhprof_disable();
            } else if (self::$extension === self::EXTENSION_TIDEWAYS) {
                tideways_disable();
            }
        }
    }
146007
protected function disableDefaultCurrency()
    {
        $obCurrencyList = Currency::isDefault()->get();
        if ($obCurrencyList->isEmpty()) {
            return;
        }

        /** @var Currency $obCurrency */
        foreach ($obCurrencyList as $obCurrency) {
            if ($obCurrency->id == $this->id) {
                continue;
            }

            $obCurrency->is_default = false;
            $obCurrency->save();
        }
    }
716619
public function getCost($withDiscount = true)
    {
        /** @var Component|CartPositionInterface|self $this */
        $cost = $this->getQuantity() * $this->getPrice();
        $costEvent = new CostCalculationEvent([
            'baseCost' => $cost,
        ]);
        if ($this instanceof Component)
            $this->trigger(CartPositionInterface::EVENT_COST_CALCULATION, $costEvent);
        if ($withDiscount)
            $cost = max(0, $cost - $costEvent->discountValue);
        return $cost;
    }
402131
protected function getDiscountForSwitchToYearly()
    {
        $amount = 0;

        foreach ($this->asBraintreeSubscription()->discounts as $discount) {
            if ($discount->id == 'plan-credit') {
                $amount += (float) $discount->amount * $discount->numberOfBillingCycles;
            }
        }

        return (object) [
            'amount' => $amount,
            'numberOfBillingCycles' => 1,
        ];
    }
335969
public function saveorder()
	{
		JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

		JLog::add('CategoriesControllerCategories::saveorder() is deprecated. Function will be removed in 4.0', JLog::WARNING, 'deprecated');

		// Get the arrays from the Request
		$order = $this->input->post->get('order', null, 'array');
		$originalOrder = explode(',', $this->input->getString('original_order_values'));

		// Make sure something has changed
		if (!($order === $originalOrder))
		{
			parent::saveorder();
		}
		else
		{
			// Nothing to reorder
			$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));

			return true;
		}
	}
622870
public function postSelectPaymentHook(TdbShop $oShop, TShopBasket $oBasket, TdbDataExtranetUser $oUser, $sMessageConsumer)
    {
        return $this->GetFieldShopPaymentHandler()->PostSelectPaymentHook($sMessageConsumer);
    }
1355013
public function cancelRedirectAction(Request $request)
    {
        $orderReference = $request->query->get('orderReference');
        $urlHmac = $request->query->get('sig');

        if ($orderReference) {
            $cancelRedirectTransfer = new PayoneCancelRedirectTransfer();
            $cancelRedirectTransfer->setOrderReference($orderReference);
            $cancelRedirectTransfer->setUrlHmac($urlHmac);

            $response = $this->getClient()->cancelRedirect($cancelRedirectTransfer);
        }

        return $this->redirectResponseInternal(PayoneControllerProvider::CHECKOUT_PAYMENT);
    }
404118
public function disableLevel($aDisableRenderLevel) 
	{
	    foreach ($aDisableRenderLevel as $iKey => $bRenderLevel) {

	        self::$_aDisableRenderLevel[$iKey] = $bRenderLevel;
	    }
	    
		return $this;
	}
509947
function disableServiceAnnounces($disable = true, $multicall = false)
    {
        if (!is_bool($disable)) {
            throw new InvalidArgumentException('disable = ' . print_r($disable, true));
        }

        return $this->execute(ucfirst(__FUNCTION__), array($disable), $multicall);
    }