<div class="payment_content text-center">
	<div class="payment_icon payment">
		<img src="<?php echo base_url('assets/images/razorpay.png'); ?>" alt="">
	</div>

	<div class="payment_details">
		<h4> <?= isset($u_info['username'])?html_escape($u_info['username']):'';?></h4>
		<div class="">
			<h2><?= get_currency('icon');?> <?= isset($package['price'])?html_escape($package['price']):'';?> / <?= !empty(lang($package['type']))?lang($package['type']):$package['type']?></h2>
			<p><b><?= !empty(lang('package_name'))?lang('package_name'):"Package Name"?> : </b> <?= html_escape($package['type_name']);?></p>
		</div>
		<p class="payment_text">*<?= !empty(lang('payment_by'))?lang('payment_by'):"Payment via"?> <i class="fa fa-credit-card-alt fa-2x"></i></p>
	</div>

	<?php include 'couponForm.php'; ?>

	<?php if(is_demo()==0): ?>
		<button type="button" data-amount="<?= $total_price;?>" data-id="<?= isset($package['id'])?html_escape($package['id']):'';?>" data-name="<?=  $u_info['username'];?>" class="btn btn-success buy_now"><?= !empty(lang('pay_now'))?lang('pay_now'):"Pay Now"?> </button>

		
	<?php endif;?>

</div><!-- payment_content -->

<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>

var key = $('#razorpay_key').attr('href');
var base_url = $('#base_url').attr('href');
var csrf_value = $('#csrf_value').attr('href');
if(key){
$('body').on('click', '.buy_now', function(e){
	$('.buy_now').prop("disabled",true);
	var totalAmount = $(this).attr("data-amount");
	var product_id =  $(this).attr("data-id");
	var username =  $(this).attr("data-name");
	var options = {
		"key": key,
		"amount": totalAmount*100, // 2000 paise = INR 20
		"name": username,
		"description": "Payment",
		"image": base_url+"assets/images/razorpay.png",
		"handler": function (response){
			$.ajax({
				url: base_url + 'payment/razorpay_payment_success',
				type: 'post',
				dataType: 'json',
				data: {
				razorpay_payment_id: response.razorpay_payment_id , totalAmount : totalAmount ,product_id : product_id,csrf_test_name: csrf_value, username : username
				}, 
				success: function (msg) {
					window.location.href = base_url + 'payment/razorpay_seccess';
				}
			});
		},
		"theme": {
		"color": "#528FF0"
		}
	};
	var rzp1 = new Razorpay(options);
		rzp1.open();
		e.preventDefault();
	});
}
</script>