Skip to content

Commit 66f6b4e

Browse files
tubiztiku-paystacktolu-paystack
authored
Version 5.6.3 release (#26)
Co-authored-by: Tiku Okoye <tiku@paystack.com> Co-authored-by: Tiku <57668978+tiku-paystack@users.noreply.github.com> Co-authored-by: tolu-paystack <60101507+tolu-paystack@users.noreply.github.com> Co-authored-by: tolu-paystack <tolu@paystack.com>
1 parent d6f6a11 commit 66f6b4e

16 files changed

Lines changed: 187 additions & 1033 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.idea

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
**Tested up to:** 5.4
1212

13-
**Stable tag:** 5.6.2
13+
**Stable tag:** 5.6.3
1414

1515
**License:** GPLv2 or later
1616

@@ -103,7 +103,7 @@ You can also follow me on Twitter! **[@tubiz](https://twitter.com/tubiz)**
103103

104104

105105
### Configure the plugin
106-
To configure the plugin, go to __WooCommerce > Settings__ from the left hand menu, then click __Checkout__ from the top tab. You will see __Paystack__ as part of the available Checkout Options. Click on it to configure the payment gateway.
106+
To configure the plugin, go to __WooCommerce > Settings__ from the left hand menu, then click __Checkout__ from the top tab. You will see __Paystack__ as part of the available Checkout Options. Click on it to configure the payment gateway.
107107

108108
* __Enable/Disable__ - check the box to enable Paystack Payment Gateway.
109109
* __Title__ - allows you to determine what your customers will see this payment option as on the checkout page.
@@ -145,80 +145,91 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
145145

146146
## Changelog
147147

148-
### 5.6.2 - March 12, 2020 =
148+
### 5.6.3 - July 27, 2020
149+
* New: Add support for ZAR as an accepted currency.
150+
* New: Add setting to remove "Cancel order & restore cart" button.
151+
* New: Minimum PHP version: 5.6
152+
* New: Minimum WooCommerce supported version: 3.0.0
153+
* Misc: Add icon for Ghanaian payment methods to checkout.
154+
* Misc: Remove GBP as an accepted currency.
155+
* Fix: Cart not fully cleared after successful payment.
156+
* Fix: Selected payment icons not displayed on custom gateways settings page.
157+
* Tweak: WooCommerce 4.3 compatibility.
158+
159+
### 5.6.2 - March 12, 2020
149160
* Update: WooCommerce 4.0 compatibility.
150161

151-
### 5.6.1 - November 13, 2019 ###
162+
### 5.6.1 - November 13, 2019
152163
* Update: WooCommerce 3.8 compatibility.
153164

154-
### 5.6.0 - August 7, 2019 ###
165+
### 5.6.0 - August 7, 2019
155166
* New: Support for refunds via Paystack from the order details screen.
156167
* New: Log successful transaction to Paystack metrics tracker.
157168
* New: Add support for sending additional order details to Paystack when making payment using a saved card.
158169
* New: Add support for sending additional order details to Paystack when a subscription payment is renewed.
159170
* Update: WC 3.7 compatibility.
160171

161-
### 5.5.0 - May 27, 2019 =
172+
### 5.5.0 - May 27, 2019
162173
* Misc: Renamed Diamond Bank to Access Bank (Diamond)
163174
* Tweak: Significant cleanup of code formatting and adherence of WordPress coding standards
164175
* New: Support for translation
165176

166-
### 5.4.2 - February 13, 2019 =
177+
### 5.4.2 - February 13, 2019
167178
* Misc: Remove Paystack fee and Paystack payout amount on the order details page
168179

169-
### 5.4.1 - February 1, 2019 ###
180+
### 5.4.1 - February 1, 2019
170181
* Fix: Split payment not working properly when the split payment transaction charge setting field is empty
171182

172-
### 5.4.0 - December 9, 2018 ###
183+
### 5.4.0 - December 9, 2018
173184
* New: Add support for Paystack split payments
174185
* New: Display Paystack fee and Paystack payout amount on the order details page
175186
* Misc: Add support for WooCommerce 3.5
176187
* Misc: Renamed Skye Bank Plc to Polaris Bank Limited
177188
* Misc: Add new banks (ALAT by WEMA, ASO Savings and Loans, MainStreet Bank & Ekondo Microfinance Bank) to Allowed Banks Card list
178189
* Misc: Add new banks logos (ALAT by WEMA, ASO Savings and Loans, MainStreet Bank & Ekondo Microfinance Bank) to Payment Icons list
179190

180-
### 5.3.1 - July 26, 2018 ###
191+
### 5.3.1 - July 26, 2018
181192
* Fix: The bank payment channel not showing in the default gateway
182193

183-
### 5.3.0 - June 2, 2018 =
194+
### 5.3.0 - June 2, 2018
184195
* Fix: Saved cards feature not working in the custom gateways
185196
* Fix: Custom gateways not processing automatic renewal payments via WooCommerce Subscriptions plugin
186197

187-
### 5.2.1 - June 1, 2018 =
198+
### 5.2.1 - June 1, 2018
188199
* Misc: Add support for WooCommerce 3.4
189200

190-
### 5.2.0 - May 18, 2018 ###
201+
### 5.2.0 - May 18, 2018
191202
* New: Add support for multiple subscriptions purchase using WooCommerce Subscriptions plugin
192203
* Fix: Deprecated functions in the Tbz_WC_Gateway_Paystack_Subscription class
193204

194-
### 5.1.0 - March 27, 2018 ###
205+
### 5.1.0 - March 27, 2018
195206
* New: Add support for GHS (Ghanaian cedi) currency
196207
* Fix: Deprecated WooCommerce 2.X functions
197208

198-
### 5.0.2 - September 15, 2017 ###
209+
### 5.0.2 - September 15, 2017
199210
* Fix: Illegal string offset warnings when plugin is newly installed
200211

201-
### 5.0.1 - September 14, 2017 ###
212+
### 5.0.1 - September 14, 2017
202213
* Fix: Fatal error on the checkout page if WooCommerce 2.6.14 and below is installed
203214

204-
### 5.0.0 - August 29, 2017 ###
215+
### 5.0.0 - August 29, 2017
205216
* New: Add support for Paystack custom filters
206217
* New: Create additional Paystack gateways (max of 5) using different custom filters. You can create a gateway that accepts only Verve cards, a gateway that accepts only bank account payments, a gateway that accepts only GTB issued Mastercard.
207218

208-
### 4.1.0 - July 7, 2017 ###
219+
### 4.1.0 - July 7, 2017
209220
* Fix: Deprecated WooCommerce 2.X functions
210221

211-
### 4.0.1 - April 10, 2017 ###
222+
### 4.0.1 - April 10, 2017
212223
* Fix: Fatal error if WooCommerce 2.6.14 and below is installed
213224

214-
### 4.0.0 - April 10, 2017 ###
225+
### 4.0.0 - April 10, 2017
215226
* New: Add support for Paystack Inline Embed.
216227
* New: Add support for sending additional order details to Paystack
217228

218-
### 3.1.1 - February 13, 2017 ###
229+
### 3.1.1 - February 13, 2017
219230
* New: Changed Paystack payment methods icon.
220231

221-
### 3.1.0 - January 10, 2017 ###
232+
### 3.1.0 - January 10, 2017
222233
* New: Add support for USD and GBP currency. Note this has to be enabled by Paystack for your account before it can be used on your site.
223234

224235
### 3.0.0 - November 11, 2016
@@ -245,8 +256,8 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
245256

246257
## Upgrade Notice
247258

248-
### 5.6.2 ###
249-
* WooCommerce 4.0 compatibility.
259+
### 5.6.3 ###
260+
* Fixes.
250261

251262
## Screenshots ##
252263

@@ -272,4 +283,4 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
272283

273284
### 5. Manage saved cards from your account page
274285
###
275-
![Screenshot 5](https://github.com/tubiz/woo-paystack/blob/master/assets/images/screenshot-5.png)
286+
![Screenshot 5](https://github.com/tubiz/woo-paystack/blob/master/assets/images/screenshot-5.png)

assets/images/paystack-gh.png

25.9 KB
Loading

assets/js/paystack-admin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jQuery( function( $ ) {
7777

7878
$( ".wc-paystack-payment-icons" ).select2( {
7979
templateResult: formatPaystackPaymentIcons,
80-
templateSelection: formatPaystackPaymentIcons
80+
templateSelection: formatPaystackPaymentIconDisplay
8181
} );
8282

8383
}
@@ -87,12 +87,18 @@ jQuery( function( $ ) {
8787
if ( !payment_method.id ) {
8888
return payment_method.text;
8989
}
90+
9091
var $payment_method = $(
9192
'<span><img src=" ' + wc_paystack_admin_params.plugin_url + '/assets/images/' + payment_method.element.value.toLowerCase() + '.png" class="img-flag" style="height: 15px; weight:18px;" /> ' + payment_method.text + '</span>'
9293
);
94+
9395
return $payment_method;
9496
};
9597

98+
function formatPaystackPaymentIconDisplay( payment_method ) {
99+
return payment_method.text;
100+
};
101+
96102
wc_paystack_admin.init();
97103

98104
} );

assets/js/paystack-admin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-wc-gateway-custom-paystack.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public function init_form_fields() {
4646
'embed' => __( 'Inline Embed', 'woo-paystack' ),
4747
),
4848
),
49+
'remove_cancel_order_button' => array(
50+
'title' => __( 'Remove Cancel Order & Restore Cart Button', 'woo-paystack' ),
51+
'label' => __( 'Remove the cancel order & restore cart button on the pay for order page', 'woo-paystack' ),
52+
'type' => 'checkbox',
53+
'description' => '',
54+
'default' => 'no',
55+
),
4956
'split_payment' => array(
5057
'title' => __( 'Split Payment', 'woo-paystack' ),
5158
'label' => __( 'Enable Split Payment', 'woo-paystack' ),
@@ -345,7 +352,8 @@ public function payment_icons() {
345352
'mastercard' => __( 'Mastercard', 'woo-paystack' ),
346353
'paystackwhite' => __( 'Secured by Paystack White', 'woo-paystack' ),
347354
'paystackblue' => __( 'Secured by Paystack Blue', 'woo-paystack' ),
348-
'paystack-wc' => __( 'Paystack', 'woo-paystack' ),
355+
'paystack-wc' => __( 'Paystack Nigeria', 'woo-paystack' ),
356+
'paystack-gh' => __( 'Paystack Ghana', 'woo-paystack' ),
349357
'access' => __( 'Access Bank', 'woo-paystack' ),
350358
'alat' => __( 'ALAT by WEMA', 'woo-paystack' ),
351359
'aso' => __( 'ASO Savings and Loans', 'woo-paystack' ),

includes/class-wc-gateway-paystack.php

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class WC_Gateway_Paystack extends WC_Payment_Gateway_CC {
6262
*/
6363
public $split_payment;
6464

65+
/**
66+
* Should the cancel & remove order button be removed on the pay for order page.
67+
*
68+
* @var bool
69+
*/
70+
public $remove_cancel_order_button;
71+
6572
/**
6673
* Paystack sub account code.
6774
*
@@ -199,10 +206,11 @@ public function __construct() {
199206

200207
$this->saved_cards = $this->get_option( 'saved_cards' ) === 'yes' ? true : false;
201208

202-
$this->split_payment = $this->get_option( 'split_payment' ) === 'yes' ? true : false;
203-
$this->subaccount_code = $this->get_option( 'subaccount_code' );
204-
$this->charges_account = $this->get_option( 'split_payment_charge_account' );
205-
$this->transaction_charges = $this->get_option( 'split_payment_transaction_charge' );
209+
$this->split_payment = $this->get_option( 'split_payment' ) === 'yes' ? true : false;
210+
$this->remove_cancel_order_button = $this->get_option( 'remove_cancel_order_button' ) === 'yes' ? true : false;
211+
$this->subaccount_code = $this->get_option( 'subaccount_code' );
212+
$this->charges_account = $this->get_option( 'split_payment_charge_account' );
213+
$this->transaction_charges = $this->get_option( 'split_payment_transaction_charge' );
206214

207215
$this->custom_metadata = $this->get_option( 'custom_metadata' ) === 'yes' ? true : false;
208216

@@ -250,9 +258,9 @@ public function __construct() {
250258
*/
251259
public function is_valid_for_use() {
252260

253-
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'GBP', 'GHS' ) ) ) ) {
261+
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'ZAR', 'GHS' ) ) ) ) {
254262

255-
$this->msg = sprintf( __( 'Paystack does not support your store currency. Kindly set it to either NGN (&#8358), GHS (&#x20b5;), USD (&#36;) or GBP (&#163;) <a href="%s">here</a>', 'woo-paystack' ), admin_url( 'admin.php?page=wc-settings&tab=general' ) );
263+
$this->msg = sprintf( __( 'Paystack does not support your store currency. Kindly set it to either NGN (&#8358), GHS (&#x20b5;), USD (&#36;) or ZAR (R) <a href="%s">here</a>', 'woo-paystack' ), admin_url( 'admin.php?page=wc-settings&tab=general' ) );
256264

257265
return false;
258266

@@ -267,7 +275,13 @@ public function is_valid_for_use() {
267275
*/
268276
public function get_icon() {
269277

270-
$icon = '<img src="' . WC_HTTPS::force_https_url( plugins_url( 'assets/images/paystack-wc.png', WC_PAYSTACK_MAIN_FILE ) ) . '" alt="cards" />';
278+
$base_location = wc_get_base_location();
279+
280+
if ( 'GH' === $base_location['country'] ) {
281+
$icon = '<img src="' . WC_HTTPS::force_https_url( plugins_url( 'assets/images/paystack-gh.png', WC_PAYSTACK_MAIN_FILE ) ) . '" alt="Paystack Payment Options" />';
282+
} else {
283+
$icon = '<img src="' . WC_HTTPS::force_https_url( plugins_url( 'assets/images/paystack-wc.png', WC_PAYSTACK_MAIN_FILE ) ) . '" alt="Paystack Payment Options" />';
284+
}
271285

272286
return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );
273287

@@ -421,6 +435,13 @@ public function init_form_fields() {
421435
'description' => __( 'Enter your Live Public Key here.', 'woo-paystack' ),
422436
'default' => '',
423437
),
438+
'remove_cancel_order_button' => array(
439+
'title' => __( 'Remove Cancel Order & Restore Cart Button', 'woo-paystack' ),
440+
'label' => __( 'Remove the cancel order & restore cart button on the pay for order page', 'woo-paystack' ),
441+
'type' => 'checkbox',
442+
'description' => '',
443+
'default' => 'no',
444+
),
424445
'split_payment' => array(
425446
'title' => __( 'Split Payment', 'woo-paystack' ),
426447
'label' => __( 'Enable Split Payment', 'woo-paystack' ),
@@ -939,7 +960,7 @@ function_exists( 'wc_reduce_stock_levels' ) ? wc_reduce_stock_levels( $order_id
939960

940961
$this->save_subscription_payment_token( $order_id, $paystack_response );
941962

942-
wc_empty_cart();
963+
WC()->cart->empty_cart();
943964

944965
return true;
945966

@@ -997,14 +1018,21 @@ public function receipt_page( $order_id ) {
9971018

9981019
echo '<div id="paystackWooCommerceEmbedContainer"></div>';
9991020

1000-
echo '<div id="paystack_form"><form id="order_review" method="post" action="' . WC()->api_request_url( 'WC_Gateway_Paystack' ) . '"></form>
1001-
<a href="' . esc_url( $order->get_cancel_order_url() ) . '" style="text-align:center; color: #EF3315; display: block; outline: none;">' . __( 'Cancel order &amp; restore cart', 'woo-paystack' ) . '</a></div>';
1021+
echo '<div id="paystack_form"><form id="order_review" method="post" action="' . WC()->api_request_url( 'WC_Gateway_Paystack' ) . '"></form>';
1022+
1023+
if ( ! $this->remove_cancel_order_button ) {
1024+
echo '<a href="' . esc_url( $order->get_cancel_order_url() ) . '" style="text-align:center; color: #ef3315; display: block; outline: none;">' . __( 'Cancel order &amp; restore cart', 'woo-paystack' ) . '</a></div>';
1025+
}
10021026

10031027
} else {
10041028

10051029
echo '<p>' . __( 'Thank you for your order, please click the button below to pay with Paystack.', 'woo-paystack' ) . '</p>';
10061030

1007-
echo '<div id="paystack_form"><form id="order_review" method="post" action="' . WC()->api_request_url( 'WC_Gateway_Paystack' ) . '"></form><button class="button alt" id="paystack-payment-button">' . __( 'Pay Now', 'woo-paystack' ) . '</button> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', 'woo-paystack' ) . '</a></div>';
1031+
echo '<div id="paystack_form"><form id="order_review" method="post" action="' . WC()->api_request_url( 'WC_Gateway_Paystack' ) . '"></form><button class="button alt" id="paystack-payment-button">' . __( 'Pay Now', 'woo-paystack' ) . '</button>';
1032+
1033+
if ( ! $this->remove_cancel_order_button ) {
1034+
echo ' <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', 'woo-paystack' ) . '</a></div>';
1035+
}
10081036

10091037
}
10101038

@@ -1115,7 +1143,7 @@ function_exists( 'wc_reduce_stock_levels' ) ? wc_reduce_stock_levels( $order_id
11151143

11161144
$this->save_card_details( $paystack_response, $order->get_user_id(), $order_id );
11171145

1118-
wc_empty_cart();
1146+
WC()->cart->empty_cart();
11191147

11201148
} else {
11211149

@@ -1220,7 +1248,7 @@ function_exists( 'wc_reduce_stock_levels' ) ? wc_reduce_stock_levels( $order_id
12201248

12211249
wc_add_notice( $notice, $notice_type );
12221250

1223-
wc_empty_cart();
1251+
WC()->cart->empty_cart();
12241252

12251253
} else {
12261254

@@ -1250,7 +1278,7 @@ function_exists( 'wc_reduce_stock_levels' ) ? wc_reduce_stock_levels( $order_id
12501278

12511279
$order->add_order_note( sprintf( __( 'Payment via Paystack successful (Transaction Reference: %s)', 'woo-paystack' ), $paystack_ref ) );
12521280

1253-
wc_empty_cart();
1281+
WC()->cart->empty_cart();
12541282

12551283
}
12561284
}

0 commit comments

Comments
 (0)