diff --git a/README.md b/README.md
old mode 100755
new mode 100644
index 8051fd6..3b3ff08
--- a/README.md
+++ b/README.md
@@ -1,12 +1,16 @@
# PayWeb_WooCommerce
-## PayGate WooCommerce plugin v1.4.7 for WooCommerce v8.3.1
-This is the Paygate plugin for WooCommerce. Please feel free to contact the Payfast support team at support@payfast.io should you require any assistance.
+## PayGate WooCommerce plugin v1.4.8 for WooCommerce v8.9.1
+
+This is the Paygate plugin for WooCommerce. Please feel free to contact the Payfast support team at support@payfast.io
+should you require any assistance.
## Installation
+
[![How To Setup PayGate PayWeb for WooCommerce](https://appinlet.com/wp-content/uploads/2021/01/How-To-Setup-PayGate-PayWeb-for-WooCommerce.jpg)](https://www.youtube.com/watch?v=MMcEG7FmoEM "How To Setup PayGate PayWeb for WooCommerce")
-Please navigate to the [releases page](https://github.com/PayGate/PayWeb_WooCommerce/releases), download the latest release (v1.4.7) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.
+Please navigate to the [releases page](https://github.com/PayGate/PayWeb_WooCommerce/releases), download the latest
+release (v1.4.8) and unzip. You will them be able to follow the integration guide PDF which is included in the zip.
## Collaboration
diff --git a/changelog.txt b/changelog.txt
index 405e306..c3d1fe2 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,4 +1,8 @@
*** Paygate for WooCommerce Changelog ***
+= 1.4.8 - 2024-05-28 =
+ * Tested on WooCommerce 8.9.1, PHP 8.1 and WordPress 6.5.3.
+ * Fix payment types compatibility.
+
= 1.4.7 - 2023-11-22 =
* Tested on WooCommerce 8.3.1, PHP 8.0 and WordPress 6.4.1.
* Add support for HPOS and Blocks.
diff --git a/classes/WC_Gateway_PayGate.php b/classes/WC_Gateway_PayGate.php
index 0078614..2202bb6 100644
--- a/classes/WC_Gateway_PayGate.php
+++ b/classes/WC_Gateway_PayGate.php
@@ -1,13 +1,13 @@
';
- const SCRIPT_TAG = '";';
- const SCRIPT_WIN_TOP_LOCAT_HREF = '';
+ const SCRIPT_WIN_TOP_LOCAT_HREF = '
HTML;
@@ -248,7 +238,7 @@ public function generate_paygate_form($order_id)
*
* @since 1.0.0
*/
- public function check_paygate_response()
+ public function check_paygate_response(): void
{
$this->logging ? self::$wc_logger->add('paygatepayweb', 'Redirect POST: ' . json_encode($_POST)) : '';
// Sanitise GET and POST arrays
@@ -256,11 +246,11 @@ public function check_paygate_response()
$get = $this->sanitizeFields($_GET);
// Only process if IPN is disabled
- if ( ! (isset($get['gid']) && isset($post[self::PAY_REQUEST_ID]))) {
+ if (!(isset($get['gid']) && isset($post[self::PAY_REQUEST_ID]))) {
die();
}
- if ( ! $order_id = $get['gid']) {
+ if (!$order_id = $get['gid']) {
wp_redirect(get_permalink(wc_get_page_id('myaccount')));
}
@@ -269,7 +259,7 @@ public function check_paygate_response()
}
$transient = get_transient('PAYGATE_PAYWEB_RED_' . $post[self::PAY_REQUEST_ID]);
- if($transient !== false) {
+ if ($transient !== false) {
exit();
}
set_transient('PAYGATE_PAYWEB_RED_' . $post[self::PAY_REQUEST_ID], $post[self::PAY_REQUEST_ID], 15);
@@ -281,7 +271,7 @@ public function check_paygate_response()
$status = isset($post[self::TRANSACTION_STATUS]) ? $post[self::TRANSACTION_STATUS] : "";
$reference = $this->getOrderReference($order);
- if ( ! $this->validateChecksum($post, $reference) && !$order->is_paid()) {
+ if (!$this->validateChecksum($post, $reference) && !$order->is_paid()) {
$order->update_status(self::PENDING, __('Checksum failed'));
exit();
}
@@ -309,7 +299,7 @@ public function check_paygate_response()
parse_str($response['body'], $parsed_response);
- if((int)$status === 1) {
+ if ((int)$status === 1) {
$this->vaultCard($parsed_response, $customer_id);
}
@@ -327,13 +317,11 @@ public function check_paygate_response()
*
* @since 1.0.0
*/
- public function check_paygate_notify_response()
+
+ public function check_paygate_notify_response(): void
{
// Log notify response for debugging purposes
- if($this->logging) {
- self::$wc_logger->add('paygatepayweb', 'Notify POST: ' . json_encode($_POST));
- self::$wc_logger->add('paygatepayweb', 'Notify GET: ' . json_encode($_GET));
- }
+ $this->logIPNRequest();
// Tell Paygate notify we have received
echo 'OK';
@@ -342,7 +330,7 @@ public function check_paygate_notify_response()
exit();
}
- if ( ! isset($_POST)) {
+ if (!isset($_POST)) {
exit();
}
@@ -375,24 +363,11 @@ public function check_paygate_notify_response()
}
// Verify security signature
- if ( ! $this->validateChecksumNotify($paygate_data)) {
- if($this->logging){
- self::$wc_logger->add('paygatepayweb', 'Failed to validate checksum with data ' . json_encode($paygate_data));
- }
- if ( ! $order->has_status(self::FAILED)) {
- $order->add_order_note('Failed Response via Notify, ' . $this->error_desc . self::BR);
- $order->update_status(self::PENDING, __('Checksum failed in notify'));
- }
- exit();
- } else {
- if($this->logging){
- self::$wc_logger->add('paygatepayweb', 'Validated checksum with data ' . json_encode($paygate_data));
- }
- }
+ $this->verifySecuritySignature($paygate_data, $order);
$customer_id = $order->get_customer_id();
- if((int)$paygate_data[self::TRANSACTION_STATUS] === 1) {
+ if ((int)$paygate_data[self::TRANSACTION_STATUS] === 1) {
$this->vaultCard($paygate_data, $customer_id);
}
@@ -400,9 +375,9 @@ public function check_paygate_notify_response()
exit();
}
- $transaction_id = isset($paygate_data[self::TRANSACTION_ID]) ? $paygate_data[self::TRANSACTION_ID] : "";
- $result_desc = isset($paygate_data[self::RESULT_DESC]) ? $paygate_data[self::RESULT_DESC] : "";
- $pay_request_id = isset($paygate_data[self::PAY_REQUEST_ID]) ? $paygate_data[self::PAY_REQUEST_ID] : "";
+ $transaction_id = $paygate_data[self::TRANSACTION_ID] ?? "";
+ $result_desc = $paygate_data[self::RESULT_DESC] ?? "";
+ $pay_request_id = $paygate_data[self::PAY_REQUEST_ID] ?? "";
switch ((int)$paygate_data[self::TRANSACTION_STATUS]) {
case 1:
@@ -420,8 +395,8 @@ public function check_paygate_notify_response()
exit;
break;
default:
- if ( ! $order->has_status(self::PENDING)) {
- if($this->logging){
+ if (!$order->has_status(self::PENDING)) {
+ if ($this->logging) {
self::$wc_logger->add('paygatepayweb', 'Reached default in switch statement');
}
$order->add_order_note(
@@ -442,7 +417,7 @@ public function check_paygate_notify_response()
*
* @return mixed
*/
- public function paywebQuery($payRequestId, $order)
+ public function paywebQuery($payRequestId, $order): mixed
{
$reference = $this->getOrderReference($order);
@@ -478,9 +453,9 @@ public function paywebQuery($payRequestId, $order)
*/
public function paywebQueryText($response, $payRequestId)
{
- $transactionStatus = ! empty($response[self::TRANSACTION_STATUS]) ? $response[self::TRANSACTION_STATUS] : 'Null';
- $resultCode = ! empty($response[self::RESULT_CODE]) ? $response[self::RESULT_CODE] : 'Null';
- $resultDesc = ! empty($response[self::RESULT_DESC]) ? $response[self::RESULT_DESC] : 'Null';
+ $transactionStatus = !empty($response[self::TRANSACTION_STATUS]) ? $response[self::TRANSACTION_STATUS] : 'Null';
+ $resultCode = !empty($response[self::RESULT_CODE]) ? $response[self::RESULT_CODE] : 'Null';
+ $resultDesc = !empty($response[self::RESULT_DESC]) ? $response[self::RESULT_DESC] : 'Null';
return <<