Skip to content

Commit 1042eff

Browse files
committed
cleanup
1 parent 3cb0bde commit 1042eff

4 files changed

Lines changed: 46 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 ) {

paystack-woocommerce-payment-gateway.php

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,34 @@ 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+
//$this->msg = 'Paystack doesn\'t support your store currency, set it to Nigerian Naira &#8358 <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=wc-settings&tab=general">here</a>';
80+
81+
return false;
82+
83+
}
84+
85+
return true;
86+
}
87+
88+
/**
89+
* Display paystack payment icon
6790
*/
6891
public function get_icon() {
6992

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

123154

@@ -175,6 +206,10 @@ public function init_form_fields() {
175206
*/
176207
public function payment_scripts() {
177208

209+
if ( is_checkout() ) {
210+
wp_enqueue_style( 'paystack', plugins_url( 'assets/css/paystack.css', __FILE__ ) );
211+
}
212+
178213
if ( ! is_checkout_pay_page() ) {
179214
return;
180215
}
@@ -237,16 +272,15 @@ public function receipt_page( $order_id ) {
237272

238273
$order = wc_get_order( $order_id );
239274

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

242277
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>
243278
';
244-
245279
}
246280

247281

248282
/**
249-
* Verify paystack payment
283+
* Verify Paystack payment
250284
*/
251285
public function verify_paystack_transaction() {
252286

@@ -352,7 +386,6 @@ function tbz_wc_add_paystack_gateway( $methods ) {
352386
$methods[] = 'Tbz_WC_Paystack_Gateway';
353387
return $methods;
354388
}
355-
356389
add_filter( 'woocommerce_payment_gateways', 'tbz_wc_add_paystack_gateway' );
357390

358391
}

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

0 commit comments

Comments
 (0)