/** * {@inheritDoc} */ protected function composeDetails(PaymentInterface $payment, TokenInterface $token) { if ($payment->getDetails()) { return; } $order = $payment->getOrder(); $total = $this->currencyConverter->convert($order->getTotal(), $order->getCurrency()); $payment->setDetails(array('amount' => round($total / 100, 2), 'currency' => $order->getCurrency())); }
/** * {@inheritDoc} */ protected function composeDetails(PaymentInterface $payment, TokenInterface $token) { if ($payment->getDetails()) { return; } $order = $payment->getOrder(); $this->payment->execute($obtainCreditCardRequest = new ObtainCreditCardRequest($order)); $creditCard = $obtainCreditCardRequest->getCreditCard(); $total = $this->currencyConverter->convert($order->getTotal(), $order->getCurrency()); $payment->setDetails(array('card' => new SensitiveValue(array('number' => $creditCard->getNumber(), 'expiryMonth' => $creditCard->getExpiryMonth(), 'expiryYear' => $creditCard->getExpiryYear(), 'cvv' => $creditCard->getSecurityCode())), 'amount' => round($total / 100, 2), 'currency' => $order->getCurrency())); }
/** * {@inheritdoc} */ public function convertAmount($amount, $sourceCurrencyCode, $targetCurrencyCode) { return $this->currencyConverter->convert($amount, $sourceCurrencyCode, $targetCurrencyCode); }
function it_converts_and_formats_money_using_default_locale_if_not_given(CurrencyConverterInterface $currencyConverter) { $currencyConverter->convert(500, 'USD', 'CAD')->willReturn(250); $this->convertAmount(500, 'USD', 'CAD')->shouldReturn(250); }
/** * Convert amount and format it! * * @param int $amount * @param string|null $currency * @param bool $decimal * * @return string */ public function convertAndFormatAmount($amount, $currency = null, $decimal = false) { $currency = $currency ?: $this->currencyContext->getCurrency(); $amount = $this->converter->convert($amount, $currency); return $this->moneyHelper->formatAmount($amount, $currency, $decimal); }