Site icon Tutorials Website: Upgrade Your Web Development & Coding Skills

How to Integrate PhonePe V2 Standard Checkout in PHP

Integrate Phonepe v2 in php

In today’s digital age, providing users with a quick, secure, and seamless payment experience is critical for any online business. PhonePe, one of India’s most popular digital payment platforms, now includes a robust Standard Checkout system in its V2 API version. This standard checkout system aims to simplify the payment process for customers while adhering to industry standards and optimizing transaction security.

In this article, we will walk you through the steps required to integrate the PhonePe V2 Standard Checkout into your PHP-based website or web application. From generating authentication tokens to initiating transactions and handling payment responses, you’ll learn how to build a secure, production-ready integration that meets PhonePe’s most recent standards.

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

A Tutorialswebsite Expert can do it for you.

Integrate PhonePe V2 Standard Checkout in PHP

Step 1: Generate Authorization Token

If you’re integrating PhonePe’s payment gateway into your application, you must ensure that communication between your server and PhonePe’s backend is secure. To achieve this, you must first generate an Auth Token, which is used to authorize all coming API requests.

An auth token is a security signature that authorizes requests from your backend to PhonePe. It is generated based on your client_id, client_version, client_secret, and grant_type.

To get this details

Create a file named “accessToken.php” and copy and paste the below code

Step-2: Initiate Payment Request

When you will receive the access token from step-1, then now we need to create payment and initiate the payment request.

Create a page named “index.php” and copy-paste the below code.

Output:

When the user clicks the Pay button, the PhonePe Standard Checkout will open in an iframe.

Upon completing the payment, the user will be redirected to the success page defined in the code above.

Test Card Details:

“card_number”: “4242424242424242”,

“Name”: “Test”

“card_type”: “DEBIT_CARD”,

“expiry_month”: 12,

“expiry_year”: 2027,

“cvv”: “936”

Looking for a Website Developer in Delhi NCR?

Get a professionally designed and developed website tailored to your needs.
As an experienced website developer based in Delhi NCR, I offer customized solutions to build responsive, SEO-friendly, and user-friendly websites. Whether it’s for a personal blog, business site, or e-commerce store, I ensure your online presence stands out.

Step 3: Handle Payment Response

Next, we’ll create a payment_success.php page to handle the payment response, display a success message to the customer, and store the transaction details in the database.

Copy and paste the below code to handle the transaction response and validate it. Checkout PhonePe API Document

Transaction details:

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

Wrapping Words

Once you’ve configured token generation, payment creation, and response handling, it’s easy to integrate PhonePe V2 Standard Checkout with PHP. Always test in a sandbox before going live.

Related Article:

Exit mobile version