UPI Integration
When your customer makes payment through UPI, you can validate the customer’s Virtual Payment Address (VPA) and then initiate payment. The validateVpa API is used to validate the UPI handle.
Steps to Integrate:
Before you begin:
Register for a account with PayU before you start integration. For more information, refer to Register for a Merchant Account.
Step 1: Validate the UPI handle
Validate the VPA (UPI handle) using the validateVpa API. For more information, refer to Validate VPA Handle API.
Step 2: Initiate the payment to PayU
Post request syntax & composition
Post Request Syntax & Composition for UPI
<body>
<form action='https://test.payu.in/_payment' method='post'>
<input type="hidden" name="key" value="JP***g" />
<input type="hidden" name="txnid" value="t6svtqtjRdl34W" />
<input type="hidden" name="productinfo" value="iPhone" />
<input type="hidden" name="amount" value="10" />
<input type="hidden" name="email" value="[email protected]" />
<input type="hidden" name="firstname" value="Ashish" />
<input type="hidden" name="lastname" value="Kumar" />
<input type="hidden" name="pg" value="UPI" />
<input type="hidden" name="bankcode" value="UPI" />
<input type="hidden" name="vpa" value="test123@okhdfcbank" />
<input type="hidden" name="surl" value="your own success url" />
<input type="hidden" name="furl" value="your own failure url" />
<input type="hidden" name="phone" value="9988776655” />
<input type="hidden" name="hash" value="eabec285da28fd0e3054d41a4d24fe9f7599c9d0b66646f7a9984303fd6124044b6206daf831e9a8bda28a6200d318293a13d6c193109b60bd4b4f8b09c90972" />
<input type="submit" value="submit"> </form>
</body>
</html>
Note
The above HTML code block is for Merchant Checkout integration on the UPI call for the test environment.
Request parameters
The following parameters vary for the UPI payment mode in the Collect Payment API (**_payment** API). For the complete list of parameters and response, refer to Collect Payments API under API Reference.
Parameter | Description | Example Value |
---|---|---|
pg | String It defines the payment category that the merchant wants the customer to see by default on the PayU’s payment page. This field must contain the value as "UPI" for UPI transactions. | UPI |
bankcode | String Each payment option is identified with a unique bank code at PayU. The merchant must post this parameter with the corresponding payment option’s bank code value in it. For a detailed list of bank codes, please contact the PayU Support. | UPI |
VPA | String The VPA of the customer. For the list of bank name part of the handles, refer to UPI Handles. Reference: For the list of test card numbers for EMI, refer to Test Cards, UPI ID and Wallets | test123@okhdfcbank |
Test Environment Limitation
You can test UPI only with the anything@payu or [email protected] as VPA.
Error Handling
If any error message is displayed with an error code, refer to Error Handling to understand the reason for these error codes.
Sample request
curl -X POST "https://test.payu.in/_payment" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "key=JP***g&txnid=xdB9G7qYpfqszo&amount=10&firstname=PayU User&[email protected]&phone=9876543210&productinfo=iPhone&pg=UPI&bankcode=UPI&vpa=VPA-anything@payu&surl=https://apiplayground-response.herokuapp.com/&furl=https://apiplayground-response.herokuapp.com/&hash=649bc87e0e8ee7bbd1e930d43c99a9165eb9fa7a3f4542a33e8d66bd207a63d631708fd9781e56b133581f7dabeaa67baa5609d5e5c9990f986792d59e7d41cb"
Sample response
Array
(
[mihpayid] => 403993715523409521
[mode] => UPI
[status] => success
[unmappedstatus] => captured
[key] => JPM7Fg
[txnid] => 5jJ9xRceXX1ydT
[amount] => 10.00
[discount] => 0.00
[net_amount_debit] => 1000
[addedon] => 2021-07-02 15:03:50
[productinfo] => iPhone
[firstname] => PayU User
[lastname] =>
[address1] =>
[address2] =>
[city] =>
[state] =>
[country] =>
[zipcode] =>
[email] => [email protected]
[phone] => 9876543210
[udf1] =>
[udf2] =>
[udf3] =>
[udf4] =>
[udf5] =>
[udf6] =>
[udf7] =>
[udf8] =>
[udf9] =>
[udf10] =>
[hash] => 716f92a6452adadba68d133ba7f5ca3f3403f03f554e3ef850911f3e6727ee73402b249054170ad276c8b55ca12368a5e27cc69ffb0642ef6403dae9a5708794
[field1] => vpa-anything@payu
[field2] => 5jJ9xRceXX1ydT
[field3] =>
[field4] => PayU User
[field5] => AXIhh4ExnaJ9dKiJvPxsewHwxMMmT3ba7UY
[field6] =>
[field7] => Transaction completed successfully
[field8] =>
[field9] => Transaction completed successfully
[payment_source] => payu
[PG_TYPE] => UPI-PG
[bank_ref_num] => 5jJ9xRceXX1ydT
[bankcode] => UPI
[error] => E000
[error_Message] => No Error
)
Step 3: Verify the payment
Verify the transaction details using the Verification APIs. For API reference, refer to Verify Payment API under API Reference.
Tip
The transaction ID that you posted in Step 2 with PayU must be used here.
Recommended integrations for UPI
- Recurring Payments: Enable recurring payments or subscriptions for wallets. For more information, refer to Recurring Payments Integration.
- Offers: Configure offers for cards on Dashboard and then collect payments with offers. For more information, refer to Offers Dashboard and Offers Integration APIs
Updated about 8 hours ago