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_checkout.php
<?php

/***
 * 
 * Title : CheckOut Page
 * Date : 25 Mar,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;

if (is_user_logged_in()) {
    if (isset($_REQUEST['ref_id'])) {

        //remove discount if code status
        if (isset($_SESSION['DISCOUNT_ID'])) {
            unset($_SESSION['DISCOUNT_ID']);
        }

        $slot_id = $_REQUEST['ref_id'];
        $txn_type = $_REQUEST['txn_type'];
        if ($txn_type == 'C') {
            $getSlotDetails = $wpdb->get_row("SELECT ps.id, ps.time_dur, ps.time_slot_hr, ps.time_slot_min, ps.pricing_for_slot, ps.counselor_id, pc.counselor_name 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;
            $time_dur = $getSlotDetails->time_dur;
            $slot_hr = $getSlotDetails->time_slot_hr;
            $slot_min = $getSlotDetails->time_slot_min == 0 ? '00' : $getSlotDetails->time_slot_min;
            $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;
        }

        //encoded parameters
        function random_strings($length_of_string)
        {
            $str_result = '0123$456789ABC#DEFGHIJKL$MNOPQRST@UVWXYZab!cdefghijklmnopqrstuvwxyz';

            return substr(str_shuffle($str_result), 0, $length_of_string);
        }

        //ref_id
        $encodedRefId = rtrim(strtr(base64_encode($slot_id), '+/', '-_'), '=');
        $shuffle = random_strings(7);
        $backShuffle = random_strings(6);
        $ref_id = $shuffle . $encodedRefId . $backShuffle;

        //type
        $encodedType = rtrim(strtr(base64_encode($txn_type), '+/', '-_'), '=');
        $shuffle = random_strings(7);
        $backShuffle = random_strings(6);
        $plan_type = $shuffle . $encodedType . $backShuffle;

        //Amount 
        $encodedAmt = rtrim(strtr(base64_encode($amount), '+/', '-_'), '=');
        $shuffle = random_strings(7);
        $backShuffle = random_strings(6);
        $amount_string = $shuffle.$encodedAmt.$backShuffle;
?>
        <style>
            .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 -->
        <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>

                                <table class="table">
                                    <thead>
                                        <tr class="bg">
                                            <th>Slot</th>
                                            <th>TIme Duration</th>
                                            <th>Start From</th>
                                            <th>Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr class="cart_item">
                                            <input type="hidden" name="siteUrl" id="siteUrl" value="https://selfanalyse.com/">
                                            <td class="product-name">
                                                Booked
                                            </td>
                                            <td class="product-total">
                                                <span class="amount"><i class="fa fa-clock"></i> <?php echo $time_dur; ?> min.</span>
                                            </td>
                                            <td class="product-total">
                                                <span class="amount"><i class="fas fa-stopwatch"></i> <?php echo $slot_hr . ':' . $slot_min  ?></span>
                                            </td>
                                            <td class="product-total">
                                                <span class="amount">₹ <?php echo $amount; ?></span>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            <?php } else if ($txn_type == 'P') {
                            ?>
                                <h4><?php echo $plan_name ?></h4>
                                <table class="table" id="valueList">
                                    <thead>
                                        <tr class="bg">
                                            <th>Plan</th>
                                            <th>Pay Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr class="cart_item">
                                            <input type="hidden" name="siteUrl" id="siteUrl" value="https://selfanalyse.com/">
                                            <td class="product-total">
                                                <span class="amount"> <?php echo $plan_name ?></span>
                                            </td>
                                            <td class="product-total">
                                                <span class="amount">₹ <?php echo $amount; ?></span>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <div>
                                    <ul class="payment-method-ul methods" id="payment_methods">
                                        <div id="discount-loading"></div>
                                        <li class="payment_method_bacs" id="li_online_trx">
                                            <label>Apply Discount Code If you Have ?</label>
                                            <div style="display: block;" class="details-box apply-code-input" id="tt_discount_code">
                                                <input type="text" name="se_discCode" id="se_discCode" value="" placeholder="Enter Discount Code...">
                                                <button type="button" class="btn btn-primary btn-sm" id="se_check">Apply Code</button>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            <?php
                            }
                            ?>
                            <!-----Razor---------->
                            <div id="payment" class="payment-method-line">
                                <ul class="payment-method-ul methods" id="payment_methods">
                                    <li class="payment_method_bacs" id="li_online_trx">
                                        <!-- <input checked="checked" type="radio" data-order_button_text="" value="" name="payment_method" class="input-radio" id="payment_method_razorpay"> -->
                                        <label for="payment_method_online">Online Payment</label>
                                        <div style="display: block;" class="details-box" id="tt_payment_payu">
                                            Pay amount online using Net Banking, Credit/Debit Cards, Wallets...
                                        </div>
                                    </li>
                                </ul>
                                <div class="form-row place-order" id="step-1">
                                    <input type="submit" data-value="Place order" value="Confirm Booking" id="place_order" name="checkout_place_order" class="apply-code-btn">
                                </div>
                                <div id="step-2" style="display: none;">
                                    <input type="hidden" id="slot_info" name="slot_info" value="<?php echo $ref_id; ?>">
                                    <input type="hidden" id="plan_info" name="plan_info" value="<?php echo $plan_type; ?>">
                                    <input type="hidden" id="category" name="category" value="psychometric-test-register">
                                    <input type="hidden" value="razorpay" id="payMethod" name="payMethod" />
                                    <input type="hidden" id="enc_string" name="enc_string" value="<?= $amount_string; ?>">
                                    <input type="hidden" name="siteUrl" id="siteUrl" value="<?php echo ROOT_LINK; ?>" />
                                    <input type="hidden" name="pageUrl" id="pageUrl" value="<?php echo ROOT_LINK . 'psychometric-test'; ?>" />
                                    <input type="hidden" name="discount_id" id="discount_id" value="" />
                                    <input type="hidden" value="1" id="txn_type" name="txn_type" />

                                    <div class="alert alert-warning"><span id="msg"></span></div>

                                    <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
                                    <form name='razorpayform' action="/thank-you" method="POST">
                                        <input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id">
                                        <input type="hidden" name="razorpay_resp_id" id="razorpay_resp_id" value="">
                                        <input type="hidden" name="razorpay_resp_id2" id="razorpay_resp_id2" value="">
                                        <input type="hidden" name="razorpay_signature" id="razorpay_signature">
                                        <input type="hidden" name="resp_id" id="resp_id" value="">
                                    </form>
                                </div>
                            </div>
                            <!-----Razor---------->
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <script src="/wp-content/plugins/psychometrics/js/psy_checkout.js?v=<?= date('dmyhis'); ?>"></script>
        <script type="text/javascript">
            //discount code check
            jQuery(document).on('click', '#se_check', function() {
                jQuery("#discount-loading").addClass("loading_image");
                var se_discCode = jQuery("#se_discCode").val();
                if (se_discCode == '') {
                    toastr.error("Please Enter discount code...");
                    jQuery("#discount-loading").removeClass("loading_image");
                } else {
                    var arr = {
                        "type": "code",
                        "coupon_code": se_discCode
                    };
                    var url = '<?php echo get_site_url() . '/wp-content/plugins/psychometrics/api/psy_discount_check.php'; ?>';
                    jQuery.ajax({
                        url: url,
                        type: 'POST',
                        data: JSON.stringify(arr),
                        contentType: 'application/json; charset=utf-8',
                        dataType: 'json',
                        async: false,
                        success: function(data) {
                            jQuery("#discount-loading").removeClass("loading_image");
                            if (data[0].status == 1) {
                                toastr.success(data[0].message);
                                var real = '<?php echo $amount ?>';
                                var percent_get = percentage(real, data[0].percent)
                                var send = real - percent_get
                                jQuery("#realAmt").val(send)
                                jQuery("#tt_discount_code").empty()
                                //jQuery("#newAmt").html("₹"+send)
                                jQuery('#valueList tr:last').after('<tr><td class="product-total1">Discount of ' + data[0].percent + '% Applied :</td><td class="product-total">₹ ' + percent_get + '</td></tr><tr><td class="product-total1">Final Pay Amount : </td><td class="product-total">₹ ' + send + '</td></tr>');
                                jQuery("#discount_id").val(data[0].discount_id);
                                jQuery("#tt_discount_code").html(data[0].message)

                            } else {
                                toastr.error(data[0].message);
                            }
                        }
                    });
                }
            });

            //calculate percentage
            function percentage(num, per) {
                return (num / 100) * per;
            }
        </script>
        <!-- END CHECKOUT SECTION -->
    <?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
}
?>