99 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
1010 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
1111 * @phpcs:disable PSR1.Methods.CamelCapsMethodName
12- * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
12+ * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
1313 * @phpcs:disable PSR12.Properties.ConstantVisibility
1414 */
1515
@@ -614,15 +614,17 @@ public function process_payment($order_id)
614614
615615 # Return success redirect
616616 return array (
617- 'result ' => 'success ' ,
618- 'redirect ' => $ payOrder ->getPaymentUrl ()
617+ 'result ' => 'success ' ,
618+ 'redirect ' => $ payOrder ->getPaymentUrl ()
619619 );
620+
620621 } catch (PPMFWC_Exception_Notice $ e ) {
621622 PPMFWC_Helper_Data::ppmfwc_payLogger ('Process payment start notice: ' . $ e ->getMessage ());
622623 $ message = $ e ->getMessage ();
623624 wc_add_notice ($ message , 'error ' );
624- } catch (Exception $ e ) {
625- PPMFWC_Helper_Data::ppmfwc_payLogger ('Could not initiate payment. Error: ' . esc_html ($ e ->getMessage ()), null , array ('wc-order-id ' => $ order_id , 'paymentOption ' => $ paymentOption ));
625+
626+ } catch (Exception $ e ) {
627+ PPMFWC_Helper_Data::ppmfwc_payLogger ('Could not initiate payment. Error ' . esc_html ($ e ->getMessage ()), null , array ('wc_order_id ' => $ order_id , 'methodid ' => $ paymentOption ), 'critical ' );
626628 $ message = 'Could not initiate payment. Please try again or use another payment method. ' ;
627629 wc_add_notice (esc_html (__ ($ message , PPMFWC_WOOCOMMERCE_TEXTDOMAIN )), 'error ' );
628630 }
@@ -667,10 +669,12 @@ protected function startTransaction(WC_Order $order, $pickupLocation = null)
667669 $ request ->setExchangeUrl ($ exchangeUrl );
668670 $ request ->setDescription (str_replace ('__ ' , ' ' , $ prefix ) . $ order ->get_order_number ());
669671 $ request ->setAmount ($ order ->get_total ());
670- $ request ->setReference ($ order ->get_order_number ());
672+
673+ $ raw = (string )($ order ->get_order_number () ?? '' );
674+ $ clean = preg_replace ('/[^A-Za-z0-9]/u ' , '' , $ raw );
675+ $ request ->setReference ($ clean );
671676
672677 if ($ this ->getOptionId () == 1927 ) {
673- //paydbg(PPMFWC_Helper_Data::getPostTextField('terminal_id'));
674678 $ request ->setTerminal (PPMFWC_Helper_Data::getPostTextField ('terminal_id ' ));
675679 }
676680
@@ -690,78 +694,6 @@ protected function startTransaction(WC_Order $order, $pickupLocation = null)
690694 $ requestOrderData ->setDeliveryAddress (PPMFWC_Helper_Config::getDeliveryAddress ($ order ));
691695 $ request ->setOrder ($ requestOrderData );
692696
693-
694- // # Retrieve order data
695- // $shippingAddress = $order->get_shipping_address_1() . ' ' . $order->get_shipping_address_2();
696- //
697- // $billingAddress = $order->get_billing_address_1() . ' ' . $order->get_billing_address_2();
698- // $aBillingAddress = \Paynl\Helper::splitAddress($billingAddress);
699- // $aShippingAddress = \Paynl\Helper::splitAddress($shippingAddress);
700- //
701- // # Check order meta for postNL plugin house number
702- // $_shipping_house_number = $order->get_meta('_shipping_house_number');
703- // if (empty($aShippingAddress[1]) && !empty($_shipping_house_number)) {
704- // $shippingAddress = $order->get_shipping_address_1() . ' ' . $_shipping_house_number . $order->get_shipping_address_2();
705- // }
706- //
707- // $_billing_house_number = $order->get_meta('_billing_house_number');
708- // if (empty($aBillingAddress[1]) && !empty($_billing_house_number)) {
709- // $billingAddress = $order->get_billing_address_1() . ' ' . $_billing_house_number .
710- // $order->get_billing_address_2();
711- // }
712- //
713- // $aBillingAddress = \Paynl\Helper::splitAddress($billingAddress);
714- // $aShippingAddress = \Paynl\Helper::splitAddress($shippingAddress);
715- // $address = array(
716- // 'streetName' => $aShippingAddress[0],
717- // 'houseNumber' => $aShippingAddress[1],
718- // 'zipCode' => $order->get_shipping_postcode(),
719- // 'city' => $order->get_shipping_city(),
720- // 'country' => $order->get_shipping_country()
721- // );
722- //
723- // if ($this->get_option('use_invoice_address') == 'yes')
724- // {
725- // PPMFWC_Helper_Data::ppmfwc_payLogger('Use_invoice_address=yes. Updating shipping address');
726- // $address = array(
727- // 'streetName' => $aBillingAddress[0],
728- // 'houseNumber' => $aBillingAddress[1],
729- // 'zipCode' => $order->get_billing_postcode(),
730- // 'city' => $order->get_billing_city(),
731- // 'country' => $billing_country
732- // );
733- // }
734-
735- # $startData['address'] = $address;
736- //$startData['invoiceAddress'] = array(
737- // 'initials' => $order->get_billing_first_name(),
738- // 'lastName' => substr($order->get_billing_last_name(), 0, 32),
739- // 'streetName' => $aBillingAddress[0],
740- // 'houseNumber' => $aBillingAddress[1],
741- // 'zipCode' => $order->get_billing_postcode(),
742- // 'city' => $order->get_billing_city(),
743- // 'country' => $billing_country,
744- //);
745-
746- //$startData['products'] = $this->getProductLines($order);
747-
748- // $optionSubId = PPMFWC_Helper_Data::getPostTextField('selectedissuer');
749- // if (empty($optionSubId)) {
750- // $optionSubId = PPMFWC_Helper_Data::getPostTextField('option_sub_id');
751- // }
752-
753- // if (!empty($optionSubId)) {
754- // $startData['bank'] = $optionSubId;
755- // }
756-
757- $ language = get_option ('paynl_language ' );
758-
759- if ($ language == 'browser ' ) {
760- $ language = PPMFWC_Helper_Data::getBrowserLanguage ();
761- }
762-
763- //$startData['language'] = $language;
764-
765697 if ($ pickupLocation === true ) {
766698 PPMFWC_Helper_Data::ppmfwc_payLogger ('Payment at pickup, order has been made but transaction skipped. ' );
767699 $ order ->save ();
@@ -821,21 +753,22 @@ public static function getServiceId()
821753 */
822754 public function process_refund ($ order_id , $ amount = null , $ reason = '' )
823755 {
824- PPMFWC_Helper_Data::ppmfwc_payLogger ('process_refund ' , $ order_id , array ('orderid ' => $ order_id , 'amount ' => $ amount ));
825-
826756 if ($ amount <= 0 ) {
757+ PPMFWC_Helper_Data::ppmfwc_payLogger ('process_refund: fund amount must be greater than 0.0 ' , '' , array ('orderid ' => $ order_id , 'amount ' => $ amount ));
827758 return new WP_Error ('1 ' , "Refund amount must be greater than €0.00 " );
828759 }
829760
830761 $ order = wc_get_order ($ order_id );
831762 $ transactionLocalDB = PPMFWC_Helper_Transaction::getPaidTransactionIdForOrderId ($ order_id );
763+ $ transactionId = $ transactionLocalDB ['transaction_id ' ] ?? '' ;
764+
765+ PPMFWC_Helper_Data::ppmfwc_payLogger ('process_refund ' , $ transactionId , array ('orderid ' => $ order_id , 'amount ' => $ amount ));
832766
833- if (empty ($ order ) || empty ($ transactionLocalDB ) || empty ( $ transactionLocalDB [ ' transaction_id ' ] )) {
834- PPMFWC_Helper_Data::ppmfwc_payLogger ('Refund canceled, order empty ' , $ order_id , array ('orderid ' => $ order_id , 'amunt ' => $ amount , 'transactionId ' => $ transactionLocalDB [ ' transaction_id ' ] )); // phpcs:ignore
767+ if (empty ($ order ) || empty ($ transactionId )) {
768+ PPMFWC_Helper_Data::ppmfwc_payLogger ('Refund canceled, order empty ' , $ order_id , array ('orderid ' => $ order_id , 'amunt ' => $ amount , 'transactionId ' => $ transactionId )); // phpcs:ignore
835769 return new WP_Error (1 , esc_html (__ ('This transaction seems to have already been refunded or may not be captured yet. Please check the status on My.pay. ' , PPMFWC_WOOCOMMERCE_TEXTDOMAIN )));
836770 }
837771
838- $ transactionId = $ transactionLocalDB ['transaction_id ' ];
839772
840773 try {
841774 # First set local state to refund so that the exchange will not try to refund aswell.
0 commit comments