Skip to content

Commit

Permalink
Merge pull request #13 from paynl/feature/PLUG-867
Browse files Browse the repository at this point in the history
PLUG-867 - PIN fix
  • Loading branch information
woutse authored Mar 11, 2022
2 parents c5891c1 + 3c3eb04 commit b623561
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 12 additions & 1 deletion paynlpaymentmethods/paynlpaymentmethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions paynlpaymentmethods/src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit b623561

Please sign in to comment.