Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions class-gf-paystack-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public function log_transaction_success($reference)
'transaction_reference' => $reference
];

$this->send_request(
'log/charge_success',
$params,
'post',
'https://plugin-tracker.paystackintegrations.com/'
);
// Usage tracking must never block a paid customer from reaching the confirmation page.
try {
$this->send_request(
'log/charge_success',
$params,
'post',
'https://plugin-tracker.paystackintegrations.com/'
);
} catch (\Throwable $e) {
error_log(__METHOD__ . '(): plugin tracker request failed: ' . $e->getMessage());
}
}

/**
Expand Down Expand Up @@ -80,7 +85,7 @@ public function send_request(

$body = json_decode($res['body'], true);

if ($body !== null) {
if (is_array($body)) {
error_log(__METHOD__ . '(): ' . strtoupper($method) . ' ' . $uri . ' status: ' . (isset($body['status']) ? var_export($body['status'], true) : 'unknown'));

if (isset($body['error']) || $body['status'] == false) {
Expand Down
4 changes: 2 additions & 2 deletions paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: https://paystack.com/docs/libraries-and-plugins/plugins#wordpress
0
Description: Integrates Gravity Forms with Paystack, enabling customers to pay for goods and services through Gravity Forms.
Version: 2.0.8
Version: 2.0.9
Author: Paystack
Author URI: https://developers.paystack.com
License: GPL-2.0+
Expand All @@ -31,7 +31,7 @@

defined('ABSPATH') || die();

define('GF_PAYSTACK_VERSION', '2.0.8');
define('GF_PAYSTACK_VERSION', '2.0.9');

require_once __DIR__ . '/includes/php-advisory.php';
add_action('admin_notices', 'gf_paystack_php_advisory_notice');
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: payments, subscriptions, gravityforms
Requires at least: 5.1
Tested up to: 7.1
Requires PHP: 7.2
Stable tag: 2.0.8
Stable tag: 2.0.9
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -54,6 +54,9 @@ Yes you can! Join in on our [GitHub repository](https://github.com/PaystackHQ/pl

== Changelog ==

= 2.0.9 - October 28, 2026 =
* Fixed a fatal error on the confirmation page after a successful payment when the usage tracking service is unreachable.

= 2.0.8 - October 27, 2026 =
* Security: hardened webhook and payment verification. Props k2sobot.
* Security: API credentials and response bodies are no longer written to the PHP error log, and the API secret key is only sent to the Paystack API.
Expand Down Expand Up @@ -92,6 +95,9 @@ Yes you can! Join in on our [GitHub repository](https://github.com/PaystackHQ/pl

== Upgrade Notice ==

= 2.0.9 =
* Fixes a fatal error customers could see after paying. Please update.

= 2.0.8 =
* Security update — please update now. After updating, rotate your live and test secret keys in the Paystack Dashboard and delete old PHP and WordPress debug log files, as earlier versions logged API request details. Ask your host to run PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 or later.

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function gf_paystack_exception_message($callback)
{
try {
$callback();
} catch (\Exception $e) {
} catch (\Throwable $e) {
return $e->getMessage();
}

Expand Down
23 changes: 23 additions & 0 deletions tests/test-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,26 @@
$log_api->log_transaction_success('gf-7-abc');
$tracker_call = $GLOBALS['gf_paystack_test_remote_calls'][0];
gf_paystack_test_check(strpos($tracker_call[0], 'plugin-tracker') !== false && !isset($tracker_call[1]['headers']['Authorization']), 'send_request headers case 1');

$GLOBALS['gf_paystack_test_remote_response'] = array('response' => array('code' => 530), 'body' => 'error code: 1016');
$tracker_thrown = gf_paystack_exception_message(function () use ($log_api) {
$log_api->log_transaction_success('gf-7-abc');
});
gf_paystack_test_check($tracker_thrown === '', 'log_transaction_success case 1: non-JSON tracker response does not throw');

$GLOBALS['gf_paystack_test_remote_response'] = new WP_Error('http_request_failed', 'cURL error 6: Could not resolve host');
$tracker_thrown = gf_paystack_exception_message(function () use ($log_api) {
$log_api->log_transaction_success('gf-7-abc');
});
gf_paystack_test_check($tracker_thrown === '', 'log_transaction_success case 2: tracker transport error does not throw');

$GLOBALS['gf_paystack_test_remote_response'] = array('body' => json_encode('error'));
$tracker_thrown = gf_paystack_exception_message(function () use ($log_api) {
$log_api->log_transaction_success('gf-7-abc');
});
gf_paystack_test_check($tracker_thrown === '', 'log_transaction_success case 3: JSON scalar tracker response does not throw');
$scalar_thrown = gf_paystack_exception_message(function () use ($log_api) {
$log_api->send_request('transaction/verify/abc', array(), 'get');
});
gf_paystack_test_check(strpos($scalar_thrown, 'issue connecting') !== false, 'send_request case: JSON scalar response throws the generic Exception');
$GLOBALS['gf_paystack_test_remote_response'] = array('body' => json_encode(array('status' => true)));
Loading