@param Money|null $unitPrice

@return OrderLineInterface
341653
public function setUnitPrice(Money $unitPrice = null)
    {
        $this->unitPrice = $unitPrice ? $unitPrice->getAmount() : $unitPrice;

        return $this;
    }
787097
@Override
    public Money with(MonetaryOperator operator) {
        Objects.requireNonNull(operator);
        try {
            return Money.class.cast(operator.apply(this));
        } catch (MonetaryException e) {
            throw e;
        } catch (Exception e) {
            throw new MonetaryException("Operator failed: " + operator, e);
        }
    }
823954
public static function format($fPrice)
    {
        $fPrice = (float) $fPrice;

        $obThis = self::instance();

        return number_format($fPrice, $obThis->iDecimal, $obThis->sDecPoint, $obThis->sThousandsSep);
    }
801149
public function dispatchOrderLineOnCreatedEvent(
        OrderInterface $order,
        CartLineInterface $cartLine,
        OrderLineInterface $orderLine
    ) {
        $orderLineOnCreatedEvent = new OrderLineOnCreatedEvent(
            $order,
            $cartLine,
            $orderLine
        );

        $this->eventDispatcher->dispatch(
            ElcodiCartEvents::ORDERLINE_ONCREATED,
            $orderLineOnCreatedEvent
        );

        return $this;
    }
670390
public function convertPrice(float $price, $baseCurrency = null, $targetCurrency = null, $quantity = 1) : string
    {
        return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity);
    }
884690
public function addPrice($amount, $currency, $type = null, $resolution = null)
    {
        $this->prices[] = array(
            'amount' => $amount,
            'currency' => $currency,
            'type' => $type,
            'resolution' => $resolution,
        );

        return $this;
    }
1370889
public function formatPrice($price, $currency, $locale = null)
    {
        return $this->priceManager->getFormattedPrice($price, $currency, $locale);
    }
7606
protected function findPrice(PriceInterface $searchPrice): ?PriceInterface
    {
        foreach ($this->prices as $price) {
            if ($price->getAmount() == $searchPrice->getAmount() && $price->getB2bGroupId() == $searchPrice->getB2bGroupId() && $price->getCurrency()->getId() == $searchPrice->getCurrency()->getId()) {
                return $price;
            }
        }

        return null;
    }
647020
public function format(
        $price,
        $digits = null,
        $locale = null,
        $currency = null,
        $currencyPosition = self::CURRENCY_LOCATION_NONE
    ) {
        if (is_null($locale)) {
            $locale = $this->defaultLocale;
        }

        if (is_null($digits)) {
            $digits = $this->defaultDigits;
        }

        $formatter = $this->getFormatter($locale, $digits);
        $formattedPrice = $formatter->format($price);

        if ($currencyPosition != self::CURRENCY_LOCATION_NONE && is_null($currency)) {
            throw new PriceFormatterException('currency must be set, if location is set');
        }

        switch ($currencyPosition) {
            case self::CURRENCY_LOCATION_PREFIX:
                $formattedPrice = $currency . ' ' . $formattedPrice;
                break;
            case self::CURRENCY_LOCATION_SUFFIX:
                $formattedPrice = $formattedPrice . ' ' . $currency;
                break;
        }

        return $formattedPrice;
    }
895875
public function refund($oOrder = null, $fPrice, $aRequestParameters = array())
    {
        //Refund ID
        if ($oOrder !== null) {
            $aRequestParameters['refund_amount'] = $fPrice;
            $this->_mapOrderToRequestParameters(
                $oOrder,
                $aRequestParameters,
                array('amazon_capture_id', 'currency_code', 'refund_reference_id', 'seller_refund_note')
            );
        }

        //Make request
        $this->_addSandboxSimulationParams('refund', $aRequestParameters);
        $oData = $this->_convertResponse($this->_getAmazonClient()->refund($aRequestParameters));

        //Update/Insert Refund info
        if ($oData && $oOrder !== null) {
            $sError = '';
            $sAmazonRefundId = '';

            if (isset($oData->Error)) {
                $sState = 'Error';
                $sError = $oData->Error->Message;
            } else {
                $sState = $oData->RefundResult->RefundDetails->RefundStatus->State;
                $sAmazonRefundId = $oData->RefundResult->RefundDetails->AmazonRefundId;
            }

            $sId = $oOrder->getFieldData('bestitamazonorderreferenceid').'_'.$this->getUtilsDate()->getTime();

            $sQuery = "
                INSERT bestitamazonrefunds SET 
                  ID = {$this->getDatabase()->quote($sId)},
                  OXORDERID = {$this->getDatabase()->quote($oOrder->getId())},
                  BESTITAMAZONREFUNDID = {$this->getDatabase()->quote($sAmazonRefundId)},
                  AMOUNT = {$fPrice},
                  STATE = {$this->getDatabase()->quote($sState)},
                  ERROR = {$this->getDatabase()->quote($sError)},
                  TIMESTAMP = NOW()";

            $this->getDatabase()->execute($sQuery);
        }

        return $oData;
    }
478936
protected function doPay(Order $order)
    {
        if ('TEST' == Paybox::getConfigValue('mode', false)) {
            $platformUrl = Paybox::getConfigValue('url_serveur_test', false);
        } else {
            $platformUrl = Paybox::getConfigValue('url_serveur', false);
        }

        // Be sure to have a valid platform URL, otherwise give up
        if (false === $platformUrl) {
            throw new \InvalidArgumentException(
                Translator::getInstance()->trans(
                    "The platform URL is not defined, please check Paybox module configuration.",
                    [],
                    Paybox::MODULE_DOMAIN
                )
            );
        }

        $hashAlgo = $this->getHashAlgorithm();
        $clefPrivee = Paybox::getConfigValue('clef_privee');

        $paybox_params = $this->doPayPayboxParameters($order)
            + [
                'PBX_HASH' => $hashAlgo,
                'PBX_SECRET' => $clefPrivee
            ];

        // Generate signature
        $param = '';

        foreach ($paybox_params as $key => $value) {
            $param .= "&" . $key . '=' . $value;
        }

        $param = ltrim($param, '&');

        $binkey = pack('H*', $clefPrivee);

        $paybox_params['PBX_HMAC'] = strtoupper(hash_hmac($hashAlgo, $param, $binkey));

        return $this->generateGatewayFormResponse($order, $platformUrl, $paybox_params);
    }
191452
public function sale($amount = null)
    {
        $builder = new HpsGiftCardServiceSaleBuilder($this);
        return $builder
            ->withAmount($amount)
            ->withCurrency('usd');
    }
1103527
public static CoinsuperGenericOrder adaptOrder(String orderId, OrderList orderList) {
    BigDecimal averagePrice = new BigDecimal(orderList.getPriceLimit());
    BigDecimal cumulativeAmount = new BigDecimal(orderList.getQuantity());
    BigDecimal totalFee = new BigDecimal(orderList.getFee());

    BigDecimal amount = new BigDecimal(orderList.getQuantity());
    OrderType action = OrderType.ASK;
    if (orderList.getAction().equals("Buy")) {
      action = OrderType.BID;
    }
    // Order Status UNDEAL:Not Executed，PARTDEAL:Partially Executed，DEAL:Order Complete，CANCEL:
    // Canceled
    OrderStatus orderStatus = OrderStatus.PENDING_NEW;
    if (orderList.getState().equals("UNDEAL")) {
      orderStatus = OrderStatus.PENDING_NEW;
    } else if (orderList.getState().equals("Canceled")) {
      orderStatus = OrderStatus.CANCELED;
    }

    CoinsuperGenericOrder coinsuperGenericOrder =
        new CoinsuperGenericOrder(
            action,
            amount,
            new CurrencyPair(orderList.getSymbol()),
            orderId,
            CommonUtil.timeStampToDate(orderList.getUtcCreate()),
            averagePrice,
            cumulativeAmount,
            totalFee,
            orderStatus);

    return coinsuperGenericOrder;
  }
614246
public function addOrderLine(OrderLineInterface $orderLine): OrderInterface
    {
        if (!$this->hasOrderLine($orderLine)) {
            $this->orderLines->add($orderLine);
            $orderLine->setOrder($this);
        }

        return $this;
    }
668040
public function PaymentOrderCancel($paymentOrderId, $amount, $currency)
    {
        $request = new Request();
        $request->setMethod('POST');

        foreach (array('paymentOrderId', 'amount', 'currency') as $param) {
            if (null == $$param) {
                throw new InvalidArgumentException($param);
            }
        }

        $params = array(
            'PaymentOrderId' => $paymentOrderId,
            'CancelAmount'   => $amount,
            'Currency'       => $currency
        );

        $request->setContent(json_encode($params));

        return $this->doRequest('PaymentOrder/Cancel', $request)->getContentJson();
    }
90549
public function getModelOffers($modelId, $regionId, $currency = null, $orderByPrice = null)
    {
        $resource = sprintf('models/%s/offers.%s', $modelId, self::DECODE_TYPE_DEFAULT);
        $queryParams = $this->filterParams([
            'regionId' => $regionId,
            'currency' => $currency,
            'orderByPrice' => $orderByPrice,
        ]);

        $response = $this->sendRequest('GET', $this->getServiceUrl($resource), ['query' => $queryParams]);
        $decodedResponseBody = $this->getDecodedBody($response->getBody());
        $marketModelsResponse = new GetMarketModelsResponse($decodedResponseBody);

        return $marketModelsResponse->getModels()->current();
    }
101824
public function prepareInvoiceWithoutItems(OrderInterface $order, $amount)
    {
        try {
            $invoice = $this->orderConverter->toInvoice($order);
            $invoice->setBaseGrandTotal($amount);
            $invoice->setSubtotal($amount);
            $invoice->setBaseSubtotal($amount);
            $invoice->setGrandTotal($amount);

            $order->getInvoiceCollection()->addItem($invoice);

            return $invoice;
        } catch(\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }