ok

Mini Shell

Direktori : /home2/selectio/public_html/wedding-info-new/
Upload File :
Current File : /home2/selectio/public_html/wedding-info-new/payment.php

<?php
include_once 'config/config.php'; // Assuming this file contains database connection details
session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Razorpay</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
 
<div class="container mt-3" style="width: 50%;">
  <h2>Razorpay Payment Integration in PHP</h2>
  <form id="paymentForm" method="post">
    <div class="mb-3 mt-3">
      <label for="payee_name">Payee Name:</label>
      <input type="text" class="form-control" id="payee_name" placeholder="Enter Payee Name" name="payee_name" Value='<?=$_SESSION['user']['profile_name']?>'>
    </div>
    <div class="mb-3">
      <label for="amount">Amount:</label>
      <input readonly  type="number" class="form-control" id="amount" placeholder="Enter Amount" name="amount" Value='<?=$_GET['price']?>'>
      <input type="hidden" class="form-control" id="amount" placeholder="Enter Amount" name="amount" Value='<?=$_GET['price']?>'>
    </div>
    <div   class="mb-3">
      <label for="amount">Plan:</label>
      <input  type="number" class="form-control" id="plan" placeholder="Enter plan" name="plan" Value='<?=$_GET['plan']?>'>
    </div>
    <div class="mb-3">
      <label for="description">Item Description:</label>
      <input type="text" class="form-control" id="description" placeholder="Enter Description" name="description">
    </div>
    <button type="button" class="btn btn-primary" id="rzp-button1">Pay</button>
  </form>
  <!-- Add a hidden input field to store JSON data -->

<!-- Form to submit payment details to the next page -->
<form id="payment_form" method="POST" hidden action="api/process_payment.php">
<input type="hidden" id="payment_details_input" name="payment_details">
    <!-- Add any other form fields if needed -->
</form>

</div>
 
</body>
</html>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#rzp-button1').on('click', function(e) {
            e.preventDefault();
            pay_now();
        });

        function pay_now() {
            var name = $("#payee_name").val();
            var amount = $("#amount").val();
            var description = $('#description').val();
            var plan = $('#plan').val();

            var options = {
                "key": "rzp_test_QPuepWvrvsEsgp", // Enter your Razorpay key
                "amount": amount * 100, // Convert amount to paise if using INR
                "currency": "INR",
                "name": name,
                "description": description,
                "image": "razorpay.png",
                "handler": function(response) {
                    // Create JSON object with payment details
                    var paymentDetails = {
                        "razorpay_payment_id": response.razorpay_payment_id,
                        "name": name,
                        "amount": amount,
                        "description": description,
                        "plan":plan,
                    };

                    // Convert JSON object to string
                    var paymentDetailsString = JSON.stringify(paymentDetails);

                    // Store stringified JSON data in hidden input field
                    $('#payment_details_input').val(paymentDetailsString);

                    // Submit the form
                    $('#payment_form').submit();
                },
                "prefill": {
                    "name": name,
                    "email": "" // You can add customer email here if you have it
                },
                "theme": {
                    "color": "#3399cc" // Customize the Razorpay button color
                }
            };

            var rzp1 = new Razorpay(options);
            rzp1.open();
        }
    });
</script>
<script type="text/javascript">
    $(document).ready(function() {
         pay_now();
    }
</script>
        



Zerion Mini Shell 1.0