Site icon Learn Web Development & Programming, Artificial Intelligence, WordPress, Shopify Articles

Integrating Razorpay Payment Gateway in PHP

Easy Integration of Razorpay Payment Gateway in PHP

If you want to integrate the Razorpay payment gateway into your PHP website, you’re in the right place! This tutorial guides you through the process in a simple and user-friendly way. Let’s get started and make your website payments smoother than ever.

Razorpay is your go-to choice for hassle-free online payments. It’s not just reliable; it’s super easy to set up compared to other gateways. Whether your customers prefer debit, credit, net banking, UPI, or digital wallets, Razorpay covers them.

Integrating Razorpay into a PHP application involves several steps. Below is a basic guide to getting you started. You should refer to the official Razorpay documentation for the latest information.

A Step-by-Step Guide: Integrate Razorpay payment gateway to your PHP website

Step 1: Create a Razorpay account

If you don’t have an account, sign up for a Razorpay account at https://dashboard.razorpay.com/

Step 2: Get API Keys

Step 3: Create your HTML form to get the customer details

Let’s create a bootstrap normal form to get customer information and amount details.

Create an index.php page and Copy and Paste the following code into your index.php file.

Include the Razorpay Checkout script in your index.php file:

Now add the below script code in the index.php file, this code will act on the form submit button click. This is the Razorpay checkout js code which populates the payment popup form.

In the above JS code, When the user clicks on the pay now button we will get the customer details like name, email, mobile, and price using JS. Also, you can see the Ajax code to process the Razorpay payment. When payment succeeds or fails you will get redirected to the page based on the above script redirection.

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Step 4: Write the Ajax process to Create an order using Razorpay API

In this step, we’ve created the ‘submitpayment.php’ code file to manage AJAX post requests.

Within this file, you have the flexibility to handle database insertion tasks and create orders through Razorpay API calls.

Step 5: Create a Payment Success Page

After a successful payment process, users will be redirected to a success page. In the index.php file mentioned above, once you receive the success response, you’ll need to redirect the user to the payment-success.php page.

Use the below payment-success.php file code

Output:

Step 6: Create a Payment Failed Page

Use the below payment-failed.php file code

That’s it.

Payment Test Card Details

Wrapping Words

These are the simple and easy steps to Integrate Razorpay Payments to Your PHP Website. You can modify and customize code as per your requirements.

Do you want to get implementation help, or modify or extend the functionality of this script? Submit a paid service request

FAQs

How to create a Razorpay account?

If you don’t have an account, sign up for a Razorpay account at https://dashboard.razorpay.com/

Is Razorpay good for online payment?

Razorpay is your go-to choice for hassle-free online payments. It’s not just reliable; it’s super easy to set up compared to other gateways. Whether your customers prefer debit, credit, net banking, UPI, or digital wallets, Razorpay covers them.

How to Get Razorpay API Keys?

1. Log in to your Razorpay Dashboard.
2. Navigate to the “Account & Settings” > “API Keys” section to get your API key and secret key.

What are the Razorpay payment Test Card Details?

Please find the below card details

How to hire the best freelancer/developer to integrate Razorpay Payment Gateway into the PHP website?

You can hire “Pradeep Maurya Freelance Developer” to integrate RazorPay Payment Gateway in your website. You can directly content on WhatsApp: +91-8218920611

Top 5 payment gateway is best in India?

1. Razorpay
2. PhonePe
3. Cashfree Payments.
4. PayU.
5. Instamojo.

Exit mobile version