@@ -680,22 +680,7 @@ protected function startTransaction(WC_Order $order, $pickupLocation = null)
680680 $ request ->setReference ($ clean );
681681
682682 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 );
683+ $ request ->setTerminal ($ this ->getTerminal ());
699684 }
700685
701686 $ extra1 = apply_filters ('paynl-extra1 ' , $ order ->get_order_number (), $ order );
@@ -733,6 +718,30 @@ protected function startTransaction(WC_Order $order, $pickupLocation = null)
733718 return $ payOrder ;
734719 }
735720
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+
736745 /**
737746 * @return boolean
738747 */
0 commit comments