diff --git a/Controller/Checkout/Exchange.php b/Controller/Checkout/Exchange.php index f429f512..7b1c1a58 100644 --- a/Controller/Checkout/Exchange.php +++ b/Controller/Checkout/Exchange.php @@ -288,28 +288,10 @@ private function processPaidOrder(Transaction $transaction, Order $order) ]; $orderAmount = round($order->getGrandTotal(), 2); - if (!in_array($orderAmount, $transactionPaid)) { - payHelper::logCritical('Amount validation error.', array($transactionPaid, $orderAmount, $order->getGrandTotal())); - return $this->result->setContents('FALSE| Amount validation error. Amounts: ' . print_r(array($transactionPaid, $orderAmount, $order->getGrandTotal()), true)); - } - - $paidAmount = $order->getGrandTotal(); - - if (!$this->paynlConfig->isAlwaysBaseCurrency()) { - if ($order->getBaseCurrencyCode() != $order->getOrderCurrencyCode()) { - # We can only register the payment in the base currency - $paidAmount = $order->getBaseGrandTotal(); - } - } - - # Multipayments finish - if ($this->config->registerPartialPayments()) { - $payments = $order->getAllPayments(); - if (count($payments) > 1) { - if ($transaction->isPaid() && $order->getTotalDue() == 0) { - $paidAmount = $order->getBaseGrandTotal(); - } - } + $orderBaseAmount = round($order->getBaseGrandTotal(), 2); + if (!in_array($orderAmount, $transactionPaid) && !in_array($orderBaseAmount, $transactionPaid)) { + payHelper::logCritical('Amount validation error.', array($transactionPaid, $orderAmount, $order->getGrandTotal(), $order->getBaseGrandTotal())); + return $this->result->setContents('FALSE| Amount validation error. Amounts: ' . print_r(array($transactionPaid, $orderAmount, $order->getGrandTotal(), $order->getBaseGrandTotal()), true)); } # Force order state to processing @@ -348,9 +330,9 @@ private function processPaidOrder(Transaction $transaction, Order $order) } if ($transaction->isAuthorized()) { - $payment->registerAuthorizationNotification($paidAmount); + $payment->registerAuthorizationNotification($order->getBaseGrandTotal()); } else { - $payment->registerCaptureNotification($paidAmount, $this->config->isSkipFraudDetection()); + $payment->registerCaptureNotification($order->getBaseGrandTotal(), $this->config->isSkipFraudDetection()); } $order->setStatus(!empty($newStatus) ? $newStatus : Order::STATE_PROCESSING); @@ -385,7 +367,7 @@ private function processPartiallyPaidOrder(Order $order, $payOrderId) $paymentDetails = $details->getPaymentDetails(); $transactionDetails = $paymentDetails['transactionDetails']; $firstPayment = count($transactionDetails) == 1; - $totalpaid =0; + $totalpaid = 0; foreach ($transactionDetails as $_dt) { $totalpaid += $_dt['amount']['value']; } @@ -420,13 +402,12 @@ private function processPartiallyPaidOrder(Order $order, $payOrderId) ); $transactionBuilder->save(); - $order->addStatusHistoryComment(__('PAY.: Partial payment received: '.$subProfile.' - Amount ' . $currency . ' ' . $amount . ' Method: ' . $method)); + $order->addStatusHistoryComment(__('PAY.: Partial payment received: ' . $subProfile . ' - Amount ' . $currency . ' ' . $amount . ' Method: ' . $method)); $order->setTotalPaid($totalpaid / 100); $this->orderRepository->save($order); - } catch (\Exception $e) { - $returnMessage = 'TRUE| Failed processing partial payment'. $e->getMessage(); + $returnMessage = 'TRUE| Failed processing partial payment' . $e->getMessage(); } return $this->result->setContents($returnMessage);