@@ -705,6 +705,9 @@ function kkd_pff_paystack_form_shortcode($atts) {
705705 $ quantity = get_post_meta ($ id ,'_quantity ' ,true );
706706 $ useagreement = get_post_meta ($ id ,'_useagreement ' ,true );
707707 $ agreementlink = get_post_meta ($ id ,'_agreementlink ' ,true );
708+ $ minimum = get_post_meta ($ id ,'_minimum ' ,true );
709+ if ($ minimum == "" ) {$ minimum = 0 ;}
710+
708711 $ showbtn = true ;
709712 $ planerrorcode = 'Input Correct Recurring Plan Code ' ;
710713 if ($ recur == 'plan ' ) {
@@ -758,6 +761,10 @@ function kkd_pff_paystack_form_shortcode($atts) {
758761 echo '<div class="span12 unit">
759762 <label class="label">Amount ( ' .$ currency .') <span>*</span></label>
760763 <div class="input"> ' ;
764+ // echo "<pre>".$minimum. "</pre>";
765+ if ($ minimum == 1 ) {
766+ echo '<small> Minimum payable amount <b style="font-size:87% !important;"> ' .$ currency .' ' .number_format ($ amount ).'</b></small> ' ;
767+ }
761768 if ($ recur == 'plan ' ) {
762769 if ($ showbtn ) {
763770 echo '<input type="text" name="pf-amount" value=" ' .$ planamount .'" id="pf-amount" readonly required/> ' ;
@@ -771,7 +778,9 @@ function kkd_pff_paystack_form_shortcode($atts) {
771778 }else {
772779 if ($ amount == 0 ) {
773780 echo '<input type="text" name="pf-amount" class="pf-number" value="0" id="pf-amount" required/> ' ;
774- }else {
781+ }elseif ($ amount != 0 && $ minimum == 1 ){
782+ echo '<input type="text" name="pf-amount" value=" ' .$ amount .'" id="pf-amount" required/> ' ;
783+ }else {
775784 echo '<input type="text" name="pf-amount" value=" ' .$ amount .'" id="pf-amount" readonly required/> ' ;
776785 }
777786 }
@@ -1080,13 +1089,14 @@ function kkd_pff_paystack_submit_action() {
10801089
10811090 $ filelimit = get_post_meta ($ _POST ["pf-id " ],'_filelimit ' ,true );
10821091 $ currency = get_post_meta ($ _POST ["pf-id " ],'_currency ' ,true );
1083- $ formamount = get_post_meta ($ _POST ["pf-id " ],'_amount ' ,true );
1092+ $ formamount = get_post_meta ($ _POST ["pf-id " ],'_amount ' ,true );/// From form
10841093 $ recur = get_post_meta ($ _POST ["pf-id " ],'_recur ' ,true );
10851094 $ subaccount = get_post_meta ($ _POST ["pf-id " ],'_subaccount ' ,true );
10861095 $ txnbearer = get_post_meta ($ _POST ["pf-id " ],'_txnbearer ' ,true );
10871096
10881097 $ txncharge = get_post_meta ($ _POST ["pf-id " ],'_txncharge ' ,true );
1089- $ amount = (int )str_replace (' ' , '' , $ _POST ["pf-amount " ]);
1098+ $ minimum = get_post_meta ($ _POST ["pf-id " ],'_minimum ' ,true );
1099+ $ amount = (int )str_replace (' ' , '' , $ _POST ["pf-amount " ]);//User input
10901100 $ originalamount = $ amount ;
10911101 $ quantity = 1 ;
10921102 $ usequantity = get_post_meta ($ _POST ["pf-id " ],'_usequantity ' ,true );
@@ -1105,6 +1115,13 @@ function kkd_pff_paystack_submit_action() {
11051115 $ amount = $ quantity *$ unitamount ;
11061116 }
11071117 }
1118+ if ($ minimum == 1 && $ formamount != 0 ) {
1119+ if ($ originalamount < $ formamount ) {
1120+ $ amount = $ formamount ;
1121+ }else {
1122+ $ amount = $ originalamount ;
1123+ }
1124+ }
11081125 if ($ txncharge == 'customer ' ) {
11091126 $ amount = kkd_pff_paystack_add_paystack_charge ($ amount );
11101127 }
@@ -1337,8 +1354,16 @@ function kkd_pff_paystack_confirm_payment() {
13371354 $ currency = get_post_meta ($ payment_array ->post_id ,'_currency ' ,true );
13381355 $ txncharge = get_post_meta ($ payment_array ->post_id ,'_txncharge ' ,true );
13391356 $ redirect = get_post_meta ($ payment_array ->post_id ,'_redirect ' ,true );
1357+ $ minimum = get_post_meta ($ payment_array ->post_id ,'_minimum ' ,true );
13401358
1341-
1359+ if ($ minimum == 1 && $ amount != 0 ) {
1360+ if ($ payment_array ->amount < $ formamount ) {
1361+ $ amount = $ formamount ;
1362+ }else {
1363+ $ amount = $ payment_array ->amount ;
1364+ }
1365+ }
1366+ $ oamount = $ amount ;
13421367 $ mode = esc_attr ( get_option ('mode ' ) );
13431368 if ($ mode == 'test ' ) {
13441369 $ key = esc_attr ( get_option ('tsk ' ) );
@@ -1383,10 +1408,11 @@ function kkd_pff_paystack_confirm_payment() {
13831408 }
13841409
13851410
1386- if ($ txncharge == 'customer ' ) {
1387- $ amount = kkd_pff_paystack_add_paystack_charge ($ amount );
1388- }
1389- if ( $ amount != $ amount_paid ) {
1411+ // if ($txncharge == 'customer') {
1412+ // $amount = kkd_pff_paystack_add_paystack_charge($amount);
1413+ // }
1414+ if ( $ oamount != $ amount_paid ) {
1415+ echo $ amount . ' - ' .$ amount_paid ;
13901416 $ message = "Invalid amount Paid. Amount required is " .$ currency ."<b> " .number_format ($ amount )."</b> " ;
13911417 $ result = "failed " ;
13921418 }else {
0 commit comments