Skip to content

Commit bb47e6d

Browse files
authored
Version 5.7.4 Release
2 parents f56505f + 510cf29 commit bb47e6d

8 files changed

Lines changed: 109 additions & 114 deletions

assets/js/paystack-admin.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ jQuery( function( $ ) {
8080
templateSelection: formatPaystackPaymentIconDisplay
8181
} );
8282

83+
$( '#woocommerce_paystack_test_secret_key, #woocommerce_paystack_live_secret_key' ).after(
84+
'<button class="wc-paystack-toggle-secret" style="height: 30px; margin-left: 2px; cursor: pointer"><span class="dashicons dashicons-visibility"></span></button>'
85+
);
86+
87+
$( '.wc-paystack-toggle-secret' ).on( 'click', function( event ) {
88+
event.preventDefault();
89+
90+
let $dashicon = $( this ).closest( 'button' ).find( '.dashicons' );
91+
let $input = $( this ).closest( 'tr' ).find( '.input-text' );
92+
let inputType = $input.attr( 'type' );
93+
94+
if ( 'text' == inputType ) {
95+
$input.attr( 'type', 'password' );
96+
$dashicon.removeClass( 'dashicons-hidden' );
97+
$dashicon.addClass( 'dashicons-visibility' );
98+
} else {
99+
$input.attr( 'type', 'text' );
100+
$dashicon.removeClass( 'dashicons-visibility' );
101+
$dashicon.addClass( 'dashicons-hidden' );
102+
}
103+
} );
83104
}
84105
};
85106

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 & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function get_icon() {
424424
*/
425425
public function payment_scripts() {
426426

427-
if ( ! is_checkout_pay_page() ) {
427+
if ( isset( $_GET['pay_for_order'] ) || ! is_checkout_pay_page() ) {
428428
return;
429429
}
430430

@@ -437,9 +437,7 @@ public function payment_scripts() {
437437

438438
$order = wc_get_order( $order_id );
439439

440-
$payment_method = method_exists( $order, 'get_payment_method' ) ? $order->get_payment_method() : $order->payment_method;
441-
442-
if ( $this->id !== $payment_method ) {
440+
if ( $this->id !== $order->get_payment_method() ) {
443441
return;
444442
}
445443

@@ -457,15 +455,15 @@ public function payment_scripts() {
457455

458456
if ( is_checkout_pay_page() && get_query_var( 'order-pay' ) ) {
459457

460-
$email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
458+
$email = $order->get_billing_email();
461459

462460
$amount = $order->get_total() * 100;
463461

464462
$txnref = $order_id . '_' . time();
465463

466-
$the_order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
467-
$the_order_key = method_exists( $order, 'get_order_key' ) ? $order->get_order_key() : $order->order_key;
468-
$currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->order_currency;
464+
$the_order_id = $order->get_id();
465+
$the_order_key = $order->get_order_key();
466+
$currency = $order->get_currency();
469467

470468
if ( $the_order_id == $order_id && $the_order_key == $order_key ) {
471469

@@ -526,10 +524,7 @@ public function payment_scripts() {
526524

527525
if ( $this->meta_name ) {
528526

529-
$first_name = method_exists( $order, 'get_billing_first_name' ) ? $order->get_billing_first_name() : $order->billing_first_name;
530-
$last_name = method_exists( $order, 'get_billing_last_name' ) ? $order->get_billing_last_name() : $order->billing_last_name;
531-
532-
$paystack_params['meta_name'] = $first_name . ' ' . $last_name;
527+
$paystack_params['meta_name'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
533528

534529
}
535530

@@ -541,9 +536,7 @@ public function payment_scripts() {
541536

542537
if ( $this->meta_phone ) {
543538

544-
$billing_phone = method_exists( $order, 'get_billing_phone' ) ? $order->get_billing_phone() : $order->billing_phone;
545-
546-
$paystack_params['meta_phone'] = $billing_phone;
539+
$paystack_params['meta_phone'] = $order->get_billing_phone();
547540

548541
}
549542

@@ -603,7 +596,7 @@ public function payment_scripts() {
603596
}
604597

605598
/**
606-
* Add Gateway to checkout page.
599+
* Add custom gateways to the checkout page.
607600
*
608601
* @param $available_gateways
609602
*

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,12 @@ public function scheduled_subscription_payment( $amount_to_charge, $renewal_orde
9595
*/
9696
public function process_subscription_payment( $order, $amount ) {
9797

98-
$order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
98+
$order_id = $order->get_id();
9999

100100
$auth_code = get_post_meta( $order_id, '_paystack_token', true );
101101

102102
if ( $auth_code ) {
103103

104-
$email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
105-
106104
$order_amount = $amount * 100;
107105

108106
$paystack_url = 'https://api.paystack.co/transaction/charge_authorization';
@@ -115,7 +113,7 @@ public function process_subscription_payment( $order, $amount ) {
115113
$metadata['custom_fields'] = $this->get_custom_fields( $order_id );
116114

117115
$body = array(
118-
'email' => $email,
116+
'email' => $order->get_billing_email(),
119117
'amount' => $order_amount,
120118
'metadata' => $metadata,
121119
'authorization_code' => $auth_code,

includes/class-wc-gateway-paystack.php

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ public function __construct() {
274274
*/
275275
public function is_valid_for_use() {
276276

277-
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'ZAR', 'GHS', 'KES' ) ) ) ) {
277+
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'ZAR', 'GHS', 'KES', 'XOF' ) ) ) ) {
278278

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

281281
return false;
282282

@@ -433,7 +433,7 @@ public function init_form_fields() {
433433
),
434434
'test_secret_key' => array(
435435
'title' => __( 'Test Secret Key', 'woo-paystack' ),
436-
'type' => 'text',
436+
'type' => 'password',
437437
'description' => __( 'Enter your Test Secret Key here', 'woo-paystack' ),
438438
'default' => '',
439439
),
@@ -445,7 +445,7 @@ public function init_form_fields() {
445445
),
446446
'live_secret_key' => array(
447447
'title' => __( 'Live Secret Key', 'woo-paystack' ),
448-
'type' => 'text',
448+
'type' => 'password',
449449
'description' => __( 'Enter your Live Secret Key here.', 'woo-paystack' ),
450450
'default' => '',
451451
),
@@ -643,7 +643,7 @@ public function payment_fields() {
643643
*/
644644
public function payment_scripts() {
645645

646-
if ( ! is_checkout_pay_page() ) {
646+
if ( isset( $_GET['pay_for_order'] ) || ! is_checkout_pay_page() ) {
647647
return;
648648
}
649649

@@ -656,9 +656,7 @@ public function payment_scripts() {
656656

657657
$order = wc_get_order( $order_id );
658658

659-
$payment_method = method_exists( $order, 'get_payment_method' ) ? $order->get_payment_method() : $order->payment_method;
660-
661-
if ( $this->id !== $payment_method ) {
659+
if ( $this->id !== $order->get_payment_method() ) {
662660
return;
663661
}
664662

@@ -676,12 +674,12 @@ public function payment_scripts() {
676674

677675
if ( is_checkout_pay_page() && get_query_var( 'order-pay' ) ) {
678676

679-
$email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
677+
$email = $order->get_billing_email();
680678
$amount = $order->get_total() * 100;
681679
$txnref = $order_id . '_' . time();
682-
$the_order_id = method_exists( $order, 'get_id' ) ? $order->get_id() : $order->id;
683-
$the_order_key = method_exists( $order, 'get_order_key' ) ? $order->get_order_key() : $order->order_key;
684-
$currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->order_currency;
680+
$the_order_id = $order->get_id();
681+
$the_order_key = $order->get_order_key();
682+
$currency = $order->get_currency();
685683

686684
if ( $the_order_id == $order_id && $the_order_key == $order_key ) {
687685

@@ -714,10 +712,7 @@ public function payment_scripts() {
714712

715713
if ( $this->meta_name ) {
716714

717-
$first_name = method_exists( $order, 'get_billing_first_name' ) ? $order->get_billing_first_name() : $order->billing_first_name;
718-
$last_name = method_exists( $order, 'get_billing_last_name' ) ? $order->get_billing_last_name() : $order->billing_last_name;
719-
720-
$paystack_params['meta_name'] = $first_name . ' ' . $last_name;
715+
$paystack_params['meta_name'] = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name();
721716

722717
}
723718

@@ -729,9 +724,7 @@ public function payment_scripts() {
729724

730725
if ( $this->meta_phone ) {
731726

732-
$billing_phone = method_exists( $order, 'get_billing_phone' ) ? $order->get_billing_phone() : $order->billing_phone;
733-
734-
$paystack_params['meta_phone'] = $billing_phone;
727+
$paystack_params['meta_phone'] = $order->get_billing_phone();
735728

736729
}
737730

@@ -879,18 +872,16 @@ public function process_payment( $order_id ) {
879872
public function process_redirect_payment_option( $order_id ) {
880873

881874
$order = wc_get_order( $order_id );
882-
$email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
883875
$amount = $order->get_total() * 100;
884876
$txnref = $order_id . '_' . time();
885-
$currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->order_currency;
886877
$callback_url = WC()->api_request_url( 'WC_Gateway_Paystack' );
887878

888879
$payment_channels = $this->get_gateway_payment_channels( $order );
889880

890881
$paystack_params = array(
891882
'amount' => $amount,
892-
'email' => $email,
893-
'currency' => $currency,
883+
'email' => $order->get_billing_email(),
884+
'currency' => $order->get_currency(),
894885
'reference' => $txnref,
895886
'callback_url' => $callback_url,
896887
);
@@ -962,9 +953,7 @@ public function process_token_payment( $token, $order_id ) {
962953

963954
$order = wc_get_order( $order_id );
964955

965-
$email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
966-
$order_amount = method_exists( $order, 'get_total' ) ? $order->get_total() : $order->order_total;
967-
$order_amount = $order_amount * 100;
956+
$order_amount = $order->get_total() * 100;
968957

969958
$paystack_url = 'https://api.paystack.co/transaction/charge_authorization';
970959

@@ -976,7 +965,7 @@ public function process_token_payment( $token, $order_id ) {
976965
$metadata['custom_fields'] = $this->get_custom_fields( $order_id );
977966

978967
$body = array(
979-
'email' => $email,
968+
'email' => $order->get_billing_email(),
980969
'amount' => $order_amount,
981970
'metadata' => $metadata,
982971
'authorization_code' => $token,
@@ -1007,7 +996,7 @@ public function process_token_payment( $token, $order_id ) {
1007996
}
1008997

1009998
$order_total = $order->get_total();
1010-
$order_currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->get_order_currency();
999+
$order_currency = $order->get_currency();
10111000
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
10121001
$amount_paid = $paystack_response->data->amount / 100;
10131002
$paystack_ref = $paystack_response->data->reference;
@@ -1181,7 +1170,7 @@ public function verify_paystack_transaction() {
11811170
}
11821171

11831172
$order_total = $order->get_total();
1184-
$order_currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->get_order_currency();
1173+
$order_currency = $order->get_currency();
11851174
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
11861175
$amount_paid = $paystack_response->data->amount / 100;
11871176
$paystack_ref = $paystack_response->data->reference;
@@ -1310,7 +1299,7 @@ public function process_webhooks() {
13101299
exit;
13111300
}
13121301

1313-
$order_currency = method_exists( $order, 'get_currency' ) ? $order->get_currency() : $order->get_order_currency();
1302+
$order_currency = $order->get_currency();
13141303

13151304
$currency_symbol = get_woocommerce_currency_symbol( $order_currency );
13161305

@@ -1508,37 +1497,30 @@ public function get_custom_fields( $order_id ) {
15081497

15091498
if ( $this->meta_name ) {
15101499

1511-
$first_name = method_exists( $order, 'get_billing_first_name' ) ? $order->get_billing_first_name() : $order->billing_first_name;
1512-
$last_name = method_exists( $order, 'get_billing_last_name' ) ? $order->get_billing_last_name() : $order->billing_last_name;
1513-
15141500
$custom_fields[] = array(
15151501
'display_name' => 'Customer Name',
15161502
'variable_name' => 'customer_name',
1517-
'value' => $first_name . ' ' . $last_name,
1503+
'value' => $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(),
15181504
);
15191505

15201506
}
15211507

15221508
if ( $this->meta_email ) {
15231509

1524-
$email = method_exists( $order, 'get_billing_email' ) ? $order->get_billing_email() : $order->billing_email;
1525-
15261510
$custom_fields[] = array(
15271511
'display_name' => 'Customer Email',
15281512
'variable_name' => 'customer_email',
1529-
'value' => $email,
1513+
'value' => $order->get_billing_email(),
15301514
);
15311515

15321516
}
15331517

15341518
if ( $this->meta_phone ) {
15351519

1536-
$billing_phone = method_exists( $order, 'get_billing_phone' ) ? $order->get_billing_phone() : $order->billing_phone;
1537-
15381520
$custom_fields[] = array(
15391521
'display_name' => 'Customer Phone',
15401522
'variable_name' => 'customer_phone',
1541-
'value' => $billing_phone,
1523+
'value' => $order->get_billing_phone(),
15421524
);
15431525

15441526
}

0 commit comments

Comments
 (0)