@@ -228,8 +228,17 @@ function init_form_fields()
228228 'default ' => 'none ' ,
229229 'options ' => array (
230230 '0.05 ' => '5% ' ,
231+ '0.048 ' => '4.8% ' ,
232+ '0.045 ' => '4.5% ' ,
233+ '0.042 ' => '4.2% ' ,
231234 '0.04 ' => '4% ' ,
235+ '0.038 ' => '3.8% ' ,
236+ '0.035 ' => '3.5% ' ,
237+ '0.032 ' => '3.2% ' ,
232238 '0.03 ' => '3% ' ,
239+ '0.028 ' => '2.8% ' ,
240+ '0.025 ' => '2.5% ' ,
241+ '0.022 ' => '2.2% ' ,
233242 '0.02 ' => '2% ' ,
234243 '0.018 ' => '1.8% ' ,
235244 '0.015 ' => '1.5% ' ,
@@ -268,8 +277,8 @@ function init_form_fields()
268277 'type ' => 'select ' ,
269278 'default ' => 'ammount ' ,
270279 'options ' => array (
271- 'ammount ' => __ ('Default Ammount ' , 'cryptapi ' ),
272280 'without_ammount ' => __ ('Default Without Ammount ' , 'cryptapi ' ),
281+ 'ammount ' => __ ('Default Ammount ' , 'cryptapi ' ),
273282 'hide_ammount ' => __ ('Hide Ammount ' , 'cryptapi ' ),
274283 'hide_without_ammount ' => __ ('Hide Without Ammount ' , 'cryptapi ' ),
275284 ),
@@ -372,7 +381,7 @@ function payment_fields()
372381 $ addr = $ this ->{$ val . '_address ' };
373382 if (!empty ($ addr )) { ?>
374383 <option value="<?php echo $ val ; ?> " <?php
375- if (!empty ($ selected ) && $ selected === $ val ) {
384+ if (!empty ($ selected ) && $ selected === $ val ) {
376385 echo " selected='true' " ;
377386 }
378387 ?> > <?php echo __ ('Pay with ' , 'cryptapi ' ) . ' ' . WC_CryptAPI_Gateway::$ COIN_OPTIONS [$ val ] ?> </option>
@@ -499,43 +508,39 @@ function process_payment($order_id)
499508
500509 function validate_payment ()
501510 {
502- try {
503- $ data = CryptAPI \Helper::process_callback ($ _GET );
504- $ order = new WC_Order ($ data ['order_id ' ]);
511+ $ data = CryptAPI \Helper::process_callback ($ _GET );
512+ $ order = new WC_Order ($ data ['order_id ' ]);
505513
506- if ($ order ->is_paid () || $ order ->get_status () === 'cancelled ' || $ data ['nonce ' ] != $ order ->get_meta ('cryptapi_nonce ' )) {
507- die ("*ok* " );
508- }
514+ if ($ order ->is_paid () || $ order ->get_status () === 'cancelled ' || $ data ['nonce ' ] != $ order ->get_meta ('cryptapi_nonce ' )) {
515+ die ("*ok* " );
516+ }
509517
510- $ paid = floatval ($ order ->get_meta ('cryptpi_paid ' )) + floatval ($ data ['value_coin ' ]);
511- $ crypto_coin = strtoupper ($ order ->get_meta ('cryptapi_currency ' ));
518+ $ paid = floatval ($ order ->get_meta ('cryptpi_paid ' )) + floatval ($ data ['value_coin ' ]);
519+ $ crypto_coin = strtoupper ($ order ->get_meta ('cryptapi_currency ' ));
512520
513- if (!$ data ['pending ' ]) {
514- $ order ->add_meta_data ('cryptapi_paid ' , $ paid );
515- }
521+ if (!$ data ['pending ' ]) {
522+ $ order ->add_meta_data ('cryptapi_paid ' , $ paid );
523+ }
516524
517- if ($ paid >= $ order ->get_meta ('cryptapi_total ' )) {
518- if ($ data ['pending ' ]) {
519- $ order ->add_meta_data ('cryptapi_pending ' , "1 " );
520- } else {
521- $ order ->delete_meta_data ('cryptapi_pending ' );
522- $ order ->payment_complete ($ data ['address_in ' ]);
523- }
525+ if ($ paid >= $ order ->get_meta ('cryptapi_total ' )) {
526+ if ($ data ['pending ' ]) {
527+ $ order ->add_meta_data ('cryptapi_pending ' , "1 " );
528+ } else {
529+ $ order ->delete_meta_data ('cryptapi_pending ' );
530+ $ order ->payment_complete ($ data ['address_in ' ]);
524531 }
532+ }
525533
526- $ order ->add_order_note (
527- ($ data ['pending ' ] ? '[PENDING] ' : '' ) .
528- __ ('User sent a payment of ' , 'cryptapi ' ) . ' ' .
529- $ data ['value_coin ' ] . ' ' . $ crypto_coin .
530- '. TXID: ' . $ data ['txid_in ' ]
531- );
534+ $ order ->add_order_note (
535+ ($ data ['pending ' ] ? '[PENDING] ' : '' ) .
536+ __ ('User sent a payment of ' , 'cryptapi ' ) . ' ' .
537+ $ data ['value_coin ' ] . ' ' . $ crypto_coin .
538+ '. TXID: ' . $ data ['txid_in ' ]
539+ );
532540
533- $ order ->save_meta_data ();
541+ $ order ->save_meta_data ();
534542
535- die ("*ok* " );
536- } catch (Exception $ e ) {
537- die ($ e ->getMessage ());
538- }
543+ die ("*ok* " );
539544 }
540545
541546 function order_status ()
@@ -591,6 +596,22 @@ function thankyou_page($order_id)
591596 wp_enqueue_script ('ca-payment ' , CRYPTAPI_PLUGIN_URL . 'static/payment.js ' , array (), CRYPTAPI_PLUGIN_VERSION , true );
592597 wp_add_inline_script ('ca-payment ' , "jQuery(function() {let ajax_url = ' {$ ajax_url }'; setTimeout(function(){check_status(ajax_url)}, 500)}) " );
593598 wp_enqueue_style ('ca-loader-css ' , CRYPTAPI_PLUGIN_URL . 'static/cryptapi.css ' , false , CRYPTAPI_PLUGIN_VERSION );
599+
600+ $ allowed_to_value = array (
601+ 'btc ' ,
602+ 'eth ' ,
603+ 'bch ' ,
604+ 'ltc ' ,
605+ 'miota ' ,
606+ 'xml ' ,
607+ 'trx ' ,
608+ );
609+
610+ $ crypto_allowed_value = false ;
611+
612+ if (in_array ($ crypto_coin , $ allowed_to_value , true )) {
613+ $ crypto_allowed_value = true ;
614+ }
594615 ?>
595616 <div class="ca_payment-panel<?php
596617 if ($ color_scheme == 'auto ' ) {
@@ -613,61 +634,82 @@ function thankyou_page($order_id)
613634 echo 'display: none ' ;
614635 }
615636 ?> ; width: <?php echo intval ($ this ->qrcode_size ) + 20 ; ?> px;">
616- <div class="inner-wrapper">
617- <figure>
637+ <?php
638+ if ($ crypto_allowed_value == true ) {
639+ ?>
640+ <div class="inner-wrapper">
641+ <figure>
642+ <?php
643+ if ($ qr_code_setting != 'hide_ammount ' ) {
644+ ?>
645+ <img class="ca_qrcode no_value" <?php
646+ if ($ qr_code_setting == 'ammount ' ) {
647+ echo 'style="display:none;" ' ;
648+ }
649+ ?> src="data:image/png;base64,<?php echo $ qr_code_img ; ?> " alt="<?php echo __ ('QR Code without value ' , 'cryptapi ' ); ?> "/>
650+ <?php
651+ }
652+ if ($ qr_code_setting != 'hide_without_ammount ' ) {
653+ ?>
654+ <img class="ca_qrcode value" <?php
655+ if ($ qr_code_setting == 'without_ammount ' ) {
656+ echo 'style="display:none;" ' ;
657+ }
658+ ?> src="data:image/png;base64,<?php echo $ qr_code_img_value ; ?> "
659+ alt="<?php echo __ ('QR Code with value ' , 'cryptapi ' ); ?> "/>
660+ <?php
661+ }
662+ ?>
663+ </figure>
618664 <?php
619- if ($ qr_code_setting != 'hide_ammount ' ) {
665+ if ($ qr_code_setting != 'hide_ammount ' && $ qr_code_setting != ' hide_without_ammount ' ) {
620666 ?>
621- <img class="ca_qrcode no_value" <?php
622- if ($ qr_code_setting == 'without_ammount ' ) {
623- echo 'style="display:none;" ' ;
624- }
625- ?> src="data:image/png;base64,<?php echo $ qr_code_img ; ?> " alt="<?php echo __ ('QR Code without value ' , 'cryptapi ' ); ?> "/>
667+ <div class="ca_qrcode_buttons">
626668 <?php
627- }
628- if ($ qr_code_setting != 'hide_without_ammount ' ) {
629- ?>
630- <img class="ca_qrcode value" <?php
631- if ($ qr_code_setting == 'ammount ' ) {
632- echo 'style="display:none;" ' ;
669+ if ($ qr_code_setting != 'hide_without_ammount ' ) {
670+ ?>
671+ <button class="ca_qrcode_btn no_value<?php
672+ if ($ qr_code_setting == 'without_ammount ' ) {
673+ echo ' active ' ;
674+ }
675+ ?> " aria-label="<?php echo __ ('Show QR Code without value ' , 'cryptapi ' ); ?> ">
676+ <?php echo __ ('ADDRESS ' , 'cryptapi ' ); ?>
677+ </button>
678+ <?php
679+ }
680+ if ($ qr_code_setting != 'hide_ammount ' ) {
681+ ?>
682+ <button class="ca_qrcode_btn value<?php
683+ if ($ qr_code_setting == 'ammount ' ) {
684+ echo ' active ' ;
685+ }
686+ ?> " aria-label="<?php echo __ ('Show QR Code with value ' , 'cryptapi ' ); ?> ">
687+ <?php echo __ ('WITH AMMOUNT ' , 'cryptapi ' ); ?>
688+ </button>
689+ </div>
690+ <?php
633691 }
634- ?> src="data:image/png;base64,<?php echo $ qr_code_img_value ; ?> "
635- alt="<?php echo __ ('QR Code with value ' , 'cryptapi ' ); ?> "/>
636- <?php
637692 }
638693 ?>
639- </figure >
694+ </div >
640695 <?php
641- if ($ qr_code_setting != 'hide_ammount ' && $ qr_code_setting != 'hide_without_ammount ' ) {
642- ?>
696+ } else {
697+ ?>
698+ <div class="inner-wrapper">
699+ <figure>
700+ <img class="ca_qrcode no_value" src="data:image/png;base64,<?php echo $ qr_code_img ; ?> "
701+ alt="<?php echo __ ('QR Code without value ' , 'cryptapi ' ); ?> "/>
702+ </figure>
643703 <div class="ca_qrcode_buttons">
644- <?php
645- if ($ qr_code_setting != 'hide_without_ammount ' ) {
646- ?>
647- <button class="ca_qrcode_btn no_value<?php
648- if ($ qr_code_setting == 'ammount ' ) {
649- echo ' active ' ;
650- }
651- ?> " aria-label="<?php echo __ ('Show QR Code without value ' , 'cryptapi ' ); ?> ">
704+ <button class="ca_qrcode_btn no_value active" aria-label="<?php echo __ ('Show QR Code without value ' , 'cryptapi ' ); ?> ">
652705 <?php echo __ ('ADDRESS ' , 'cryptapi ' ); ?>
653706 </button>
654- <?php
655- }
656- if ($ qr_code_setting != 'hide_ammount ' ) {
657- ?>
658- <button class="ca_qrcode_btn value<?php
659- if ($ qr_code_setting == 'without_ammount ' ) {
660- echo ' active ' ;
661- }
662- ?> " aria-label="<?php echo __ ('Show QR Code with value ' , 'cryptapi ' ); ?> ">
663- <?php echo __ ('WITH AMMOUNT ' , 'cryptapi ' ); ?>
664- </button>
665- </div>
666- <?php
667- }
668- }
669- ?>
670- </div>
707+ </div>
708+ </div>
709+
710+ <?php
711+ }
712+ ?>
671713 </div>
672714 <div class="ca_details_box">
673715 <div class="ca_details_text">
0 commit comments