Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omnipay itemBag price should be converted to payment currency #23

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/base/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,10 @@ protected function getItemListForOrder(Order $order): array

/** @var LineItem $item */
foreach ($order->lineItems as $item) {
$price = Currency::round($item->salePrice);
$price = Currency::round(
Commerce::getInstance()->getPaymentCurrencies()->convertCurrency($item->salePrice, $order->currency, $order->paymentCurrency),
Commerce::getInstance()->getPaymentCurrencies()->getPaymentCurrencyByIso($order->paymentCurrency)
);
// Can not accept zero amount items. See item (4) here:
// https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#setting-order-details-on-the-paypal-review-page

Expand All @@ -707,8 +710,11 @@ protected function getItemListForOrder(Order $order): array

/** @var OrderAdjustment $adjustment */
foreach ($order->adjustments as $adjustment) {
$price = Currency::round($adjustment->amount);

$price = Currency::round(
Commerce::getInstance()->getPaymentCurrencies()->convertCurrency($adjustment->amount, $order->currency, $order->paymentCurrency),
Commerce::getInstance()->getPaymentCurrencies()->getPaymentCurrencyByIso($order->paymentCurrency)
);

// Do not include the 'included' adjustments, and do not send zero value items
// See item (4) https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/#setting-order-details-on-the-paypal-review-page
if (($adjustment->included == 0 || $adjustment->included == false) && $price !== 0) {
Expand Down