Skip to content

Commit ab8ae3a

Browse files
committed
Fixed instore issues
1 parent d62d1e2 commit ab8ae3a

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

includes/classes/PPMFWC/Gateway/Abstract.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,23 @@ protected function startTransaction(WC_Order $order, $pickupLocation = null)
679679
$clean = preg_replace('/[^A-Za-z0-9]/u', '', $raw);
680680
$request->setReference($clean);
681681

682-
if ($this->getOptionId() == 1927) {
683-
$request->setTerminal(PPMFWC_Helper_Data::getPostTextField('terminal_id'));
682+
if ($this->getOptionId() == PayNL\Sdk\Model\Method::PIN) {
683+
$terminalThCode = PPMFWC_Helper_Data::getPostTextField('terminal_id');
684+
$terminal_setting = $this->get_option('paynl_instore_terminal');
685+
686+
if ($terminal_setting == 'checkout') {
687+
# do nothing, just use terminalThCode
688+
}
689+
if ($terminal_setting == 'checkout_save') {
690+
# Only save the tg-code in the cookie. This will then later be integrated in the checkout-view(hidden).
691+
setcookie('paynl_instore_terminal_id', $terminalThCode, time() + (60 * 60 * 24 * 365));
692+
693+
} elseif (str_starts_with(strtoupper($terminal_setting), 'TH')) {
694+
# A designated TH-code is selected as preferred terminal, so always use this one.
695+
$terminalThCode = $terminal_setting;
696+
}
697+
698+
$request->setTerminal($terminalThCode);
684699
}
685700

686701
$extra1 = apply_filters('paynl-extra1', $order->get_order_number(), $order);

includes/classes/PPMFWC/Gateways.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,15 @@ public static function ppmfwc_onReturn()
903903
public static function getOrderReturnUrl(WC_Order $order, $newStatus, $orderStatusId)
904904
{
905905
$payStatus = new PayStatus();
906+
$method = $order->get_payment_method() ?? '';
906907

907-
if ($payStatus->get($orderStatusId) === PayStatus::CANCEL)
908-
{
908+
if ($method == 'pay_gateway_instore') {
909909
$url = add_query_arg('paynl_status', PPMFWC_Gateways::STATUS_CANCELED, wc_get_checkout_url());
910-
} elseif ($payStatus->get($orderStatusId) === PayStatus::DENIED ||
911-
$newStatus == PPMFWC_Gateways::STATUS_DENIED)
912-
{
910+
911+
} elseif ($payStatus->get($orderStatusId) === PayStatus::CANCEL) {
912+
$url = add_query_arg('paynl_status', PPMFWC_Gateways::STATUS_CANCELED, wc_get_checkout_url());
913+
914+
} elseif ($payStatus->get($orderStatusId) === PayStatus::DENIED || $newStatus == PPMFWC_Gateways::STATUS_DENIED) {
913915
$methodName = $order->get_payment_method_title();
914916
if (!empty($methodName)) {
915917
wc_add_notice(

0 commit comments

Comments
 (0)