Skip to content

Commit a34c22b

Browse files
authored
Version 5.7.6 Release (#84)
1 parent f27efbc commit a34c22b

3 files changed

Lines changed: 66 additions & 20 deletions

File tree

includes/class-wc-gateway-paystack.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,9 +1621,9 @@ public function get_custom_fields( $order_id ) {
16211621
/**
16221622
* Process a refund request from the Order details screen.
16231623
*
1624-
* @param int $order_id WC Order ID.
1625-
* @param null $amount WC Order Amount.
1626-
* @param string $reason Refund Reason
1624+
* @param int $order_id WC Order ID.
1625+
* @param float|null $amount Refund Amount.
1626+
* @param string $reason Refund Reason
16271627
*
16281628
* @return bool|WP_Error
16291629
*/
@@ -1658,8 +1658,17 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
16581658
'merchant_note' => $merchant_note,
16591659
);
16601660

1661-
$args['body'] = $body;
1662-
$refund_url = 'https://api.paystack.co/refund';
1661+
$headers = array(
1662+
'Authorization' => 'Bearer ' . $this->secret_key,
1663+
);
1664+
1665+
$args = array(
1666+
'headers' => $headers,
1667+
'timeout' => 60,
1668+
'body' => $body,
1669+
);
1670+
1671+
$refund_url = 'https://api.paystack.co/refund';
16631672

16641673
$refund_request = wp_remote_post( $refund_url, $args );
16651674

readme.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://bosun.me/donate
44
Tags: paystack, woocommerce, payment gateway, tubiz plugins, verve, ghana, kenya, nigeria, south africa, naira, cedi, rand, mastercard, visa
55
Requires at least: 5.8
66
Tested up to: 6.2
7-
Stable tag: 5.7.5
7+
Stable tag: 5.7.6
88
Requires PHP: 7.4
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -123,6 +123,11 @@ If you do not find Paystack on the Payment method options, please go through the
123123

124124
== Changelog ==
125125

126+
= 5.7.6 - June 20, 2023 =
127+
* New: Minimum WooCommerce supported version: 7.0
128+
* Fix: Unable to process refund on the view order screen
129+
* Improve: Paystack test mode notice will now be displayed in the WooCommerce Admin Notes Inbox
130+
126131
= 5.7.5 - May 22, 2023 =
127132
* Update: Add support for EGP as an accepted currency
128133
* Update: Update icon for Kenyan payment methods

woo-paystack.php

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@
33
* Plugin Name: Paystack WooCommerce Payment Gateway
44
* Plugin URI: https://paystack.com
55
* Description: WooCommerce payment gateway for Paystack
6-
* Version: 5.7.5
6+
* Version: 5.7.6
77
* Author: Tunbosun Ayinla
88
* Author URI: https://bosun.me
99
* License: GPL-2.0+
1010
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11-
* WC requires at least: 6.1
12-
* WC tested up to: 7.7
11+
* WC requires at least: 7.0
12+
* WC tested up to: 7.8
1313
* Text Domain: woo-paystack
1414
* Domain Path: /languages
1515
*/
1616

17+
use Automattic\WooCommerce\Admin\Notes\Note;
18+
use Automattic\WooCommerce\Admin\Notes\Notes;
19+
1720
if ( ! defined( 'ABSPATH' ) ) {
1821
exit;
1922
}
2023

2124
define( 'WC_PAYSTACK_MAIN_FILE', __FILE__ );
2225
define( 'WC_PAYSTACK_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) );
2326

24-
define( 'WC_PAYSTACK_VERSION', '5.7.5' );
27+
define( 'WC_PAYSTACK_VERSION', '5.7.6' );
2528

2629
/**
2730
* Initialize Paystack WooCommerce payment gateway.
@@ -35,7 +38,7 @@ function tbz_wc_paystack_init() {
3538
return;
3639
}
3740

38-
add_action( 'admin_notices', 'tbz_wc_paystack_testmode_notice' );
41+
add_action( 'admin_init', 'tbz_wc_paystack_testmode_notice' );
3942

4043
require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paystack.php';
4144

@@ -145,21 +148,50 @@ function tbz_wc_paystack_wc_missing_notice() {
145148
**/
146149
function tbz_wc_paystack_testmode_notice() {
147150

148-
if ( ! current_user_can( 'manage_options' ) ) {
151+
if ( ! class_exists( Notes::class ) ) {
152+
return;
153+
}
154+
155+
if ( ! class_exists( WC_Data_Store::class ) ) {
156+
return;
157+
}
158+
159+
if ( ! method_exists( Notes::class, 'get_note_by_name' ) ) {
160+
return;
161+
}
162+
163+
$test_mode_note = Notes::get_note_by_name( 'paystack-test-mode' );
164+
165+
if ( false !== $test_mode_note ) {
149166
return;
150167
}
151168

152169
$paystack_settings = get_option( 'woocommerce_paystack_settings' );
153-
$test_mode = isset( $paystack_settings['testmode'] ) ? $paystack_settings['testmode'] : '';
170+
$test_mode = $paystack_settings['testmode'] ?? '';
171+
172+
if ( 'yes' !== $test_mode ) {
173+
Notes::delete_notes_with_name( 'paystack-test-mode' );
154174

155-
if ( 'yes' === $test_mode ) {
156-
/* translators: 1. Paystack settings page URL link. */
157-
echo '<div class="error"><p>' . sprintf( __( 'Paystack test mode is still enabled, Click <strong><a href="%s">here</a></strong> to disable it when you want to start accepting live payment on your site.', 'woo-paystack' ), esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout&section=paystack' ) ) ) . '</p></div>';
175+
return;
158176
}
177+
178+
$note = new Note();
179+
$note->set_title( __( 'Paystack test mode enabled', 'woo-paystack' ) );
180+
$note->set_content( __( 'Paystack test mode is currently enabled. Remember to disable it when you want to start accepting live payment on your site.', 'woo-paystack' ) );
181+
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
182+
$note->set_layout( 'plain' );
183+
$note->set_is_snoozable( false );
184+
$note->set_name( 'paystack-test-mode' );
185+
$note->set_source( 'woo-paystack' );
186+
$note->add_action( 'disable-paystack-test-mode', __( 'Disable Paystack test mode', 'woo-paystack' ), admin_url( 'admin.php?page=wc-settings&tab=checkout&section=paystack' ) );
187+
$note->save();
159188
}
160189

161-
add_action( 'before_woocommerce_init', function () {
162-
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
163-
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
190+
add_action(
191+
'before_woocommerce_init',
192+
function () {
193+
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
194+
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
195+
}
164196
}
165-
} );
197+
);

0 commit comments

Comments
 (0)