Skip to content

Commit 39bfcfa

Browse files
committed
Merge branch 'dev'
2 parents 78a79ad + 1042eff commit 39bfcfa

4 files changed

Lines changed: 44 additions & 14 deletions

File tree

assets/css/paystack.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.payment_box.payment_method_paystack{ display: none !important; }

assets/js/paystack.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ jQuery( function( $ ) {
77
return payStackFormHandler();
88
});
99

10-
1110
jQuery( '#paystack_form form#order_review' ).submit( function() {
1211
return payStackFormHandler();
1312
});
1413

15-
1614
function payStackFormHandler() {
1715

1816
if ( paystack_submit ) {

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== Paystack WooCommerce Payment Gateway ===
22
Contributors: tubiz
33
Donate link: http://bosun.me/donate
4-
Tags: woocommerce, payment gateway, payment gateways, paystack, interswitch, verve cards, tubiz plugins, verve, nigeria, mastercard, visa card
4+
Tags: paystack, woocommerce, payment gateway, interswitch, tubiz plugins, verve, nigeria, mastercard, visa
55
Requires at least: 4.1
66
Tested up to: 4.4
77
Stable tag: 1.0.0
Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,32 @@ public function __construct() {
5959

6060
// Payment listener/API hook
6161
add_action( 'woocommerce_api_tbz_wc_paystack_gateway', array( $this, 'verify_paystack_transaction' ) );
62+
63+
// Check if the gateway can be used
64+
if ( ! $this->is_valid_for_use() ) {
65+
$this->enabled = false;
66+
}
6267
}
6368

6469

6570
/**
66-
* display paystack payment icon
71+
* Check if this gateway is enabled and available in the user's country.
72+
*/
73+
public function is_valid_for_use() {
74+
75+
if( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN' ) ) ) ) {
76+
77+
$this->msg = 'Paystack does not support your store currency.';
78+
79+
return false;
80+
81+
}
82+
83+
return true;
84+
}
85+
86+
/**
87+
* Display paystack payment icon
6788
*/
6889
public function get_icon() {
6990

@@ -112,12 +133,20 @@ public function is_available() {
112133
* Admin Panel Options
113134
*/
114135
public function admin_options() {
115-
?>
116-
<h3>Paystack</h3>
117-
<table class="form-table">
118-
<?php $this->generate_settings_html(); ?>
119-
</table>
120-
<?php
136+
137+
echo '<h3>Paystack</h3>';
138+
139+
if ( $this->is_valid_for_use() ){
140+
141+
echo '<table class="form-table">';
142+
$this->generate_settings_html();
143+
echo '</table>';
144+
145+
}
146+
else{ ?>
147+
<div class="inline error"><p><strong>Paystack Payment Gateway Disabled</strong>: <?php echo $this->msg ?></p></div>
148+
149+
<?php }
121150
}
122151

123152

@@ -175,6 +204,10 @@ public function init_form_fields() {
175204
*/
176205
public function payment_scripts() {
177206

207+
if ( is_checkout() ) {
208+
wp_enqueue_style( 'paystack', plugins_url( 'assets/css/paystack.css', __FILE__ ) );
209+
}
210+
178211
if ( ! is_checkout_pay_page() ) {
179212
return;
180213
}
@@ -237,16 +270,15 @@ public function receipt_page( $order_id ) {
237270

238271
$order = wc_get_order( $order_id );
239272

240-
echo '<p>Thank you for your order, please click the button below to pay with credit card using Paystack.</p>';
273+
echo '<p>Thank you for your order, please click the button below to pay with debit/credit card using Paystack.</p>';
241274

242275
echo '<div id="paystack_form"><form id="order_review" method="post" action="'. WC()->api_request_url( 'Tbz_WC_Paystack_Gateway' ) .'"></form><button class="button alt" id="paystack-payment-button">Pay Now</button> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">Cancel order &amp; restore cart</a></div>
243276
';
244-
245277
}
246278

247279

248280
/**
249-
* Verify paystack payment
281+
* Verify Paystack payment
250282
*/
251283
public function verify_paystack_transaction() {
252284

@@ -352,7 +384,6 @@ function tbz_wc_add_paystack_gateway( $methods ) {
352384
$methods[] = 'Tbz_WC_Paystack_Gateway';
353385
return $methods;
354386
}
355-
356387
add_filter( 'woocommerce_payment_gateways', 'tbz_wc_add_paystack_gateway' );
357388

358389
}

0 commit comments

Comments
 (0)