HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/selfanalyse/wp-content/plugins/psychometrics/psy_payment_confirmation_page.php
<?php

/***
 * 
 * Title :Payment Confirmation Page
 * Date :3 June ,2020
 * Description : Page for accepting payment through payU or any other payment method.
 */

global $wpdb;
$PSY_SLOT_AVAILABLE = $wpdb->prefix . PSY_SLOT_AVAILABLE;
$PSY_COUNSELORS = $wpdb->prefix . PSY_COUNSELORS;
$PSY_PLANS = $wpdb->prefix . PSY_PLANS;
$PSY_DISCOUNT_CODE = $wpdb->prefix . PSY_DISCOUNT_CODE;
if (is_user_logged_in()) {
    if (isset($_REQUEST['message'])) {

        $params = $_REQUEST['message'];
        $discount_id = $_SESSION['DISCOUNT_ID'];

        $explodeParams = explode("|", $params);
        $encode_ref = $explodeParams[0];
        $encode_type = $explodeParams[1];

        //decode function
        function decodeReq($value)
        {
            $str = substr($value, 7);
            $str1 = substr($str, 0, -6);

            $decode = base64_decode($str1);
            return $decode;
        }

        //find percentage value
        function percentage($num, $per)
        {
            return ($num / 100) * $per;
        }

        $slot_id = decodeReq($encode_ref);
        $txn_type = decodeReq($encode_type);

        if ($txn_type == 'C') {
            $getSlotDetails = $wpdb->get_row("SELECT ps.id, pc.counselor_name,ps.counselor_id ,ps.pricing_for_slot FROM $PSY_SLOT_AVAILABLE as ps LEFT JOIN $PSY_COUNSELORS as pc on pc.counselor_id=ps.counselor_id WHERE ps.id='$slot_id'");

            $amount = $getSlotDetails->pricing_for_slot;
            $counselor_name = $getSlotDetails->counselor_name;
            $counselor = $getSlotDetails->counselor_id;
        } else if ($txn_type == 'P') {
            $getPlansDetails = $wpdb->get_row("SELECT plan_id, plan_name, plan_price FROM $PSY_PLANS where plan_id='$slot_id'");

            $plan_name = $getPlansDetails->plan_name;
            $amount = $getPlansDetails->plan_price;
        }

        if (isset($_SESSION['DISCOUNT_ID'])) {
            $discount_id = $_SESSION['DISCOUNT_ID'];
            $getdiscount = $wpdb->get_row("SELECT id,discount_value FROM $PSY_DISCOUNT_CODE where id='$discount_id' and status='1'");
            $percentValue = percentage($amount, $getdiscount->discount_value);

            $finalAmount = $amount - $percentValue;
        } else {
            $finalAmount = $amount;
        }
?>
        <style>
            .hide-div {
                display: none;
            }
            .loading_image {
                display: block;
                position: fixed;
                z-index: 1000;
                top: 0;
                left: 0;
                height: 100%;
                width: 100%;
                background: rgba(255, 255, 255, .8) url('/wp-content/themes/psychometrics/images/loading_image.gif') 50% 50% no-repeat;
            }
        </style>
        <!-- CHECKOUT SECTION -->
        <!-- this meta viewport is required for BOLT //-->
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <!-- <script id="bolt" src="https://checkout-static.citruspay.com/bolt/run/bolt.min.js" bolt-color="e34524" bolt-logo="http://boltiswatching.com/wp-content/uploads/2015/09/Bolt-Logo-e14421724859591.png"></script> -->
        <script id="bolt" src="https://checkout-static.citruspay.com/bolt/run/bolt.min.js" bolt-color="<color-
code>" bolt-logo="<image path>"></script>
        <section class="counselor-checkout-section">
            <div class="container">
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="counselor-checkout-box">
                            <?php if ($txn_type == 'C') { ?>
                                <h4>Booking Appointment with "<?php echo $counselor_name ?>"</h4>
                            <?php } else if ($txn_type == 'P') {
                            ?>
                                <h4><?php echo $plan_name ?></h4>
                            <?php
                            }
                            ?>
                            <div class="payment-method-line">
                                <ul class="payment-method-ul methods" id="payment_methods">
                                    <div id="discount-loading"></div>
                                    <li class="payment_method_bacs" id="li_online_trx">
                                        <label>Verify Payment</label>
                                        <div style="display: block;" class="details-box" id="tt_payment_payu">
                                            Payment To be done ₹ <?php echo $finalAmount ?> -/
                                        </div>
                                    </li>
                                </ul>
                                <div class="form-row place-order">
                                    <input type="button" data-value="Place order" value="Verify & Click" id="place_order" name="checkout_place_order" class="apply-code-btn">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <div class="modal fade" id="payu-verify-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-keyboard="false" data-backdrop="static">
            <div class="modal-dialog loginmodal-dialog" style="width: 30%;">
                <div id="book-loading"></div>
                <div class="loginmodal-container">
                    <h4>Verify Your Name</h4>
                    <div id="data-show">
                    </div>
                </div>
            </div>
        </div>
        <script>
            jQuery(document).ready(function() {
                //show data in modal
                jQuery("#place_order").click(function() {
                    jQuery("#payu-verify-modal").modal()
                    var slot = '<?php echo $slot_id; ?>'
                    var siteBaseUrl = "<?php echo get_site_url()  ?>/";
                    var url = siteBaseUrl + "wp-content/plugins/psychometrics/api/psy_payment_confirmation.php";
                    jQuery.ajax(url, {
                        type: 'GET',
                        dataType: 'html',
                        data: {
                            slot: slot
                        },
                        success: function(data) {
                            jQuery("#data-show").html(data);
                        },
                        error: function(jqXhr, textStatus, errorMessage) {}
                    });
                })

                //prevent modal from outside click
                // jQuery('#payu-verify-modal').modal({
                //     backdrop: 'static',
                //     keyboard: false
                // })
            });

            

            //save data in temp table
            function verify() {
                jQuery("#book-loading").addClass("loading_image");
                var name = jQuery('#fname').val();
                var state_verify = jQuery('#state_verify').val();
                if (name == '') {
                    toastr.error("Please fill your name");
                    jQuery("#book-loading").removeClass("loading_image");
                } else if (state_verify == 0) {
                    toastr.error("Please fill state");
                    jQuery("#book-loading").removeClass("loading_image");
                } else {
                    var arr = {
                        "txn_type": '<?php echo $txn_type ?>',
                        "ref_id": '<?php echo $slot_id ?>',
                        "counselor": '<?php echo $counselor ?>',
                        "payment_type": 'Payu',
                        "state_id": state_verify,
                        "hash_value": jQuery('#hash').val()
                    };
                    var siteBaseUrl = "<?php echo get_site_url()  ?>/";
                    var url = siteBaseUrl + "wp-content/plugins/psychometrics/api/psy_payment_temp.php";
                    jQuery.ajax({
                        url: url,
                        type: 'POST',
                        data: JSON.stringify(arr),
                        contentType: 'application/json; charset=utf-8',
                        dataType: 'json',
                        success: function(data) {
                            if (data[0].status == 1) {
                                jQuery("#book-loading").removeClass("loading_image");
                                launchBOLT();
                            }

                        }
                    });

                }
            }
            //create hash string on name type
            jQuery('#data-show').bind('keyup blur', function() {
                var siteBaseUrl = "<?php echo get_site_url()  ?>/";
                var url = siteBaseUrl + "wp-content/plugins/psychometrics/api/psy_payment_confirmation.php";
                jQuery.ajax({
                    url: url,
                    type: 'post',
                    data: JSON.stringify({
                        key: jQuery('#key').val(),
                        salt: jQuery('#salt').val(),
                        txnid: jQuery('#txnid').val(),
                        amount: '<?php echo $finalAmount ?>',
                        pinfo: jQuery('#pinfo').val(),
                        fname: jQuery('#fname').val(),
                        email: jQuery('#email').val(),
                        mobile: jQuery('#mobile').val(),
                        udf5: jQuery('#udf5').val()
                    }),
                    contentType: "application/json",
                    dataType: 'json',
                    success: function(json) {
                        if (json['error']) {
                            jQuery('#alertinfo').html('<i class="fa fa-info-circle"></i>' + json['error']);
                        } else if (json['success']) {
                            jQuery('#hash').val(json['success']);
                        }
                    }
                });
            });
            //-->

            function launchBOLT() {
                jQuery('#payu-verify-modal').modal('toggle');
                bolt.launch({
                    key: jQuery('#key').val(),
                    txnid: jQuery('#txnid').val(),
                    hash: jQuery('#hash').val(),
                    amount: '<?php echo $finalAmount ?>',
                    firstname: jQuery('#fname').val(),
                    email: jQuery('#email').val(),
                    phone: jQuery('#mobile').val(),
                    productinfo: jQuery('#pinfo').val(),
                    udf5: jQuery('#udf5').val(),
                    surl: jQuery('#surl').val(),
                    furl: jQuery('#surl').val(),
                    mode: 'dropout'
                }, {
                    responseHandler: function(BOLT) {
                        console.log(BOLT.response.txnStatus);
                        if (BOLT.response.txnStatus != 'CANCEL') {
                            //Salt is passd here for demo purpose only. For practical use keep salt at server side only.
                            var fr = '<form action=\"' + $('#surl').val() + '\" method=\"post\">' +
                                '<input type=\"hidden\" name=\"key\" value=\"' + BOLT.response.key + '\" />' +
                                '<input type=\"hidden\" name=\"salt\" value=\"' + $('#salt').val() + '\" />' +
                                '<input type=\"hidden\" name=\"txnid\" value=\"' + BOLT.response.txnid + '\" />' +
                                '<input type=\"hidden\" name=\"amount\" value=\"' + BOLT.response.amount + '\" />' +
                                '<input type=\"hidden\" name=\"productinfo\" value=\"' + BOLT.response.productinfo + '\" />' +
                                '<input type=\"hidden\" name=\"firstname\" value=\"' + BOLT.response.firstname + '\" />' +
                                '<input type=\"hidden\" name=\"email\" value=\"' + BOLT.response.email + '\" />' +
                                '<input type=\"hidden\" name=\"udf5\" value=\"' + BOLT.response.udf5 + '\" />' +
                                '<input type=\"hidden\" name=\"mihpayid\" value=\"' + BOLT.response.mihpayid + '\" />' +
                                '<input type=\"hidden\" name=\"status\" value=\"' + BOLT.response.status + '\" />' +
                                '<input type=\"hidden\" name=\"hash\" value=\"' + BOLT.response.hash + '\" />' +
                                '</form>';
                            var form = jQuery(fr);
                            jQuery('body').append(form);
                            form.submit();
                        } else {
                            window.location.href = '/counselors'
                        }
                    },
                    catchException: function(BOLT) {
                        alert(BOLT.message);
                    }
                });
            }
        </script>
    <?php
    } else {
    ?>
        <script>
            window.location.href = '<?php echo ROOT_LINK . 'counselors' ?>'
        </script>
    <?php
    }
} else {
    ?>
    <script>
        window.location.href = '<?php echo ROOT_LINK . 'login' ?>'
    </script>
<?php
}
?>