Skip to content

Commit fdf1185

Browse files
authored
Merge pull request #191 from paynl/feature/PLUG-5164
Fixed instore issues
2 parents ccb1a9c + d432718 commit fdf1185

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

includes/classes/PPMFWC/Gateway/Abstract.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ 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+
$request->setTerminal($this->getTerminal());
684684
}
685685

686686
$extra1 = apply_filters('paynl-extra1', $order->get_order_number(), $order);
@@ -718,6 +718,30 @@ protected function startTransaction(WC_Order $order, $pickupLocation = null)
718718
return $payOrder;
719719
}
720720

721+
/**
722+
* @return false|string
723+
*/
724+
private function getTerminal()
725+
{
726+
$terminalThCode = PPMFWC_Helper_Data::getPostTextField('terminal_id');
727+
$terminal_setting = $this->get_option('paynl_instore_terminal');
728+
729+
if ($terminal_setting == 'checkout') {
730+
# do nothing, just use terminalThCode
731+
}
732+
if ($terminal_setting == 'checkout_save') {
733+
# Only save the tg-code in the cookie. This will then later be integrated in the checkout-view(hidden).
734+
setcookie('paynl_instore_terminal_id', $terminalThCode, time() + (60 * 60 * 24 * 365));
735+
736+
} elseif (str_starts_with(strtoupper($terminal_setting), 'TH')) {
737+
# A designated TH-code is selected as preferred terminal, so always use this one.
738+
$terminalThCode = $terminal_setting;
739+
}
740+
741+
742+
return $terminalThCode ?? '';
743+
}
744+
721745
/**
722746
* @return boolean
723747
*/

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' && (in_array($newStatus, [PPMFWC_Gateways::STATUS_CANCELED, PPMFWC_Gateways::STATUS_PENDING]))) {
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)