Skip to content

Commit 7bc9ba1

Browse files
committed
Updates for v4
1 parent bd725cd commit 7bc9ba1

6 files changed

Lines changed: 35 additions & 41 deletions

File tree

includes/classes/PPMFWC/Gateway/Abstract.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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
}
@@ -751,21 +753,22 @@ public static function getServiceId()
751753
*/
752754
public function process_refund($order_id, $amount = null, $reason = '')
753755
{
754-
PPMFWC_Helper_Data::ppmfwc_payLogger('process_refund', $order_id, array('orderid' => $order_id, 'amount' => $amount));
755-
756756
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));
757758
return new WP_Error('1', "Refund amount must be greater than €0.00");
758759
}
759760

760761
$order = wc_get_order($order_id);
761762
$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));
762766

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
765769
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)));
766770
}
767771

768-
$transactionId = $transactionLocalDB['transaction_id'];
769772

770773
try {
771774
# First set local state to refund so that the exchange will not try to refund aswell.

includes/classes/PPMFWC/Gateways.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -850,16 +850,6 @@ public static function ppmfwc_onReturn()
850850

851851
PPMFWC_Helper_Data::ppmfwc_payLogger('FINISH, back from PAY payment', $orderId, array('orderStatusId' => $orderStatusId, 'status' => $status));
852852

853-
///?wc-api=Wc_Pay_Gateway_Return
854-
/// id=44907558081X114c
855-
/// reference=39
856-
/// statusAction=CANCEL
857-
/// statusCode=-64
858-
/// ticket=
859-
/// utm_nooverride=1
860-
861-
#return (new PayStatus())->get($statusCode) === PayStatus::DENIED
862-
863853
try {
864854
# Retrieve URL to continue (and update status if necessary)
865855
if (!empty($orderId)) {
@@ -1031,15 +1021,15 @@ public static function ppmfwc_onExchange()
10311021
$payOrder = $exchange->process(PPMFWC_Helper_Config::getPayConfig());
10321022
$payOrderId = $payOrder->getOrderId();
10331023

1034-
PPMFWC_Helper_Data::ppmfwc_payLogger('payOrderId: ' . $payOrderId);
1035-
10361024
if ($payOrder->isPending()) {
10371025
$exchange->setResponse(true, 'Ignoring pending.');
10381026
}
10391027

10401028
$order_id = $exchange->getReference();
10411029
$methodId = $payOrder->getPaymentMethod();
10421030

1031+
PPMFWC_Helper_Data::ppmfwc_payLogger('Exchange', $payOrderId, array('action' => $action, 'wc_order_id' => $order_id, 'methodid' => $methodId));
1032+
10431033
if ($methodId == PPMFWC_Gateway_Abstract::PAYMENT_METHOD_PINREFUND && $action == self::ACTION_NEWPPT) {
10441034
$action = self::ACTION_PINREFUND;
10451035
}
@@ -1057,20 +1047,22 @@ public static function ppmfwc_onExchange()
10571047
throw new PPMFWC_Exception_Notice('Ignoring: ' . $action);
10581048
}
10591049

1060-
PPMFWC_Helper_Data::ppmfwc_payLogger('Exchange incoming', $order_id, array('action' => $action, 'wc_order_id' => '', 'methodid' => $methodId));
1050+
10611051

10621052
$newStatus = PPMFWC_Helper_Transaction::processTransaction($payOrder, $status, $methodId);
10631053
$responseMessage = 'Status updated to ' . $newStatus;
10641054

10651055

10661056
} catch (PPMFWC_Exception_Notice $e) {
10671057
$responseMessage = $e->getMessage();
1058+
10681059
} catch (PPMFWC_Exception $e) {
1069-
$responseResult = false;
10701060
$responseMessage = 'Error 1: ' . $e->getMessage();
1061+
PPMFWC_Helper_Data::ppmfwc_payLogger('Exchange error: ' . $e->getMessage(), ($order_id ?? 0), array('action' => ($action ?? ''), 'wc_order_id' => '', 'payOrderId' => ($payOrderId ?? '')), 'critical');
1062+
10711063
} catch (Exception $e) {
1072-
$responseResult = false;
10731064
$responseMessage = 'Error 2: ' . $e->getMessage();
1065+
PPMFWC_Helper_Data::ppmfwc_payLogger('Exchange Error: ' . $e->getMessage(), ($order_id ?? 0), array('action' => ($action ?? ''), 'wc_order_id' => '', 'payOrderId' => ($payOrderId ?? '')), 'critical');
10741066
}
10751067

10761068
if (($action ?? '') == self::ACTION_NEWPPT && isset($payOrderId)) {

includes/classes/PPMFWC/Helper/Data.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ class PPMFWC_Helper_Data
2323
*/
2424
public static function ppmfwc_payLogger($message, $payTransactionId = null, $infoFields = array(), $type = 'info')
2525
{
26-
if (self::$paylog === true || self::$paylog === null) {
27-
if (empty(self::$paylog)) {
28-
self::$paylog = get_option('paynl_paylogger') == 'yes';
29-
if (!self::$paylog) {
30-
return;
31-
}
32-
}
26+
if (self::$paylog === null) {
27+
self::$paylog = get_option('paynl_paylogger') == 'yes';
28+
}
29+
30+
if (self::$paylog === true || strtolower($type) == 'critical') {
3331
if (!in_array($type, array('emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'))) {
3432
$type = 'info';
3533
}

includes/classes/PPMFWC/Helper/Transaction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ public static function processTransaction(\PayNL\Sdk\Model\Pay\PayOrder $payOrde
164164
throw new PPMFWC_Exception_Notice('Woocommerce could not find internal order ' . $orderId);
165165
}
166166

167-
PPMFWC_Helper_Data::ppmfwc_payLogger('processTransaction', $orderId, array($status, $localTransactionStatus));
167+
PPMFWC_Helper_Data::ppmfwc_payLogger('processTransaction', $transactionId, array($status, $localTransactionStatus, $orderId));
168168

169169
if ($status == $localTransactionStatus) {
170-
PPMFWC_Helper_Data::ppmfwc_payLogger('processTransaction - status allready up-to-date', $transactionId, array('status' => $status));
170+
PPMFWC_Helper_Data::ppmfwc_payLogger('processTransaction - status already up-to-date', $transactionId, array('status' => $status));
171171
throw new PPMFWC_Exception_Notice('Already ' . $status);
172172
}
173173

@@ -228,7 +228,7 @@ public static function processTransaction(\PayNL\Sdk\Model\Pay\PayOrder $payOrde
228228

229229
if ($payOrder->isFastCheckout()) {
230230
if ($transactionId == $order->get_meta('transactionId') && $order->get_meta('fc')) {
231-
PPMFWC_Helper_Data::ppmfwc_payLogger('adding AddressToOrder');
231+
PPMFWC_Helper_Data::ppmfwc_payLogger('FC: adding address to successful order', $transactionId);
232232
PPMFWC_Hooks_FastCheckout_Exchange::addAddressToOrder($payOrder->getCheckoutData(), $order);
233233
}
234234
}

readme.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
=== Pay. Payment Methods for WooCommerce ===
2-
Contributors: andypay
2+
Contributors: woutse
33
Donate link: https://www.pay.nl/webshops/plugin-woocommerce
44
Link: https://www.pay.nl
55
Tags: paynl, paymentmethods, iDEAL, betaalmethoden, pay
6-
Requires at least: 3.5.1
6+
Requires at least: 6.1.0
77
Stable tag: 4.0.0
8-
Tested up to: 6.8
9-
WC tested up to: 9.8.1
8+
Tested up to: 6.8.3
9+
WC tested up to: 10.3.3
1010
WC requires at least: 3.0
1111
Requires PHP: 8.1
1212
License: GPLv2

woocommerce-payment-paynl.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
* Version: 4.0.0
88
* Author: Pay.
99
* Author URI: https://www.pay.nl
10-
* Requires at least: 3.5.1
11-
* WC requires at least: 3.0
10+
* Requires at least: 6.1.0
11+
* WC requires at least: 6.5
12+
* WC tested up to: 10.3.3
1213
* Requires PHP: 8.1
1314
* Text Domain: woocommerce-paynl-payment-methods
1415
* Domain Path: /i18n/languages

0 commit comments

Comments
 (0)