@@ -614,6 +614,8 @@ function kkd_pff_paystack_form_shortcode($atts) {
614614 <div class="input"> ' ;
615615 if ($ recur == 'plan ' ) {
616616 echo '<input type="text" name="pf-amount" value=" ' .$ planamount .'" id="pf-amount" readonly required/> ' ;
617+ }elseif ($ recur == 'optional ' ){
618+ echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" required/> ' ;
617619 }else {
618620 if ($ amount == 0 ) {
619621 echo '<input type="text" name="pf-amount" class="pf-number" id="pf-amount" required/> ' ;
@@ -627,30 +629,29 @@ function kkd_pff_paystack_form_shortcode($atts) {
627629 echo '</div>
628630 </div> ' ;
629631
630- if ($ recur != ' no ' ) {
631- if ( $ recur == ' optional ' ) {
632- echo ' <div class="span12 unit" >
633- <label class="label">Recuring Payment</label >
634- <div class="select" >
635- <select class="form-control" name="pf-interval" >
636- <option value="no">None </option>
637- <option value="hourly">Hourly </option>
638- <option value="daily">Daily </option>
639- <option value="weekly">Weekly </option>
640- <option value="monthly">Monthly </option>
641- <option value="annually">Annually</option >
642- </select >
643- <i></i >
644- </div>
645- </div> ' ;
646- } else {
647- echo '<input type="hidden" name="pf-plancode" value=" ' . $ recurplan . ' " /> ' ;
648- echo ' <div class="span12 unit" >
649- <label class="label" style="font-size:18px;font-weight:600;line-height: 20px;"> ' . $ plan -> data -> name . ' ' . $ plan -> data -> interval . ' recuring payment - ' . $ plan -> data -> currency . ' ' . number_format ( $ planamount ). ' </label>
650- </div> ' ;
651- }
632+ if ($ recur == ' optional ' ) {
633+ echo ' <div class="span12 unit">
634+ <label class="label">Recuring Payment</label >
635+ <div class="select" >
636+ <select class="form-control" name="pf-interval" >
637+ <option value="no">None</option >
638+ <option value="hourly">Hourly </option>
639+ <option value="daily">Daily </option>
640+ <option value="weekly">Weekly </option>
641+ <option value="monthly">Monthly </option>
642+ <option value="annually">Annually </option>
643+ </select >
644+ <i></i >
645+ </div >
646+ </div> ' ;
647+ } elseif ( $ recur == ' plan ' ){
648+ echo ' <input type="hidden" name="pf-plancode" value=" ' . $ recurplan . ' " /> ' ;
649+ echo '<div class="span12 unit">
650+ <label class="label" style="font-size:18px;font-weight:600;line-height: 20px;"> ' . $ plan -> data -> name . ' ' . $ plan -> data -> interval . ' recuring payment - ' . $ plan -> data -> currency . ' ' . number_format ( $ planamount ). ' </label >
651+ </div> ' ;
652+ }
653+
652654
653- }
654655 echo (do_shortcode ($ obj ->post_content ));
655656
656657 // echo '<br /><p>Transaction charge:'.$currency.'<b class="txn_charge">13,000</b></p>';
@@ -1021,6 +1022,7 @@ function kkd_pff_paystack_confirm_payment() {
10211022
10221023 $ payment_array = $ record [0 ];
10231024 $ amount = get_post_meta ($ payment_array ->post_id ,'_amount ' ,true );
1025+ $ recur = get_post_meta ($ payment_array ->post_id ,'_recur ' ,true );
10241026 $ currency = get_post_meta ($ payment_array ->post_id ,'_currency ' ,true );
10251027
10261028
@@ -1044,25 +1046,33 @@ function kkd_pff_paystack_confirm_payment() {
10441046 if ( 'success ' == $ paystack_response ->data ->status ) {
10451047 $ amount_paid = $ paystack_response ->data ->amount / 100 ;
10461048 $ paystack_ref = $ paystack_response ->data ->reference ;
1047-
1048- if ($ amount == 0 ) {
1049+ if ($ recur == 'optional ' || $ recur == 'plan ' ) {
10491050 $ wpdb ->update ( $ table , array ( 'paid ' => 1 ,'amount ' =>$ amount_paid ),array ('txn_code ' =>$ paystack_ref ));
10501051 $ thankyou = get_post_meta ($ payment_array ->post_id ,'_successmsg ' ,true );
10511052 $ message = $ thankyou ;
10521053 $ result = "success " ;
1053- // kkd_pff_paystack_send_receipt($currency,$amount,$name,$payment_array->email,$code,$metadata)
10541054 }else {
1055- if ( $ amount != $ amount_paid ) {
1056- $ message = "Invalid amount Paid. Amount required is " .$ currency ."<b> " .number_format ($ amount )."</b> " ;
1057- $ result = "failed " ;
1058- }else {
10591055
1060- $ wpdb ->update ( $ table , array ( 'paid ' => 1 ),array ('txn_code ' =>$ paystack_ref ));
1056+ if ($ amount == 0 ) {
1057+ $ wpdb ->update ( $ table , array ( 'paid ' => 1 ,'amount ' =>$ amount_paid ),array ('txn_code ' =>$ paystack_ref ));
10611058 $ thankyou = get_post_meta ($ payment_array ->post_id ,'_successmsg ' ,true );
10621059 $ message = $ thankyou ;
10631060 $ result = "success " ;
1061+ // kkd_pff_paystack_send_receipt($currency,$amount,$name,$payment_array->email,$code,$metadata)
1062+ }else {
1063+ if ( $ amount != $ amount_paid ) {
1064+ $ message = "Invalid amount Paid. Amount required is " .$ currency ."<b> " .number_format ($ amount )."</b> " ;
1065+ $ result = "failed " ;
1066+ }else {
1067+
1068+ $ wpdb ->update ( $ table , array ( 'paid ' => 1 ),array ('txn_code ' =>$ paystack_ref ));
1069+ $ thankyou = get_post_meta ($ payment_array ->post_id ,'_successmsg ' ,true );
1070+ $ message = $ thankyou ;
1071+ $ result = "success " ;
1072+ }
10641073 }
10651074 }
1075+
10661076 }else {
10671077 $ message = "Transaction Failed/Invalid Code " ;
10681078 $ result = "failed " ;
0 commit comments