Skip to content

Commit bdfe67a

Browse files
committed
Version 3.1.0
1 parent 1b36da4 commit bdfe67a

8 files changed

Lines changed: 104 additions & 54 deletions

File tree

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Paystack WooCommerce Payment Gateway
2+
23
**Contributors:** tubiz
4+
35
**Donate link:** http://bosun.me/donate
6+
47
**Tags:** paystack, woocommerce, payment gateway, interswitch, tubiz plugins, verve, nigeria, mastercard, visa
8+
59
**Requires at least:** 4.4
6-
**Tested up to:** 4.6
7-
**Stable tag:** 3.0.0
10+
11+
**Tested up to:** 4.7
12+
13+
**Stable tag:** 3.1.0
14+
815
**License:** GPLv2 or later
16+
917
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
1018

1119
Paystack WooCommerce Payment Gateway allows you to accept online payments from local and international customers
@@ -133,6 +141,8 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
133141

134142
## Changelog
135143

144+
### 3.1.0, January 10, 2017 ###
145+
* 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.
136146

137147
### 3.0.0, November 11, 2016
138148
* New: Add support for recurring payment using [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) plugin.
@@ -163,9 +173,8 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
163173

164174
## Upgrade Notice
165175

166-
167-
### 3.0.0
168-
* Add support for recurring payment using WooCommerce Subscriptions plugin
176+
### 3.1.0
177+
* 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.
169178

170179

171180

assets/js/paystack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jQuery( function( $ ) {
4343
email: wc_paystack_params.email,
4444
amount: wc_paystack_params.amount,
4545
ref: wc_paystack_params.txnref,
46+
currency: wc_paystack_params.currency,
4647
callback: paystack_callback,
4748
onClose: function() {
4849
$( this.el ).unblock();

assets/js/paystack.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-paystack-deprecated.php

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public function __construct() {
6161
*/
6262
public function is_valid_for_use() {
6363

64-
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN','USD','GBP') ) ) ) {
64+
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'GBP' ) ) ) ) {
6565

66-
$this->msg = 'Paystack does not support your store currency. Kindly set it to Nigerian Naira &#8358; <a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '">here</a>';
66+
$this->msg = 'Paystack does not support your store currency. Kindly set it to either NGN (&#8358), USD (&#36;) or GBP (&#163;) <a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '">here</a>';
6767

6868
return false;
6969

@@ -111,8 +111,11 @@ public function is_available() {
111111
if ( $this->enabled == "yes" ) {
112112

113113
if ( ! ( $this->public_key && $this->secret_key ) ) {
114+
114115
return false;
116+
115117
}
118+
116119
return true;
117120
}
118121

@@ -235,9 +238,12 @@ public function payment_scripts() {
235238
$txnref = $order_id . '_' .time();
236239

237240
if ( $order->id == $order_id && $order->order_key == $order_key ) {
238-
$paystack_params['email'] = $email;
239-
$paystack_params['amount'] = $amount;
240-
$paystack_params['txnref'] = $txnref;
241+
242+
$paystack_params['email'] = $email;
243+
$paystack_params['amount'] = $amount;
244+
$paystack_params['txnref'] = $txnref;
245+
$paystack_params['currency'] = get_woocommerce_currency();
246+
241247
}
242248

243249
update_post_meta( $order_id, '_paystack_txn_ref', $txnref );
@@ -307,25 +313,29 @@ public function verify_paystack_transaction() {
307313

308314
if ( 'success' == $paystack_response->data->status ) {
309315

310-
$order_details = explode( '_', $paystack_response->data->reference );
316+
$order_details = explode( '_', $paystack_response->data->reference );
311317

312-
$order_id = (int) $order_details[0];
318+
$order_id = (int) $order_details[0];
313319

314-
$order = wc_get_order($order_id);
320+
$order = wc_get_order($order_id);
315321

316322
if ( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ) ) ) {
317323
wp_redirect( $this->get_return_url( $order ) );
318324
exit;
319325
}
320326

321-
$order_total = $order->get_total();
327+
$order_total = $order->get_total();
328+
329+
$order_currency = $order->get_order_currency();
330+
331+
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
322332

323-
$amount_paid = $paystack_response->data->amount / 100;
333+
$amount_paid = $paystack_response->data->amount / 100;
324334

325-
$paystack_ref = $paystack_response->data->reference;
335+
$paystack_ref = $paystack_response->data->reference;
326336

327337
// check if the amount paid is equal to the order amount.
328-
if ( $order_total != $amount_paid ) {
338+
if ( $amount_paid < $order_total ) {
329339

330340
$order->update_status( 'on-hold', '' );
331341

@@ -338,15 +348,15 @@ public function verify_paystack_transaction() {
338348
$order->add_order_note( $notice, 1 );
339349

340350
// Add Admin Order Note
341-
$order->add_order_note('<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>&#8358;'.$amount_paid.'</strong> while the total order amount is <strong>&#8358;'.$order_total.'</strong><br />Paystack Transaction Reference: '.$paystack_ref );
351+
$order->add_order_note( '<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>'. $currency_symbol . $amount_paid . '</strong> while the total order amount is <strong>'. $currency_symbol . $order_total . '</strong><br />Paystack Transaction Reference: '.$paystack_ref );
342352

343353
$order->reduce_order_stock();
344354

345355
wc_add_notice( $notice, $notice_type );
346356

347357
wc_empty_cart();
348-
}
349-
else {
358+
359+
} else {
350360

351361
$order->payment_complete( $paystack_ref );
352362

@@ -355,8 +365,7 @@ public function verify_paystack_transaction() {
355365
wc_empty_cart();
356366
}
357367

358-
}
359-
else {
368+
} else {
360369

361370
$order_details = explode( '_', $_REQUEST['paystack_txnref'] );
362371

@@ -419,14 +428,18 @@ public function process_webhooks() {
419428
exit;
420429
}
421430

422-
$order_total = $order->get_total();
431+
$order_currency = $order->get_order_currency();
432+
433+
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
423434

424-
$amount_paid = $event->data->amount / 100;
435+
$order_total = $order->get_total();
425436

426-
$paystack_ref = $event->data->reference;
437+
$amount_paid = $event->data->amount / 100;
438+
439+
$paystack_ref = $event->data->reference;
427440

428441
// check if the amount paid is equal to the order amount.
429-
if ( $order_total != $amount_paid ) {
442+
if ( $amount_paid < $order_total ) {
430443

431444
$order->update_status( 'on-hold', '' );
432445

@@ -439,15 +452,15 @@ public function process_webhooks() {
439452
$order->add_order_note( $notice, 1 );
440453

441454
// Add Admin Order Note
442-
$order->add_order_note('<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>&#8358;'.$amount_paid.'</strong> while the total order amount is <strong>&#8358;'.$order_total.'</strong><br />Paystack Transaction Reference: '.$paystack_ref );
455+
$order->add_order_note( '<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>'. $currency_symbol . $amount_paid . '</strong> while the total order amount is <strong>'. $currency_symbol . $order_total . '</strong><br />Paystack Transaction Reference: '.$paystack_ref );
443456

444457
$order->reduce_order_stock();
445458

446459
wc_add_notice( $notice, $notice_type );
447460

448461
wc_empty_cart();
449-
}
450-
else {
462+
463+
} else {
451464

452465
$order->payment_complete( $paystack_ref );
453466

includes/class-paystack.php

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public function __construct() {
7676
*/
7777
public function is_valid_for_use() {
7878

79-
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN','USD','GBP') ) ) ) {
79+
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'GBP' ) ) ) ) {
8080

81-
$this->msg = 'Paystack does not support your store currency. Kindly set it to Nigerian Naira, USD or GBP &#8358; <a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '">here</a>';
81+
$this->msg = 'Paystack does not support your store currency. Kindly set it to either NGN (&#8358), USD (&#36;) or GBP (&#163;) <a href="' . admin_url( 'admin.php?page=wc-settings&tab=general' ) . '">here</a>';
8282

8383
return false;
8484

@@ -127,7 +127,9 @@ public function is_available() {
127127
if ( $this->enabled == "yes" ) {
128128

129129
if ( ! ( $this->public_key && $this->secret_key ) ) {
130+
130131
return false;
132+
131133
}
132134

133135
return true;
@@ -282,9 +284,10 @@ public function payment_scripts() {
282284

283285
if ( $order->id == $order_id && $order->order_key == $order_key ) {
284286

285-
$paystack_params['email'] = $email;
286-
$paystack_params['amount'] = $amount;
287-
$paystack_params['txnref'] = $txnref;
287+
$paystack_params['email'] = $email;
288+
$paystack_params['amount'] = $amount;
289+
$paystack_params['txnref'] = $txnref;
290+
$paystack_params['currency'] = get_woocommerce_currency();
288291

289292
}
290293

@@ -383,16 +386,28 @@ public function process_token_payment( $token, $order_id ) {
383386

384387
if ( 'success' == $paystack_response->data->status ) {
385388

386-
$order = wc_get_order( $order_id );
389+
$order = wc_get_order( $order_id );
387390

388-
$order_total = $order->get_total();
391+
if ( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ) ) ) {
389392

390-
$amount_paid = $paystack_response->data->amount / 100;
393+
wp_redirect( $this->get_return_url( $order ) );
391394

392-
$paystack_ref = $paystack_response->data->reference;
395+
exit;
396+
397+
}
398+
399+
$order_total = $order->get_total();
400+
401+
$order_currency = $order->get_order_currency();
402+
403+
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
404+
405+
$amount_paid = $paystack_response->data->amount / 100;
406+
407+
$paystack_ref = $paystack_response->data->reference;
393408

394409
// check if the amount paid is equal to the order amount.
395-
if ( $order_total != $amount_paid ) {
410+
if ( $amount_paid < $order_total ) {
396411

397412
$order->update_status( 'on-hold', '' );
398413

@@ -405,7 +420,7 @@ public function process_token_payment( $token, $order_id ) {
405420
$order->add_order_note( $notice, 1 );
406421

407422
// Add Admin Order Note
408-
$order->add_order_note('<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>&#8358;'.$amount_paid.'</strong> while the total order amount is <strong>&#8358;'.$order_total.'</strong><br />Paystack Transaction Reference: '.$paystack_ref );
423+
$order->add_order_note( '<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>'. $currency_symbol . $amount_paid . '</strong> while the total order amount is <strong>'. $currency_symbol . $order_total . '</strong><br />Paystack Transaction Reference: '.$paystack_ref );
409424

410425
wc_add_notice( $notice, $notice_type );
411426

@@ -503,8 +518,11 @@ public function verify_paystack_transaction() {
503518
$order = wc_get_order( $order_id );
504519

505520
if ( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ) ) ) {
521+
506522
wp_redirect( $this->get_return_url( $order ) );
523+
507524
exit;
525+
508526
}
509527

510528
$order_total = $order->get_total();
@@ -514,7 +532,7 @@ public function verify_paystack_transaction() {
514532
$paystack_ref = $paystack_response->data->reference;
515533

516534
// check if the amount paid is equal to the order amount.
517-
if ( $order_total != $amount_paid ) {
535+
if ( $amount_paid < $order_total ) {
518536

519537
$order->update_status( 'on-hold', '' );
520538

@@ -527,11 +545,12 @@ public function verify_paystack_transaction() {
527545
$order->add_order_note( $notice, 1 );
528546

529547
// Add Admin Order Note
530-
$order->add_order_note('<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>&#8358;'.$amount_paid.'</strong> while the total order amount is <strong>&#8358;'.$order_total.'</strong><br />Paystack Transaction Reference: '.$paystack_ref );
548+
$order->add_order_note( '<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>&#8358;'.$amount_paid.'</strong> while the total order amount is <strong>&#8358;'.$order_total.'</strong><br />Paystack Transaction Reference: '.$paystack_ref );
531549

532550
$order->reduce_order_stock();
533551

534552
wc_add_notice( $notice, $notice_type );
553+
535554
} else {
536555

537556
$order->payment_complete( $paystack_ref );
@@ -608,14 +627,18 @@ public function process_webhooks() {
608627
exit;
609628
}
610629

611-
$order_total = $order->get_total();
630+
$order_currency = $order->get_order_currency();
631+
632+
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
633+
634+
$order_total = $order->get_total();
612635

613-
$amount_paid = $event->data->amount / 100;
636+
$amount_paid = $event->data->amount / 100;
614637

615-
$paystack_ref = $event->data->reference;
638+
$paystack_ref = $event->data->reference;
616639

617640
// check if the amount paid is equal to the order amount.
618-
if ( $order_total != $amount_paid ) {
641+
if ( $amount_paid < $order_total ) {
619642

620643
$order->update_status( 'on-hold', '' );
621644

@@ -628,7 +651,7 @@ public function process_webhooks() {
628651
$order->add_order_note( $notice, 1 );
629652

630653
// Add Admin Order Note
631-
$order->add_order_note('<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>&#8358;'.$amount_paid.'</strong> while the total order amount is <strong>&#8358;'.$order_total.'</strong><br />Paystack Transaction Reference: '.$paystack_ref );
654+
$order->add_order_note( '<strong>Look into this order</strong><br />This order is currently on hold.<br />Reason: Amount paid is less than the total order amount.<br />Amount Paid was <strong>'. $currency_symbol . $amount_paid . '</strong> while the total order amount is <strong>'. $currency_symbol . $order_total . '</strong><br />Paystack Transaction Reference: '.$paystack_ref );
632655

633656
$order->reduce_order_stock();
634657

includes/class-wc-subscriptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function process_subscription_payment( $order = '', $amount = 0 ) {
118118
$order->payment_complete( $paystack_ref );
119119

120120
$message = sprintf( 'Payment via Paystack successful (Transaction Reference: %s)', $paystack_ref );
121+
121122
$order->add_order_note( $message );
122123

123124
return true;

readme.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Contributors: tubiz
33
Donate link: http://bosun.me/donate
44
Tags: paystack, woocommerce, payment gateway, interswitch, tubiz plugins, verve, nigeria, mastercard, visa
55
Requires at least: 4.4
6-
Tested up to: 4.6
7-
Stable tag: 3.0.0
6+
Tested up to: 4.7
7+
Stable tag: 3.1.0
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -120,6 +120,9 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
120120

121121
== Changelog ==
122122

123+
= 3.1.0, January 10, 2017 =
124+
* 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.
125+
123126
= 3.0.0, November 11, 2016 =
124127
* New: Add support for recurring payment using [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) plugin.
125128

@@ -143,8 +146,8 @@ To configure the plugin, go to __WooCommerce > Settings__ from the left hand me
143146

144147
== Upgrade Notice ==
145148

146-
= 3.0.0 =
147-
* Add support for recurring payment using WooCommerce Subscriptions plugin
149+
= 3.1.0 =
150+
* 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.
148151

149152

150153

0 commit comments

Comments
 (0)