If you want to integrate PhonePe payment gateway on your php laravel website/application, it’s not just about Laravel code. You need to get a merchant account for handling payments, grab some API credentials, and set up how the payment function works.
Let’s start php laravel PhonePe payment gateway Integration into your website/application.
Suggested Read: How to Integrate PhonePe Payment Gateway in PHP
There is no need to worry about creating an account for testing the PhonePe payment gateway – the test credentials are open to everyone. But when you’re ready to take the live / production keys for real payments, log in or register on PhonePe Business Solutions.
Suppose you already have a merchant account and API credentials for your PhonePe gateway.
PhonePe API Credentials
Test Credentials :
Merchant ID : PGTESTPAYUAT
Salt Key: 099eb0cd-02cf-4e2a-8aca-3e6c6aff0399
Test Card Details:
Card: 4242 4242 4242 4242
Expiry: 12/25 (any future date)
CVV: 357
OTP: 987654
Are you want to get implementation help, or modify or extend the functionality?
A Tutorialswebsite Expert can do it for you.
Step 1: Create a controller
Step 2: Let’s Build Your Payment Form
Next up, we’re going to create a user-friendly payment form. This form will enable you to request the necessary details and receive the confirmation. Let’s get started!
Now create a payment form at the location: resources/views/payment-form.blade.php
Copy and Paste the below code on the above file.

Step 3: Create Routes in web.php
Let’s create 3 routes in your web.php file. The 1st route will load a Phonepe request, 2nd route will handle the submitted payment form request, 3rd route will handle the response from the Phonepe server in the form of a “SUCCESS” response or “FAILED” response.
Step 4: Create a Model to Insert Data into a Table
To insert data into a table in Laravel, If you don’t already have a model for your table, you can create one using the following command:
Open the generated model file (located in the app directory) and define the model class and the associated table name:
Step 5: Create a Payment Function
Now create a function named index in PaymentController.php
Now create a function named submitPaymentForm in PaymentController.php
PhonePe Checkout Page

Step 6: Setting Up the Callback Function
Now, let’s make a function called “confirmPayment” in PaymentController.php. In this function, we’ll handle and receive PhonePe transaction details like code, merchantId, transactionId, amount, providerReferenceId, checksum, and more.
Note: You will receive transaction data using the POST method.
Now create a response view page at the location: resources/views/confirm_payment.blade.php and and display providerReferenceId and transactionId.

Step 7: Exclude callback URL
As PhonePe’s payment callback works with the POST method and doesn’t include a CSRF token from their side. So we need to exclude CSRF verification for the PhonePe callback URL.
To achieve this, add the callback URL to a middleware located in app/Http/Middleware/VerifyCsrfToken.php.
It’s done, Now you can make the payment in test mode. http://yourdomain.com/payment/
Note: Please replace ‘YOUR_API_KEY’, ‘YOUR_MERCHANT_ID’, ‘YOUR_ORDER_ID’, ‘YOUR_REDIRECT_URL’, and other placeholders with your actual credentials and data.
👍
UAT OR SANDBOX API
UAT Host URL: https://api-preprod.phonepe.com/apis/pg-sandbox
API End Point: /pg/v1/payUAT PAY API URL: https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/pay
Are you want to get implementation help, or modify or extend the functionality?
A Tutorialswebsite Expert can do it for you.
Wrapping Words
These are the simple and easy steps to Integrate PhonePe Payment Gateway in PHP. 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
Related Article
Integrate Recurring Stripe Subscription Payment with PHP
Integrate Blockonomics bitcoin payment gateway in PHP
FAQs

Pradeep Maurya is the Professional Web Developer & Designer and the Founder of “Tutorials website”. He lives in Delhi and loves to be a self-dependent person. As an owner, he is trying his best to improve this platform day by day. His passion, dedication and quick decision making ability to stand apart from others. He’s an avid blogger and writes on the publications like Dzone, e27.co
[…] PhonePe Payment Gateway Integration in Laravel […]
[…] Suggested Read: How to Integrate PhonePe Payment Gateway in Laravel […]