@@ -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 (₦), GHS (₵), USD ($), 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 (₦), GHS (₵), USD ($), 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