|
9 | 9 | * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace |
10 | 10 | * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps |
11 | 11 | * @phpcs:disable PSR1.Methods.CamelCapsMethodName |
12 | | - * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing |
| 12 | + * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing |
13 | 13 | * @phpcs:disable PSR12.Properties.ConstantVisibility |
14 | 14 | */ |
15 | 15 |
|
@@ -614,15 +614,17 @@ public function process_payment($order_id) |
614 | 614 |
|
615 | 615 | # Return success redirect |
616 | 616 | return array( |
617 | | - 'result' => 'success', |
618 | | - 'redirect' => $payOrder->getPaymentUrl() |
| 617 | + 'result' => 'success', |
| 618 | + 'redirect' => $payOrder->getPaymentUrl() |
619 | 619 | ); |
| 620 | + |
620 | 621 | } catch (PPMFWC_Exception_Notice $e) { |
621 | 622 | PPMFWC_Helper_Data::ppmfwc_payLogger('Process payment start notice: ' . $e->getMessage()); |
622 | 623 | $message = $e->getMessage(); |
623 | 624 | 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'); |
626 | 628 | $message = 'Could not initiate payment. Please try again or use another payment method.'; |
627 | 629 | wc_add_notice(esc_html(__($message, PPMFWC_WOOCOMMERCE_TEXTDOMAIN)), 'error'); |
628 | 630 | } |
@@ -751,21 +753,22 @@ public static function getServiceId() |
751 | 753 | */ |
752 | 754 | public function process_refund($order_id, $amount = null, $reason = '') |
753 | 755 | { |
754 | | - PPMFWC_Helper_Data::ppmfwc_payLogger('process_refund', $order_id, array('orderid' => $order_id, 'amount' => $amount)); |
755 | | - |
756 | 756 | 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)); |
757 | 758 | return new WP_Error('1', "Refund amount must be greater than €0.00"); |
758 | 759 | } |
759 | 760 |
|
760 | 761 | $order = wc_get_order($order_id); |
761 | 762 | $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)); |
762 | 766 |
|
763 | | - if (empty($order) || empty($transactionLocalDB) || empty($transactionLocalDB['transaction_id'])) { |
764 | | - 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 |
765 | 769 | 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))); |
766 | 770 | } |
767 | 771 |
|
768 | | - $transactionId = $transactionLocalDB['transaction_id']; |
769 | 772 |
|
770 | 773 | try { |
771 | 774 | # First set local state to refund so that the exchange will not try to refund aswell. |
|
0 commit comments