URL
PreProd Host URL: https://api-preprod.phonepe.com/apis/merchant-simulator
API End Point: /pg/v1/pay
URL: https://api-preprod.phonepe.com/apis/merchant-simulator/pg/v1/pay
Quick Links
- Request Headers
- Request Parameters
- Sample Request for Pay Page
- How to Calculate X-Verify/Checksum header
- Sample Response
- Response Headers
- Response Parameters
- Response Codes
- Common errors related to X-Verify header
Request Details
Request Headers
Header Name | Header Value |
---|---|
Content-Type | application/json |
X-VERIFY | SHA256(base64 encoded payload + "/pg/v1/pay" + salt key) + ### + salt index |
Request Parameters
Parameter Name | Data Type | Description | Mandatory |
---|---|---|---|
merchantId | STRING | Unique MerchantID assigned to the merchant by PhonePeNote: merchantId length will be less than 38 characters. | Yes |
merchantTransactionId | STRING | Unique Transaction ID generated by the merchant to track request to PhonePeNote: - merchantTransactionId length should be less than 36 characters - No Special characters allowed except underscore "_" | Yes |
amount | LONG | Transaction amount in Paise | Yes |
merchantUserId | STRING | Unique UserID of the users generated by the merchant.Note: - merchantUserId length should be less than 36 characters - Should be alphanumeric only. | Yes |
redirectUrl | STRING | The url where the user will be redirected after transaction completion. | Yes |
redirectMode | ENUM | redirectMode should be: ● POST | Yes |
callbackUrl | STRING | The url where server to server callback will be posted. Always POST. Note: This callback will be of POST type and will contain the same payload as the status response. The callback will contain an X-VERIFY header which the merchant should verify before decoding the response. | Yes |
paymentInstrument | OBJECT | Payment details | Yes |
paymentInstrument.type | ENUM | Payment instrument type. Value will be: PAY_PAGE | Yes |
mobileNumber | STRING | Mobile number of the user | No |
Sample Request for Pay Page
{
"merchantId": "MERCHANTUAT",
"merchantTransactionId": "MT7850590068188104",
"merchantUserId": "MUID123",
"amount": 10000,
"redirectUrl": "https://webhook.site/redirect-url",
"redirectMode": "POST",
"callbackUrl": "https://webhook.site/callback-url",
"mobileNumber": "9999999999",
"paymentInstrument": {
"type": "PAY_PAGE"
}
}
{
"request":"ewogICJtZXJjaGFudElkIjogIk1FUkNIQU5UVUFUIiwKICAibWVyY2hhbnRUcmFuc2FjdGlvbklkIjogIk1UNzg1MDU5MDA2ODE4ODEwNCIsCiAgIm1lcmNoYW50VXNlcklkIjogIk1VSUQxMjMiLAogICJhbW91bnQiOiAxMDAwMCwKICAicmVkaXJlY3RVcmwiOiAiaHR0cHM6Ly93ZWJob29rLnNpdGUvcmVkaXJlY3QtdXJsIiwKICAicmVkaXJlY3RNb2RlIjogIlBPU1QiLAogICJjYWxsYmFja1VybCI6ICJodHRwczovL3dlYmhvb2suc2l0ZS9jYWxsYmFjay11cmwiLAogICJtb2JpbGVOdW1iZXIiOiAiOTk5OTk5OTk5OSIsCiAgInBheW1lbnRJbnN0cnVtZW50IjogewogICAgInR5cGUiOiAiUEFZX1BBR0UiCiAgfQp9"
}
How to Calculate X-Verify/Checksum header
Formula: SHA256(Base64 encoded payload + "/pg/v1/pay" + salt key) + ### + salt index
Base64 encoded payload:
ewogICJtZXJjaGFudElkIjogIk1FUkNIQU5UVUFUIiwKICAibWVyY2hhbnRUcmFuc2FjdGlvbklkIjogIk1UNzg1MDU5MDA2ODE4ODEwNCIsCiAgIm1lcmNoYW50VXNlcklkIjogIk1VSUQxMjMiLAogICJhbW91bnQiOiAxMDAwMCwKICAicmVkaXJlY3RVcmwiOiAiaHR0cHM6Ly93ZWJob29rLnNpdGUvcmVkaXJlY3QtdXJsIiwKICAicmVkaXJlY3RNb2RlIjogIlBPU1QiLAogICJjYWxsYmFja1VybCI6ICJodHRwczovL3dlYmhvb2suc2l0ZS9jYWxsYmFjay11cmwiLAogICJtb2JpbGVOdW1iZXIiOiAiOTk5OTk5OTk5OSIsCiAgInBheW1lbnRJbnN0cnVtZW50IjogewogICAgInR5cGUiOiAiUEFZX1BBR0UiCiAgfQp9API Endpoint:
/pg/v1/paySample Salt Key:
099eb0cd-02cf-4e2a-8aca-3e6c6aff0399Sample Salt Index:
1Final Computation:
SHA256 (ewogICJtZXJjaGFudElkIjogIk1FUkNIQU5UVUFUIiwKICAibWVyY2hhbnRUcmFuc2FjdGlvbklkIjogIk1UNzg1MDU5MDA2ODE4ODEwNCIsCiAgIm1lcmNoYW50VXNlcklkIjogIk1VSUQxMjMiLAogICJhbW91bnQiOiAxMDAwMCwKICAicmVkaXJlY3RVcmwiOiAiaHR0cHM6Ly93ZWJob29rLnNpdGUvcmVkaXJlY3QtdXJsIiwKICAicmVkaXJlY3RNb2RlIjogIlBPU1QiLAogICJjYWxsYmFja1VybCI6ICJodHRwczovL3dlYmhvb2suc2l0ZS9jYWxsYmFjay11cmwiLAogICJtb2JpbGVOdW1iZXIiOiAiOTk5OTk5OTk5OSIsCiAgInBheW1lbnRJbnN0cnVtZW50IjogewogICAgInR5cGUiOiAiUEFZX1BBR0UiCiAgfQp9/pg/v1/pay099eb0cd-02cf-4e2a-8aca-3e6c6aff0399) + ### + 1
Checksum Value :
2cd3a2cd04ff5b453df11e91f97b29fae10fe22522a29c1ae6b7fad41478d8b5###1
Sample Response
{
"success": true,
"code": "PAYMENT_INITIATED",
"message": "Payment Iniiated",
"data": {
"merchantId": "MERCHANTUAT",
"merchantTransactionId": "MT7850590068188104",
"instrumentResponse": {
"type": "PAY_PAGE",
"redirectInfo": {
"url": "https://mercury-uat.phonepe.com/transact?token=MjdkNmQ0NjM2MTk5ZTlmNDcxYjY3NTAxNTY5MDFhZDk2ZjFjMDY0YTRiN2VhMjgzNjIwMjBmNzUwN2JiNTkxOWUwNDVkMTM2YTllOTpkNzNkNmM2NWQ2MWNiZjVhM2MwOWMzODU0ZGEzMDczNA",
"method": "GET"
}
}
}
}
Response Details
Response Headers
Header Name | Header Value |
---|---|
Content-Type | application/json |
Response Parameters
Parameter Name | Data Type | Description |
---|---|---|
success | BOOLEAN | Success/failure of request processing |
code | STRING | Response code explaining reason for status- Click here |
message | STRING | Message giving more information about the code. |
merchantId | STRING | Merchant id |
merchantTransactionId | STRING | Transaction id generated by merchant |
transactionId | STRING | Transaction id generated by PhonePe. Note: This may not always be available in response of a pay call but will always be available in callback or status call after transaction completion. |
redirectInfo | STRING | Payload for redirecting user to bank page for authentication |
url | STRING | Url on which user needs to be redirected for authentication |
method | STRING | http method for loading redirect url |
headers | Map<String, String> | Request headers to be passed while loading redirect url |
data | Map<String, String> | Form data to be submitted to redirect url page |
Response Codes
Code | Description |
---|---|
PAYMENT_INITIATED | Payment is initiated successfully |
PAYMENT_ERROR | Payment initiation has failed |
INTERNAL_SERVER_ERROR | Something went wrong |
BAD_REQUEST | Invalid request |
AUTHORIZATION_FAILED | X-VERIFY header is incorrect |
Common errors related to X-Verify header
Scenario | Error Code | Response Body |
---|---|---|
X-Verify is not passed in request headers or passed in different format than expected | 400 (Bad Request) | |
Incorrect X-Verify header passed in request | 401 | {"success":false,"code":"401"} |