diff --git a/paynlpaymentmethods/paynlpaymentmethods.php b/paynlpaymentmethods/paynlpaymentmethods.php index 0d8848c..cb7e03c 100644 --- a/paynlpaymentmethods/paynlpaymentmethods.php +++ b/paynlpaymentmethods/paynlpaymentmethods.php @@ -133,7 +133,8 @@ public function createDatabaseTable() `status` varchar(255) DEFAULT NULL, `created_at` datetime NOT NULL DEFAULT current_timestamp(), `updated_at` datetime NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX (`transaction_id`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;'); return true; @@ -189,6 +190,13 @@ public function hookDisplayAdminOrder($params) } else { $methodName = empty($settings->name) ? $profileId : $settings->name; } + + if ($methodName == $profileId) { + if (count(Transaction::get($transactionId) > 0)) { + $methodName = 'PAY. PIN (Instore)'; + } + } + $showRefundButton = ($transaction->isPaid() || $transaction->isPartiallyRefunded()) && ($profileId != PaymentMethod::METHOD_INSTORE_PROFILE_ID && $profileId != PaymentMethod::METHOD_INSTORE); } catch (Exception $exception) { $showRefundButton = false; @@ -684,6 +692,9 @@ public function processPayment($transactionId, &$message = null) if (empty(trim($paymentMethodName))) { $paymentMethodName = 'PAY.'; + if (count(Transaction::get($transactionId) > 0)) { + $paymentMethodName = 'PAY. PIN (Instore)'; + } } $cart = new Cart((int)$cartId); diff --git a/paynlpaymentmethods/src/Transaction.php b/paynlpaymentmethods/src/Transaction.php index eebc5eb..356ab54 100644 --- a/paynlpaymentmethods/src/Transaction.php +++ b/paynlpaymentmethods/src/Transaction.php @@ -51,13 +51,13 @@ public static function addTransactionHash($transaction_id, $hash) /** * Returns the transaction based on transaction_id from the pay_transactions table * - * @param int $transaction_id - * @return array - * + * @param $transaction_id + * @return array */ public static function get($transaction_id) { - $transaction = Db::getInstance()->getRow("SELECT * FROM `" . _DB_PREFIX_ . "pay_transactions` WHERE `transaction_id` = '" . Db::getInstance()->escape($transaction_id) . "';"); - return $transaction; + $result = Db::getInstance()->getRow("SELECT * FROM `" . _DB_PREFIX_ . "pay_transactions` WHERE `transaction_id` = '" . Db::getInstance()->escape($transaction_id) . "';"); + + return is_array($result) ? $result : array(); } }