From 9d9a5148b67a1bd02c7c9e120c31c053d73b1114 Mon Sep 17 00:00:00 2001 From: woutse Date: Thu, 3 Jun 2021 13:28:08 +0200 Subject: [PATCH] Updated paymentmethod name --- paynlpaymentmethods/paynlpaymentmethods.php | 39 +++++++++++++-------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/paynlpaymentmethods/paynlpaymentmethods.php b/paynlpaymentmethods/paynlpaymentmethods.php index 25a8cf2..d1b584c 100644 --- a/paynlpaymentmethods/paynlpaymentmethods.php +++ b/paynlpaymentmethods/paynlpaymentmethods.php @@ -136,18 +136,27 @@ public function hookDisplayAdminOrder($params) $orderPayment = reset($orderPayments); $status = 'unavailable'; - $method = $order->payment; $currency = new Currency($orderPayment->id_currency); $transactionId = $orderPayment->transaction_id; $payOrderAmount = 0; + $methodName = 'PAY.'; try { - $transaction = $this->getTransaction($transactionId); - $arrTransactionDetails = $transaction->getData(); - $payOrderAmount = $transaction->getPaidAmount(); - $status = $arrTransactionDetails['paymentDetails']['stateName']; - $method = $arrTransactionDetails['paymentDetails']['paymentProfileName']; - $showRefundButton = $transaction->isPaid() || $transaction->isPartiallyRefunded(); + $transaction = $this->getTransaction($transactionId); + $arrTransactionDetails = $transaction->getData(); + $payOrderAmount = $transaction->getPaidAmount(); + $status = $arrTransactionDetails['paymentDetails']['stateName']; + $profileId = $transaction->getPaymentProfileId(); + $settings = $this->getPaymentMethodSettings($profileId); + + # Get the custom method name + if ($profileId == 613) { + $methodName = 'Sandbox'; + } else { + $methodName = empty($settings->name) ? $profileId : $settings->name; + } + + $showRefundButton = $transaction->isPaid() || $transaction->isPartiallyRefunded(); } catch (Exception $exception) { $showRefundButton = false; } @@ -165,7 +174,7 @@ public function hookDisplayAdminOrder($params) 'currency' => $currency->iso_code, 'pay_orderid' => $transactionId, 'status' => $status, - 'method' => $method, + 'method' => $methodName, 'ajaxURL' => $this->context->link->getModuleLink($this->name, 'ajax', array(), true), 'showRefundButton' => $showRefundButton, )); @@ -632,15 +641,16 @@ public function processPayment($transactionId, &$message = null) } try { - $profileId = $arrPayData['paymentDetails']['paymentOptionId']; - $paymentMethodName = $arrPayData['paymentDetails']['paymentProfileName']; + $profileId = $transaction->getPaymentProfileId(); # Profile 613 is for testing purposes - if($profileId != 613) { - $settings = $this->getPaymentMethodSettings($profileId); + if ($profileId == 613) { + $paymentMethodName = 'Sandbox'; + } else { + $settings = $this->getPaymentMethodSettings($profileId); - # Get the custom method name - $paymentMethodName = empty($settings->name) ? '' : $settings->name; + # Get the custom method name + $paymentMethodName = empty($settings->name) ? '' : $settings->name; } if (empty($paymentMethodName)) { @@ -686,7 +696,6 @@ public function processPayment($transactionId, &$message = null) public function getTransaction($transactionId) { $this->sdkLogin(); - return \Paynl\Transaction::status($transactionId); }