<?php
require('../config.php');
require('razorpay-php/Razorpay.php');
session_start();

// Create the Razorpay Order

use Razorpay\Api\Api;
 $keyId = $keyId;
 $keySecret = $keySecret;
// $keyId = 'rzp_live_isgZOqgPKrfIRR';
// $keySecret = '0Lvq3bpha3lGlVmEBGxR6GEB';
$displayCurrency = 'INR';
$api = new Api($keyId, $keySecret);

$amount = $_GET["amount"];
$name = $_GET["name"];
$phone = $_GET["phone"];
$email = $_GET["email"];
$userid = $_GET["userid"];
$id = $_GET["id"];
$deptid = $_GET['deptid'];
$BatchId = $_GET['BatchId'];

$razorpayOrder = $api->order->create(array(
    'receipt'         => 'ORD'.rand(1000,9999),
    'amount'          => $amount * 100, // 2000 rupees in paise
    'currency'        => 'INR',
    'payment_capture' => 1 // auto capture
));
?>
<html>
  <head>
    <title> The Yash Academy Txn with RazorPay </title>
    <meta name="viewport" content="width=device-width">
    <style>
      .razorpay-payment-button {
        color: #ffffff !important;
        background-color: #7266ba;
        border-color: #7266ba;
        font-size: 14px;
        padding: 10px;
        margin: 0;
        position: absolute;
  top: 20%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
      }
    </style>
  </head>
  <body>
      <h1 style="color:red;font-size: 11px;">Do Not Go to Next or Previous Page as it will lead to wrong transaction.</h1>
    <form action="sucess.php?userid=<?php echo $userid;?>&id=<?php echo $id;?>&deptid=<?php echo $deptid;?>&BatchId=<?php echo $BatchId;?>&amount=<?php echo $amount;?>" method="POST">
    <!-- Note that the amount is in paise = 50 INR -->
    <script
        src="https://checkout.razorpay.com/v1/checkout.js"
        data-key="<?php echo $keyId; ?>"
        data-amount="100"
        
        data-buttontext="Pay Now"
        data-name="The Yash Academy"
        data-order_id="<?php echo $razorpayOrder->id; ?>"
        data-description="The Yash Academy Txn with RazorPay"
        data-image=""
        data-prefill.name="<?php echo $name; ?>"
        data-prefill.email="<?php echo $email; ?>"
        data-prefill.contact="<?php echo $phone; ?>"
        data-theme.color="#27457b"
    ></script>
    <input type="hidden" value="Hidden Element" name="hidden">
    </form>
  </body>
</html>