<script type="text/javascript">
document.title = "Course Payment";
</script>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<link rel="stylesheet" href="<?php echo admin_css() ?>plugins/sweetalert/sweetalert.min.css">
<script src="<?php echo admin_css() ?>plugins/sweetalert/sweetalert.min.js"></script>
<button id="rzp-button1" style="display:none;">Pay with Razorpay</button>
<form name='razorpayform' id="razorpayform">
    <input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id">
    <input type="hidden" name="razorpay_signature"  id="razorpay_signature" >
</form>
<script>
$(document).ready(function(e){
    // Checkout details as a json
    var options = <?php echo json_encode($data);?>;

    /**
     * The entire list of Checkout fields is available at
     * https://docs.razorpay.com/docs/checkout-form#checkout-fields
     */
    options.handler = function (response){
        document.getElementById('razorpay_payment_id').value = response.razorpay_payment_id;
        document.getElementById('razorpay_signature').value = response.razorpay_signature;
        // document.razorpayform.submit();
        var form = $('#razorpayform');
        $.ajax({
             type: "POST",
             url: "<?php echo base_url().'/home/rezorpay_payment_for_atp_reg';?>",
             data: form.serialize(), 
             success: function(data)
             {
                swal('Done!', 'Form Submit Successfully', 'success');
                window.location = "<?php echo base_url(); ?>partnerRegistration/<?php echo $this->session->userdata('u_course'); ?>";
             }
        });
    };

    // Boolean whether to show image inside a white frame. (default: true)
    options.theme.image_padding = false;

    options.modal = {
        ondismiss: function(){
           // window.history.back();
            <?php $send = $_SERVER['HTTP_REFERER'];?> 
            var redirect_to="<?php echo $send;?>";    

            //to redirected to this link
            location.assign(redirect_to);
        },
        escape: true,
        backdropclose: false
    };


    var rzp = new Razorpay(options);
	$("#rzp-button1").click();
	 rzp.open();
    e.preventDefault();
});

function ss()
{
    window.history.back()
}
</script>
