How to integrate payment gateway in PHP? OR How to integrate Razorpay with my PHP website?
How to integrate Razorpay payment gateway in PHP?
Payment gateway in php form will be as below Watch above full video:
For More Details :
Follow the below code to create an above HTML form:
<!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 style="color:blue;">Razorpay Payment Integration in PHP</h2>
<form action="#">
<div class="mb-3 mt-3">
<label for="email" style="color:blue;">User Name:</label>
<input type="email" class="form-control" id="name" placeholder="Enter Payee Name" name="name">
</div>
<div class="mb-3">
<label for="pwd" style="color:blue;">Amount:</label>
<input type="number" class="form-control" id="amount" placeholder="Enter Amount" name="amount">
</div>
<div class="mb-3">
<label for="pwd" style="color:blue;">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" onclick="pay_now()">Pay</button>
</form>
</div>
</body>
</html>
Below is the code for an Razorpay to integarte in php:
<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">
function pay_now(){
//here we are taking output from form
var name = $("#name").val();
var amount = $("#amount").val();
var actual_amount = amount*100;
var description = $('#description').val();
var options = {
"key": "rzp_test_FViTaNsOKBZAyt", // Enter the Key ID generated from the Dashboard
"amount": actual_amount, // Amount is in currency subunits.
"currency": "INR",
"name": name,
"description": description,
"image": "",
//"order_id": "order_IluGWxBm9U8zJ8",
"handler": function (response){
console.log(response);
},
};
var rzp1 = new Razorpay(options);
rzp1.on('payment.failed', function (response){
});
document.getElementById('rzp-button1').onclick = function(e){
rzp1.open();
e.preventDefault();
}
}
</script>
You will get full code Below:
<!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 style="color:blue;">Razorpay Payment Integration in PHP</h2>
<form action="#">
<div class="mb-3 mt-3">
<label for="email" style="color:blue;">User Name:</label>
<input type="email" class="form-control" id="name" placeholder="Enter Payee Name" name="name">
</div>
<div class="mb-3">
<label for="pwd" style="color:blue;">Amount:</label>
<input type="number" class="form-control" id="amount" placeholder="Enter Amount" name="amount">
</div>
<div class="mb-3">
<label for="pwd" style="color:blue;">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" onclick="pay_now()">Pay</button>
</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">
function pay_now(){
//here we are taking output from form
var name = $("#name").val();
var amount = $("#amount").val();
var actual_amount = amount*100;
var description = $('#description').val();
var options = {
"key": "rzp_test_FViTaNsOKBZAyt", // Enter the Key ID generated from the Dashboard
"amount": actual_amount, // Amount is in currency subunits.
"currency": "INR",
"name": name,
"description": description,
"image": "",
//"order_id": "order_IluGWxBm9U8zJ8",
"handler": function (response){
console.log(response);
},
};
var rzp1 = new Razorpay(options);
rzp1.on('payment.failed', function (response){
});
document.getElementById('rzp-button1').onclick = function(e){
rzp1.open();
e.preventDefault();
}
}
</script>
After execution of this you will get the output with Razorpay
This code is an illustration of a website page that exhibits Razorpay installment reconciliation in PHP. It gives a structure where clients can enter their name, sum, and depiction for an installment. When the "Pay" button is clicked, a JavaScript capability called "pay_now()" is summoned to start the installment interaction.
The structure utilizes Bootstrap classes for styling and responsiveness. It incorporates input fields for the client's name, sum, and depiction. The "Pay" button has the ID "rzp-button1" and is related with the JavaScript capability "pay_now()".
Generally, this code sets up a fundamental installment structure involving Razorpay for PHP. In any case, if it's not too much trouble, note that the genuine installment handling rationale and mix with Razorpay's Programming interface are excluded from this code piece. To finish the installment mix and handle the server-side handling, you would have to execute the important backend code and interface it with the Razorpay Programming interface.
For More Details :
Contact : info@infysky.com
Post a Comment