The PhonePe Docs Developer Hub

Welcome to the PhonePe Docs developer hub. You'll find comprehensive guides and documentation to help you start working with PhonePe Docs as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started
Suggest Edits

Installation

 


To install PhonePe's Javascript SDK for your PWA/M-Site integration, please download the javascript file from this link.

Suggest Edits

Enable Logging

 

To enable logging while debugging the SDK, please set the property on PhonePe's global variable like so:

PhonePe.PhonePe.loggingEnabled = true
Suggest Edits

Create PhonePe Instance

 

build

(species: string): Promise<PhonePe>
Description: This method is used to create an instance of PhonePe. This method runs asynchronously and it is very fast. This instance is used for any calls to PhonePe's bridges.

Older build() call is deprecated

Starting JS SDK version 0.3.6 and above, the operatingSystem parameter is not needed. On SDK version < 0.3.6, operatingSystem is necessary and can be either PhonePe.Constants.OS.ios or PhonePe.Constants.OS.android. Please use the latest SDK version.

Request Parameter

Parameter Name
Type
Description

species

string

Describes if the merchant is using the sdk for web or react native.
Can be either PhonePe.Constants.Species.native or PhonePe.Constants.Species.web

Response Parameter

Promise<PhonePe>

Usage:

PhonePe.PhonePe.build(PhonePe.Constants.Species.web)
  .then((sdk) => { //Get the instance of the sdk })

OR 

let sdk = await PhonePe.PhonePe.build(PhonePe.Constants.Species.web)

isMethodSupported

(methodName: string): boolean
Description: Call this method to check if the method that you're trying to call is supported. This is a synchronous call and returns the result immediately. Methods might be added/removed and it's important to know if a method is supported by the current PhonePe app that merchant's web app is running on. Case in point, if a method gets added to the SDK, older PhonePe apps might not support the method.

For the current version of PhonePe's SDK, merchants won't need to call this.

Request Parameter

Parameter Name
Type
Description

methodName

string

Name of the method that you'd be calling

Response Parameter

boolean

Usage:

//When invoking method named setItem
if (sdk.isMethodSupported(setItem)) { sdk.setItem('app', 'key', 'value') }
Suggest Edits

Ask for Permissions

 


(listOfPermissions: string[]): Promise<any>
Description: This method is used to ask for permissions for

  • Accessing User Location
  • Reading SMS (Android only)

Request Parameter

Parameter Name
Type
Description

listOfPermissions

Array<string>

List of the permissions that you would like to ask for. The permissions you can ask for are described in the table below.

Response Parameters

Promise<any>

Permission Name
Description

READ_SMS (accessed as
PhonePe.Constants.Permission. READ_SMS)

Read the user SMS​ for functionalities like OTP detection. Only available for Android.

LOCATION (accessed as
PhonePe.Constants.Permission.LOCATION)

Retrieve the user's location.

CAMERA (accessed as
PhonePe.Constants.Permission.CAMERA)

Asks for camera permission

Usage:

let result = await sdk.seekPermission([PhonePe.Constants.Permission.READ_SMS, PhonePe.Constants.Permission.LOCATION,PhonePe.Constants.Permission.CAMERA])
Promise resolve:
[  
   {  
      "permission":"LOCATION",
      "permissionGranted":true,
      "willShowPermissionAlertAgain": false
   },
   {  
      "permission":"READ_SMS",
      "permissionGranted": true,
      "willShowPermissionAlertAgain": false
   }
]
Suggest Edits

Get User Location

 

Get Current Location of the User

(): Promise<any>
Description: Call this method to get the current location of the user

Usage

//Get the location permission from PhonePe first
//See the Ask for Permissions section above to see the structure of res object
let result = await sdk.seekPermission([PhonePe.Constants.Permission.LOCATION])

//If the permission has been given for location
//Then get the current location
//Else getCurrentLocation() would reject
sdk.getCurrentLocation()
  .then((location) => { 
  	console.log("Location received with latitude = " + location.latitude + ' longitude = ' + location.longitude) 
  })
  .catch((err) => { 
  	console.log("Error found when fetching location = " + err) 
  })

Response Parameters

Promise<any>
A promise of getting the current location. Promise rejection will contain the error message if we were unable to fetch the location.

The promise rejection reason can be as follows:

Code
Description

LOCATION_FETCH_FAILURE

Unable to fetch user's location

Promise resolve:
{
  'latitude': 123.123, 
  'longitude': 345.345
}

Promise reject:
{
  'error_code': 'LOCATION_FETCH_FAILURE'
}
Suggest Edits

Key-Value Storage

 


PhonePe provides a native persistent key-value storage. Both the keys and values can only be of type string.

getItem

(preferenceName: string, key: string, defaultValue?: undefined⎮string): Promise<string>

Description: This method is used to get a stored value from native key-value storage

Request Parameters

Parameter Name
Type
Description

preferenceName

string

Name of the key-value storage file. You can have multiple key-value storage files for your app. Should be a non-empty string.

key

string

Name of the key to fetch the value for.

defaultValue

undefined/string

Default value in case the key doesn't exist.

Usage:

sdk.getItem('app', 'key', null)
  .then((data) => {
	console.log('Value received = ' + data)
})
  .catch((err) => {})

Response Parameter

Promise<string>
A promise with the desired value or error if there is some issue. Promise failure reasons can be as follows:

Code
Description

KEY_NOT_FOUND

No value found for this key and no default value was provided


setItem

(preferenceName: string, key: string, value: string): void
Description: This method is used to store a value (string) for the corresponding key (string) into the key-value storage.

Request Parameters

Parameter Name
Type
Description

preferenceName

string

Name of the key-value storage file. You can have multiple key-value storage files for your app.

key

string

Name of the key to fetch the value for.

value

string

Value that you would like to set for the key

Response Parameter

void

Usage:

sdk.setItem('app', 'key', 'value')

removeItem

(preferenceName: string, key: string): void
Description: This method is used remove a key-value pair from key-value storage.
Usage:

sdk.removeItem('app', 'key')
Promise resolve:
'valueForKey'

Promise reject:
{
  'error_code': 'KEY_NOT_FOUND'
}
 


You can find the SSO flow diagram here

SSO flow involves two steps as :

a.) Calling fetchAuthToken grantToken ()] at client end.


b.) Calling getAccessToken () server to server API() to fetch the access token.


c.) Calling getUserDetails () server to server API() to fetch the user details from PhonePe server.

Suggest Edits

fetchAuthToken

 

fetchAuthToken

Description: This method can be used to verify the identity of a PhonePe user and get his details. The merchant should call this method and get a token, let's call it the grant token.

As soon as this method is called, SSO pop up will come, showing user options to either "Login" or "Skip" the consent. In the case of "Login" Phonepe server will share you with the user details. In the case of "Skip", merchants can show their login page to users where they can either log in or create a new account.

Usage:

PhonePe.PhonePe.build(PhonePe.Constants.Species.web).then((sdk) => {
	sdk.fetchAuthToken().then((res) => {
		console.log("Grant token data received = " + res)
		alert(res)
	}).catch((err) => {
		console.log("Error occurred while fetching the grant token: " + err)
		alert(err)
	})
})


Response Parameter

Promise<any>
A promise resolution with the grant token. Promise rejection if the grant token fetching failed.

Promise resolve:
{
    "grantToken": "GRT8616a8396e9b3a0899a2a6b06a3845cf0ad3521d0c4a0d5194404fba21a00b7a",
    "expiryInSeconds": 86400
}

Promise reject:
{
  "error_code": "NETWORK_ERROR"
}
Suggest Edits

Get Access Token

 
posthttps://apps-uat.phonepe.com/v3/service/auth/access
curl --request POST \
  --url https://apps-uat.phonepe.com/v3/service/auth/access
var request = require("request");

var options = { method: 'POST',
  url: 'https://apps-uat.phonepe.com/v3/service/auth/access' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://apps-uat.phonepe.com/v3/service/auth/access")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://apps-uat.phonepe.com/v3/service/auth/access");

xhr.send(data);
import requests

url = "https://apps-uat.phonepe.com/v3/service/auth/access"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
    "success": true,
    "code": "SUCCESS",
    "data": {
        "accessToken": "AUTHca12ab41b97bea5268e65593ab2a1cc697338a656e8",
        "expiresInSeconds": 1800
    }
}

Body Params

request
string

base64 encoded payload

Headers

X-VERIFY
string

SHA256(only base64 encoded str+ "/v3/service/auth/access" + salt key) + ### + salt index

X-CLIENT-ID
string

Unique MID(shared by Phonepe) needs to be send as a parameter

Content-Type
string
 

This service gives a merchant the access token corresponding to a grant token. This token can be used to fetch the User details in the getUserDetails API

Request Headers

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256(only base64 encoded str+ "/v3/service/auth/access" + salt key) + ### + salt index

X-CLIENT-ID

Unique MID(shared by Phonepe) needs to be sent as a parameter unless a different value is shared by PhonePe team

Request Parameters

Parameter Name
Type
Description
Mandatory

grantToken

STRING

Unique grantToken generated by the call to fetchAuthToken as mentioned in the last section fetchAuthToken ]

Yes

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

Success status of the request

code

ENUM

See list of response codes below

data

Object

The data object that has to be passed to the sdk.

Response Codes

Code
Description

UNAUTHORIZED

The grantToken provided is either invalid or not mapped to the merchant.

BAD_REQUEST

Invalid request payload

AUTHORIZATION_FAILED

Incorrect X-VERIFY header

INTERNAL_SERVER_ERROR

Something went wrong

API_RATE_LIMIT_REACHED

If the api call limit is breached then API_LIMIT & TIME_WINDOW would be sent with HTTP status 429

{
	"grantToken":"GRTe098bd540176757ybbnhu879125ebec723741c5189f6a4e303f2b9d28d3e4d1289bd61dd"
}
{
  "request": "ewoJImdyYW50VG9rZW4iOiJHUlRlMDk4YmQ1NDAxNzY3NTd5YmJuaHU4NzkxMjVlYmVjNzIzNzQxYzUxODlmNmE0ZTMwM2YyYjlkMjhkM2U0ZDEyODliZDYxZGQiCn0="
}
Suggest Edits

Get User Details

 
gethttps://apps-uat.phonepe.com/v3/service/userdetails
curl --request GET \
  --url https://apps-uat.phonepe.com/v3/service/userdetails
var request = require("request");

var options = { method: 'GET',
  url: 'https://apps-uat.phonepe.com/v3/service/userdetails' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://apps-uat.phonepe.com/v3/service/userdetails")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://apps-uat.phonepe.com/v3/service/userdetails");

xhr.send(data);
import requests

url = "https://apps-uat.phonepe.com/v3/service/userdetails"

response = requests.request("GET", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
    "success": true,
    "code": "SUCCESS",
    "data": {
        "name": "Anurag",
        "phoneNumber": "9888888888"
    }
}

Incase of email is shared 

{
   "success": true,
   "code": "SUCCESS",
   "data": {
       "name": "Rohit Kumar",
       "phoneNumber": "9888888888",
       "primaryEmail": "[email protected]",
       "isEmailVerified": true
   }
}

Headers

X-VERIFY
string

SHA256(/v3/service/userdetails + salt key) + ### + salt index

Content-Type
string
X-CLIENT-ID
string

Unique MID(shared by Phonepe) needs to be send as a parameter

X-ACCESS-TOKEN
string

Token fetched from get auth token API

 

This service gives a merchant the PhonePe's user details corresponding to an access token. This can be used to facilitate Single Sign-On in the merchant's system as the user details have already been verified by PhonePe.

Request Headers

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256("/v3/service/userdetails" + salt key) + ### + salt index

X-CLIENT-ID

Unique MID(shared by Phonepe) needs to be sent as a parameter unless a different value is shared by PhonePe team

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

Success status of the request

code

ENUM

See list of response codes below

data

Object

The data object that has to be passed to the sdk.

Response Codes

Code
Description

UNAUTHORIZED

The grantToken provided is either invalid or not mapped to the merchant.

BAD_REQUEST

Invalid request payload

AUTHORIZATION_FAILED

Incorrect X-VERIFY header

INTERNAL_SERVER_ERROR

Something went wrong

API_RATE_LIMIT_REACHED

If the api call limit is breached then API_LIMIT & TIME_WINDOW would be sent with HTTP status 429

Suggest Edits

Payment Flow SDK Less

 


The payment involves four steps :

a.) Integrating with server-side Initiate Transaction API()

This involves implementing the Call back API and above API

b.)Opening the 'redirectionURL' fetched from above API at the client-side. (https://developer.phonepe.com/v4/reference#open-phonepe-payments-page).

c.) Integrating with the Check Status API

d.) Integrating with the refund API

Suggest Edits

Initiate Transaction (SDK less) API

 
posthttps://apps-uat.phonepe.com/v3/transaction/sdk-less/initiate
curl --request POST \
  --url https://apps-uat.phonepe.com/v3/transaction/sdk-less/initiate
var request = require("request");

var options = { method: 'POST',
  url:
   'https://apps-uat.phonepe.com/v3/transaction/sdk-less/initiate' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://apps-uat.phonepe.com/v3/transaction/sdk-less/initiate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://apps-uat.phonepe.com/v3/transaction/sdk-less/initiate");

xhr.send(data);
import requests

url = "https://apps-uat.phonepe.com/v3/transaction/sdk-less/initiate"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated


{
"success":true,
"code":"SUCCESS",
"data":{
"redirectUrl":"phonepe://checkoutResolve?reservationId=R2001231624585218494402&redirectUrl=https://test-merchant.com/order/42314233232"
}
}

Headers

X-VERIFY
string

SHA256(base64 encoded payload + "/v3/transaction/sdk-less/initiate" + salt key) + '###' + salt index

X-CLIENT-ID
string

This will verify corresponding to the merchants. The default value will be merchant ID

Content-Type
string

application/json

X-CALLBACK-URL
string

Callback API of the merchant

 

Request Headers

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256(base64 encoded payload +
"/v3/transaction/sdk-less/initiate" + salt key) + '###' + salt index

X-CLIENT-ID

This will verify corresponding to the merchants. The default value will be merchant ID

X-CALLBACK-URL

Please find the details here

Every service request has cart details that are typed by the category of that request. Here is an example for the category Bus.

The category tree is managed and maintained by PhonePe.

Request Parameters

Parameter Name
Type
Description
Mandatory

merchantId

STRING

Unique MerchantID assigned to the merchant by PhonePe

Yes

subMerchantId

STRING

Unique subMerchantId assigned to the merchant by PhonePe

Optional

transactionId

STRING

Unique TransactionID generated by the merchant to track request to PhonePe
transactionId length should be less than 38 characters.

Yes

amount

INT

Transaction amount in Paise

Yes

validFor

LONG

Time in Miliseconds for which the payment is valid

Yes

merchantOrderId

STRING

OrderID generated by the merchant
merchantOrderId length should be less than 48 characters

Yes

redirectUrl

STRING

As soon as user completes the transaction on PhonePe Switch, user will be redirected to this redirection URL

Yes

transactionContext

STRING

Base 64 encoded of the cart details pertaining to the category

Yes

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

Success status of the request

code

ENUM

See list of response codes below

data

Object

The redirectUrl which needs to be open at the client side using the code as

<body onload="window.location.href = '{{$data['request']['redirectUrl']}}'">

Response Codes

Code
Description

INVALID_TRANSACTION_ID

Duplicate TransactionID

INVALID_USER_AUTH_TOKEN

The userAuthToken provided is either invalid or not mapped to merchant.

BAD_REQUEST

Invalid request payload

AUTHORIZATION_FAILED

Incorrect X-VERIFY header

INTERNAL_SERVER_ERROR

Something went wrong

API_RATE_LIMIT_REACHED

If the api call limit is breached then API_LIMIT & TIME_WINDOW would be sent with HTTP status 429

It's recommended to have the server to server call back using x-callback-url header.

{
"merchantId":"MERCHANTTEST",
"amount":10000000,
"validFor":900000,
"subMerchantId":"SUBMERCHANTTEST",// needs to send only when mentioned by PhonePe integration team//
"transactionId":"T12RTRTBJGGTGJNYGB",
"merchantOrderId":"T12RTRTBJGGTGJNYGB",
 "redirectUrl":"https://test-merchant.com/order/42314233232",
 "transactionContext": "ewoJIm9yZGVyQ29udGV4dCI6IHsKCQkidHJhY2tpbmdJbmZvIjogewoJCQkidHlwZSI6ICJIVFRQUyIsCgkJCSJ1cmwiOiAiaHR0cHM6Ly9nb29nbGUuY29tIgoJCX0KCX0sCgkiZmFyZURldGFpbHMiOiB7CgkJInRvdGFsQW1vdW50IjogMzkwMCwKCQkicGF5YWJsZUFtb3VudCI6IDM5MDAKCX0sCgkiY2FydERldGFpbHMiOiB7CgkJImNhcnRJdGVtcyI6IFt7CgkJCSJjYXRlZ29yeSI6ICJTSE9QUElORyIsCgkJCSJpdGVtSWQiOiAiMTIzNDU2Nzg5MCIsCgkJCSJwcmljZSI6IDM5MDAsCgkJCSJpdGVtTmFtZSI6ICJURVNUIiwKCQkJInF1YW50aXR5IjogMQoJCX1dCgl9Cn0="
}
{ "request": "ewoibWVyY2hhbnRJZCI6Ik1FUkNIQU5UVEVTVCIsCiJhbW91bnQiOjEwMDAwMDAwLAoidmFsaWRGb3IiOjkwMDAwMCwKInN1Yk1lcmNoYW50SWQiOiJTVUJNRVJDSEFOVFRFU1QiLC8vIG5lZWRzIHRvIHNlbmQgb25seSB3aGVuIG1lbnRpb25lZCBieSBQaG9uZVBlIGludGVncmF0aW9uIHRlYW0vLwoidHJhbnNhY3Rpb25JZCI6IlQxMlJUUlRCSkdHVEdKTllHQiIiLAoibWVyY2hhbnRPcmRlcklkIjoiVDEyUlRSVEJKR0dUR0pOWUdCIiwKICJyZWRpcmVjdFVybCI6Imh0dHBzOi8vdGVzdC1tZXJjaGFudC5jb20vb3JkZXIvNDIzMTQyMzMyMzIiCiAidHJhbnNhY3Rpb25Db250ZXh0IjogImV3b0pJbTl5WkdWeVEyOXVkR1Y0ZENJNklIc0tDUWtpZEhKaFkydHBibWRKYm1adklqb2dld29KQ1FraWRIbHdaU0k2SUNKSVZGUlFVeUlzQ2drSkNTSjFjbXdpT2lBaWFIUjBjSE02THk5bmIyOW5iR1V1WTI5dElnb0pDWDBLQ1gwc0Nna2labUZ5WlVSbGRHRnBiSE1pT2lCN0Nna0pJblJ2ZEdGc1FXMXZkVzUwSWpvZ016a3dNQ3dLQ1FraWNHRjVZV0pzWlVGdGIzVnVkQ0k2SURNNU1EQUtDWDBzQ2draVkyRnlkRVJsZEdGcGJITWlPaUI3Q2drSkltTmhjblJKZEdWdGN5STZJRnQ3Q2drSkNTSmpZWFJsWjI5eWVTSTZJQ0pUU0U5UVVFbE9SeUlzQ2drSkNTSnBkR1Z0U1dRaU9pQWlNVEl6TkRVMk56ZzVNQ0lzQ2drSkNTSndjbWxqWlNJNklETTVNREFzQ2drSkNTSnBkR1Z0VG1GdFpTSTZJQ0pVUlZOVUlpd0tDUWtKSW5GMVlXNTBhWFI1SWpvZ01Rb0pDWDFkQ2dsOUNuMD0iCn0=" } 
Suggest Edits

Open PhonePe payments page

 

Step1 : Initiate API will give redirect Url in response which needs to open at the client-side using the below code.

On client side open the "redirection URL" using the below code

<body onload="window.location.href = '{{$data['request']['redirectUrl']}}'">

As soon as the above redirectUrl is called, the PhonePe payments page will open where a user will be able to complete the payment on the Switch Platform.

Step2: As soon as the user completes the payment, the user will be redirected to the redirectUrl which is merchant client-side URL given in the response of the Initiate API.

Note: PhonePe Switch does not share the status of the transaction at the client-side.
As soon as user completes the payment, he will be redirected to the merchant's URL. A merchant needs to fetch the status of the transaction from the backend API.

Step3: Fetch the status of the transaction from the getStatus backend API.

Suggest Edits

Check Status API

 
gethttps://apps-uat.phonepe.com/v3/transaction/merchantId/transactionId/status
curl --request GET \
  --url https://apps-uat.phonepe.com/v3/transaction/merchantId/transactionId/status
var request = require("request");

var options = { method: 'GET',
  url:
   'https://apps-uat.phonepe.com/v3/transaction/merchantId/transactionId/status' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://apps-uat.phonepe.com/v3/transaction/merchantId/transactionId/status")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://apps-uat.phonepe.com/v3/transaction/merchantId/transactionId/status");

xhr.send(data);
import requests

url = "https://apps-uat.phonepe.com/v3/transaction/merchantId/transactionId/status"

response = requests.request("GET", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

 {
   "success": true,
   "code": "PAYMENT_SUCCESS", // code 
   "data": {
       "transactionId": "cf015dab-0fsafds4799bf6fds03",
       "amount": 100,
       "merchantId": "TESTMAIN",
       "providerReferenceId": "P1907101401597592710760",
       "status": "SUCCESS",
       "payResponseCode": "SUCCESS"
   }
}

Path Params

merchantId
string
required

Unique Merchant ID assigned to the merchant by PhonePe

transactionId
string
required

Merchant transaction id for which status is to be fetched

Headers

X-CLIENT-ID
string

This will vary corresponding to the merchants. The default value will be merchant ID

X-VERIFY
string

SHA256("/v3/transaction/<merchantId>/<transactionId>/status" + saltKey) + "###" + saltIndex

 

It is mandatory for the merchant to check the status of a transaction post callback from Show Payments Page or Refund workflows.

  • Once customer is redirected back to merchant website, it is recommended to make a transaction status check with PhonePe backend systems to know the actual status of the payment and, then accordingly process the result.
  • The payment status can be Success, Failed or Pending. When Pending, merchants should retry until the status changes to Success or Failed.

Request Headers

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256("/v3/transaction/{merchantId}/{transactionId}/status" +
saltKey) + "###" + saltIndex

X-CLIENT-ID

This will vary corresponding to the merchants. The default value will be merchant ID.

Path Parameters

Parameter Name
Type
Description
Mandatory

merchantId

STRING

Unique Merchant ID assigned to the merchant by PhonePe

Yes

transactionId

STRING

Merchant transactionID for which status is to be fetched

Yes

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

A boolean to indicate the success/failure of the request.

code

ENUM

Please see the list of Transaction Status Response Codes below. You should base your decision on this parameter.

transactionId

STRING

Unique Transaction ID generated by the merchant to track this request to PhonePe

merchantId

STRING

Unique Merchant ID assigned to the merchant by PhonePe

amount

LONG

Transaction amount in paise

providerReferenceId

STRING

PhonePe transaction Id

Transaction Status Response Codes

Code
Description

TRANSACTION_NOT_FOUND

Payment not initiated inside PhonePe

INVALID_TRANSACTION_ID

Transaction ID sent is wrong. Need to send transaction ID as sent in the initiate API

BAD_REQUEST

Invalid request

AUTHORIZATION_FAILED

X-VERIFY header is incorrect

INTERNAL_SERVER_ERROR

Something went wrong. Merchant needs to call Check Transaction Status to verify the transaction status.

PAYMENT_SUCCESS

Payment is successful or In case of refund - Refund is successful.

PAYMENT_ERROR

Payment failed

PAYMENT_PENDING

Payment is pending. It does not indicate failed payment. Merchant needs to call Check Transaction Status to verify the transaction status.

PAYMENT_DECLINED

Payment declined by user

PAYMENT_CANCELLED

Payment cancelled by the merchant using Cancel API

API_RATE_LIMIT_REACHED

If the api call limit is breached then API_LIMIT & TIME_WINDOW would be sent with HTTP status 429

Cross-check the amount which has been passed in forward payment path(Accept payment API) and in the response of Check Transaction Status API.

posthttps://apps-uat.phonepe.com/v3/credit/backToSource
curl --request POST \
  --url https://apps-uat.phonepe.com/v3/credit/backToSource
var request = require("request");

var options = { method: 'POST',
  url: 'https://apps-uat.phonepe.com/v3/credit/backToSource' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://apps-uat.phonepe.com/v3/credit/backToSource")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://apps-uat.phonepe.com/v3/credit/backToSource");

xhr.send(data);
import requests

url = "https://apps-uat.phonepe.com/v3/credit/backToSource"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
   "success": true,
   "code": "PAYMENT_SUCCESS",
   "message": "Your payment is successful.",
   "data": {
       "transactionId": "TX123456789",
       "merchantId": "DemoMerchant",
       "amount": 100,
       "status": "SUCCESS",
       "mobileNumber": "9xxxxxxxxxx",
       "providerReferenceId": "PPXXXXX",
       "payResponseCode": "SUCCESS"
   }
}

Body Params

request
string

base64 encoded payload

Headers

X-VERIFY
string

SHA256(base64 encoded payload + "/v3/credit/backToSource" + salt key) + ### + salt index

Content-type
string
X-CLIENT-ID
string

This will vary corresponding to the merchants. The default value will be merchant ID

 

Request Headers

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256(base64 encoded payload + "/v3/credit/backToSource" + salt key) + ### + salt index

Request Parameters

Parameter Name
Type
Description
Mandatory

merchantId

STRING

Unique Merchant ID assigned to the merchant by PhonePe

Yes

transactionId

STRING

Unique Transaction ID generated by the merchant to track this request to PhonePe.
This should be different from transaction ID of debit transaction.

Yes

originalTransactionId

STRING

Merchant transaction Id of forward transaction which needs to be reversed.

Yes

providerReferenceId

STRING

PhonePe transaction id of the original forward payment.
Note : use only one of originalTransactionId, providerReferenceId only

Yes

amount

LONG

Reversal amount in paise. Upto a max of amount of original payment transaction.

Yes

merchantOrderId

STRING

Order ID for the merchant transaction

Yes

subMerchant

STRING

Tag to categorize merchant transaction

No

message

STRING

Short message

Yes

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

Success status of the request

code

ENUM

See list of response codes below

message

STRING

Short message about code

transactionId

STRING

Unique Transaction ID generated by the merchant to track this request to PhonePe

merchantId

STRING

Unique Merchant ID assigned to the merchant by PhonePe

amount

LONG

Transaction amount in paise

status

STRING

Status of the request

mobileNumber

STRING

Mobile number of the user

providerReferenceId

STRING

PhonePe payment transaction id against which the reversal is to be done

payResponseCode

STRING

PhonePe internal status code

Refund API Response Codes

Code
Description

BAD_REQUEST

Invalid request

AUTHORIZATION_FAILED

X-VERIFY header is incorrect

TRANSACTION_NOT_FOUND

Original transaction not found

INTERNAL_SERVER_ERROR

Something went wrong. Refund might get initiated (need to check status with check transaction status API before retrying the refund)

PAYMENT_SUCCESS

Payment is successful

PAYMENT_ERROR

Payment failed

PAYMENT_PENDING

Payment is pending. It does not indicate failed payment. Refund might get initiated (need to check status with check transaction status API before retrying the refund)

TIMED_OUT

Refund timed out. Refund might get initiated (need to check status with check transaction status API before retrying the refund)

DUPLICATE_TXN_REQUEST

If the transaction id is used already for refund request.

EXCESS_REFUND_AMOUNT

If the amount requested for refund is more than forward payment or If refund is already done

WALLLET_NOT_ACTIVATED

If the user has disabled the wallet. Contact user to know the source for refund.

API_RATE_LIMIT_REACHED

If the api call limit is breached then API_LIMIT & TIME_WINDOW would be sent with HTTP status 429

{
    "merchantId": "DemoMerchant",
    "transactionId": "TX123456789",
    "providerReferenceId": "PPXXXXX",
    "amount": 100,
    "merchantOrderId": "OD1234",
    "subMerchant": "DemoMerchant",
    "message": "refund for cancelled order"
}
{
  "request": "eyJtZXJjaGFudE9yZGVySWQiOiAiT0QxMjM0IiwgInN1Yk1lcmNoYW50IjogIkRlbW9NZXJjaGFudCIsICJhbW91bnQiOiAxMDAsICJtZXNzYWdlIjogInJlZnVuZCBmb3IgY2FuY2VsbGVkIG9yZGVyIiwgIm1vYmlsZU51bWJlciI6ICI5eHh4eHh4eHh4IiwgInNob3J0TmFtZSI6ICJBbWl0IiwgInRyYW5zYWN0aW9uSWQiOiAiVFgxMjM0NTY3ODkiLCAibWVyY2hhbnRVc2VySWQiOiAiVTEyMzQ1Njc4OSIsICJtZXJjaGFudElkIjogIkRlbW9NZXJjaGFudCIsICJlbWFpbCI6ICJhbWl0eHh4NzVAZ21haWwuY29tIn0"
}
Suggest Edits

S2S Call Back

 
  • Server to server callbacks are initiated from PhonePe server to the url provided by merchant when payment reaches to any terminal state (SUCESS or FAIL)
    Callback url can be send along with each payment request in initiateTransactionRequest() API

The URL is specified in header X-CALLBACK-URL

The payload that is going to be sent to the merchant on the specified callback url will have a base64 encoded json.

Upon base64 decoding the response, you should get a json with format similar to the response returned by transaction status API

This is the best case callback that would be sent from PhonePe server to the merchants' server. In the event of a callback failure, the onus is on the merchants to use the transaction status API and take the transaction to closure.

Callback headers

Following are the response headers sent with a callback.

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256(response + salt key) + ### + salt index

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

true/ false

code

ENUM(see list of codes below)

This parameter is used to decide if payment is success or failed

transactionId

STRING

transactionId (if this is static QR then this will be generated by PhonePe)

merchantId

STRING

merchantId

amount

LONG

Amount in paisa

providerReferenceId

STRING

PhonePe transactionId

paymentState

STRING

COMPLETED/ FAILED

payResponseCode

STRING

More granular error codes for failure.

Server to Server Callback Response Codes

Code
Description

PAYMENT_SUCCESS

Payment is successful for QR scan

PAYMENT_ERROR

Payment failed for QR scan

PAYMENT_DECLINED

Payment declined by customer

PAYMENT_CANCELLED

Payment cancelled by merchant

Payment Modes

Parameter Name
Description

amount

Amount in paisa

utr

UTR for UPI payments.

  1. Success/Failure of transaction should be dependent on the code in response parameters
  2. Cross-check the amount which has been passed in forward payment path(Accept payment API) and in the response of Server to Server callback.
curl -X POST \
  https://api.merchant.com/response/phonepe \
  -H 'content-type: application/json' \
  -H 'x-verify: 2abaa82a4810c57dcd6aa52680dd772173b1e40770afe028131f31ddbe5487a8###1' \
  -d '{
	"response":"ewoJInN1Y2Nlc3MiOiB0cnVlLAoJImNvZGUiOiAiUEFZTUVOVF9TVUNDRVNTIiwKCSJkYXRhIjogewoJCSJ0cmFuc2FjdGlvbklkIjogImY2MjI0MjBmLTJmNTgtNGYyZS04MzJmIiwKCQkibWVyY2hhbnRJZCI6ICJNSURURVNUIiwKCQkiYW1vdW50IjogMTAwMCwKCQkicHJvdmlkZXJSZWZlcmVuY2VJZCI6ICJQMTkxMjE4MTIxMDM1NzQyMTc1Njc1NSIsCgkJInBheW1lbnRTdGF0ZSI6ICJDT01QTEVURUQiLAoJCSJwYXlSZXNwb25zZUNvZGUiOiAiU1VDQ0VTUyIKCX0KfQ=="
}'

{
  "response": "ewoJInN1Y2Nlc3MiOiB0cnVlLAoJImNvZGUiOiAiUEFZTUVOVF9TVUNDRVNTIiwKCSJkYXRhIjogewoJCSJ0cmFuc2FjdGlvbklkIjogImY2MjI0MjBmLTJmNTgtNGYyZS04MzJmIiwKCQkibWVyY2hhbnRJZCI6ICJNSURURVNUIiwKCQkiYW1vdW50IjogMTAwMCwKCQkicHJvdmlkZXJSZWZlcmVuY2VJZCI6ICJQMTkxMjE4MTIxMDM1NzQyMTc1Njc1NSIsCgkJInBheW1lbnRTdGF0ZSI6ICJDT01QTEVURUQiLAoJCSJwYXlSZXNwb25zZUNvZGUiOiAiU1VDQ0VTUyIKCX0KfQ=="
}
{
"success": true,
"code": "PAYMENT_SUCCESS",
"data": {
"transactionId": "f622420f-2f58-4f2e-832f",
"merchantId": "MIDTEST",
"amount": 1000,
"providerReferenceId": "P1912181210357421756755",
"paymentState": "COMPLETED",
"payResponseCode": "SUCCESS"
}
}

Suggest Edits

Payment Flow with SDK

 

PhonePe expects all merchants to show the PhonePe Payment Page at the time of checkout.

A user selects a product, confirms the booking and clicks on PAY in the Switch. He is then redirected to PhonePe's payments page. He can pay using any payment mode provided by PhonePe. After the payment flow is completed he will be redirected to the Switch.

We expect all the merchants to show user order details(My Orders/MyTrips/My History) inside his APP.

You can see the flow diagram here.

Payments Integration will involve steps as :

Step 1 : Integrating with S2S Initiate Transaction() API

Type of integration
Details

PWA/M-Site/React Native

Step 2 : Integrating with client-side SDK method proceedToPay()

Type of integration
Details

PWA/M-Site/React Native

Example: Travel App inside PhonePe shows PhonePe's payments page when the user clicks on "Proceed To Pay".

Step 7: Polling Transaction Status

After payment is completed, the user will be redirected on the same page where the proceedToPay() method was called from. To get the status of the transaction, the merchant needs to hit Check Transaction Status API to fetch the status of the transaction. The merchant needs to redirect the user to the corresponding success or failure page to display the result fetched from the above API.

Step 8: Refund

There can be a couple of cases in which refunds might need to be triggered by the merchant:

  • User cancels the order
  • Merchant times out when waiting for the payment from PhonePe (using Check Transaction Status) and the payment comes after the merchant times out. The merchant should trigger a refund for the transaction.
Suggest Edits

Payment Flow Diagram

 
  1. The user selects a product, confirms the booking and clicks on PAY in the Switch .

  2. Switch server hits the PhonePe server sending order details like merchantId, transactionId, OrderId, transactionContext, and cartDetails as described in the PhonePe initiate Transaction Request() API.

transactionContext takes trackingInfo as input which is used on the PhonePe APP to take a user to their specific booking inside the Switch. Example :

"trackingInfo": {
        "type": "HTTPS",
        "url": "https://google.com"
      },

For eg.,
In the image below, a ​user can click on “VIEW BOOKING” to get redirected to the Hotels Switch on PhonePe and list the booking details corresponding to the transaction Id. You can find the details here.

Switch need to share its cart details with PhonePe in initiate API. You can find the details for your use-case here

"cartDetails": {} 
  1. PhonePe's server sends back the response of initiateTransaction API () API to the Switch server which needs to be passed onto the Switch.
    Example:
    In response to initiateTransaction API() API, Switch server would receive “reservationId” field which needs to be passed to the Switch.

Sample Curl Request (Please see the API for more details)

curl -X POST \
  https://apps-uat.phonepe.com/v3/transaction/initiate \
  -H 'Content-Type: application/json' \
  -H 'Host: apps-uat.phonepe.com' \
  -H 'X-CALLBACK-URI: http://www.test.com' \
  -H 'X-VERIFY: 5cd50830b45f98a3703d833f7255a611c4204d72ed2be998227688d01aeac07c###2' \
  -d '{ "request": "ewogIm1lcmNoYW50SWQiOiJQQVlVTUFJTiIsCiAiYW1vdW50IjoxMDAwMDAwMCwKICJ2YWxpZEZvciI6IDkwMDAwMCwKICJzdWJNZXJjaGFudElkIjogIlBBWU1FUkNIQU5UVEVTVCIsCiAidHJhbnNhY3Rpb25JZCI6ICIxMTIzNDIxNC00MjE0MTIxMzExMjMtMTI1MTAxMjEyMjEiLAogIm1lcmNoYW50T3JkZXJJZCI6IjExMjM0MjE0LTQyMTQxMTIzMTEyMy0xMjUxMTEyMTIyMSIsCiAidHJhbnNhY3Rpb25UeXBlIjogIlNUQU5EQVJEIiwKICJ0cmFuc2FjdGlvbkNvbnRleHQiOiAiZXdvZ0lDQWdJbTl5WkdWeVEyOXVkR1Y0ZENJNmV3b2dJQ0FnSUNBaWRISmhZMnRwYm1kSmJtWnZJanA3Q2lBZ0lDQWdJQ0FnSW5SNWNHVWlPaUpJVkZSUUlpd0tJQ0FnSUNBZ0lDQWlkWEpzSWpvaWFIUjBjRG92TDJkdmIyZHNaUzVqYjIwaUNpQWdJQ0FnSUgwc0NpQWdJQ0FnSUNKemRYQndiM0owU1c1bWJ5STZJSHNLSUNBZ0lDQWdJQ0FpZEhsd1pTSTZJa2hVVkZBaUxBb2dJQ0FnSUNBZ0lDSjFjbXdpT2lKb2RIUndPaTh2WjI5dloyeGxMbU52YlNJS0lDQWdJQ0FnZlFvZ0lDQWdmU3dLSUNBZ0lDSm1ZWEpsUkdWMFlXbHNjeUk2ZXdvZ0lDQWdJQ0FpZEc5MFlXeEJiVzkxYm5RaU9qRXdNQ3dLSUNBZ0lDQWdJbkJoZVdGaWJHVkJiVzkxYm5RaU9qRXdNQW9nSUNBZ2ZTd0tJQ0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es 
	"data": {
		"reservationId": "String"
	}
}
  1. To open the PhonePe's Payments page, the Switch calls proceedToPay() API on the JS-SDK method posting “reservationId” field received from the Switch server.

  2. PhonePe payments page opens and the user is shown all the payment options of the PhonePe APP.

  3. The user completes the payment on the PhonePe APP and is redirected back to the Switch.

  4. The Switch checks the status of the transaction asking its server.

  5. The Switch server hits getTransactionStatus() API on PhonePe server's, receiving the status of the transaction.

  6. Switch server would receive the status as pending until PhonePe receives a confirmation from the Bank.

  7. As soon as PhonePe receives a callback from the Bank of Payment success or Failure, Switch server would receive success or failure in getTransactionStatus() API.

  8. Order fulfilment page is shown by the Switch.

Suggest Edits

Initiate Transaction Request

 
posthttps://apps-uat.phonepe.com/v3/transaction/initiate
curl --request POST \
  --url https://apps-uat.phonepe.com/v3/transaction/initiate
var request = require("request");

var options = { method: 'POST',
  url: 'https://apps-uat.phonepe.com/v3/transaction/initiate' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://apps-uat.phonepe.com/v3/transaction/initiate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://apps-uat.phonepe.com/v3/transaction/initiate");

xhr.send(data);
import requests

url = "https://apps-uat.phonepe.com/v3/transaction/initiate"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

{
	"success": Boolean,
	"code": "String",// Response Codes 
	"data": {
		"reservationId": "String"
	}
}

Headers

X-VERIFY
string

SHA256(base64 encoded payload + "/v3/transaction/initiate" + salt key) + '###' + salt index

X-CLIENT-ID
string

This will verify corresponding to the merchants. The default value will be merchant ID

Content-Type
string

Content-Type

X-CALLBACK-URL
string

Callback API of the merchant

 

Request Headers

Header Name
Header Value

Content-Type

application/json

X-VERIFY

SHA256(base64 encoded payload +
"/v3/transaction/initiate" + salt key) + '###' + salt index

X-CLIENT-ID

This will verify corresponding to the merchants. The default value will be merchant ID

X-CALLBACK-URL

Please find the details here

Every service request has cart details that are typed by the category of that request. Here is an example for the category Bus.

The category tree is managed and maintained by PhonePe.

Request Parameters

Parameter Name
Type
Description
Mandatory

merchantId

STRING

Unique MerchantID assigned to the merchant by PhonePe

Yes

subMerchantId

STRING

Unique subMerchantId assigned to the merchant by PhonePe

Optional

transactionId

STRING

Unique TransactionID generated by the merchant to track request to PhonePe
transactionId length should be less than 38 characters.

Yes

amount

INT

Transaction amount in Paise

Yes

validFor

LONG

Time in Miliseconds for which the payment is valid

Yes

merchantOrderId

STRING

OrderID generated by the merchant
merchantOrderId length should be less than 48 characters

Yes

transactionContext

STRING

Base 64 encoded of the cart details pertaining to the category

Yes

Response Parameters

Parameter Name
Type
Description

success

BOOLEAN

Success status of the request

code

ENUM

See list of response codes below

data

Object

The data object that has to be passed to the sdk. The data will have reservation id.

Response Codes

Code
Description

INVALID_TRANSACTION_ID

Duplicate TransactionID

INVALID_USER_AUTH_TOKEN

The userAuthToken provided is either invalid or not mapped to merchant.

BAD_REQUEST

Invalid request payload

AUTHORIZATION_FAILED

Incorrect X-VERIFY header

INTERNAL_SERVER_ERROR

Something went wrong

API_RATE_LIMIT_REACHED

If the api call limit is breached then API_LIMIT & TIME_WINDOW would be sent with HTTP status 429

It's recommended to have the server to server call back using x-callback-url header.

{
 "merchantId":"MERCHANTTEST",
 "amount":10000000,
 "validFor": 900000,
 "subMerchantId": "SUBMERCHANTTEST",
 "transactionId": "T12RTRTBJGGTGJNYGB",
 "merchantOrderId":"T12RTRTBJGGTGJNYGB",
 "transactionContext": "ewogICAgIm9yZGVyQ29udGV4dCI6ewogICAgICAidHJhY2tpbmdJbmZvIjp7CiAgICAgICAgInR5cGUiOiJIVFRQIiwKICAgICAgICAidXJsIjoiaHR0cDovL2dvb2dsZS5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UWtKQ1FrSkNTSjJZV3gxWlNJNklERXdDZ2tKQ1FrSkNRbDlMQW9KQ1FrSkNRa0pJbU5oYm1ObGJHeGhkR2x2YmtsdWRHVnlkbUZzSWpvZ2V3b0pDUWtKQ1FrSkNTSjBlWEJsSWpvZ0lsSkZURUZVU1ZaRklpd0tDUWtKQ1FrSkNRa2labkp2YlNJNklIc0tDUWtKQ1FrSkNRa0pJbXRsZVNJNklDSklUMVZTVXlJc0Nna0pDUWtKQ1FrSkNTSjJZV3gxWlNJNklDMHhDZ2tKQ1FrSkNRa0pmU3dLQ1FrSkNRa0pDUWtpZEc4aU9pQjdDZ2tKQ1FrSkNRa0pDU0pyWlhraU9pQWlTRTlWVWxNaUxBb0pDUWtKQ1FrSkNRa2lkbUZzZFdVaU9pQXlOQW9KQ1FrSkNRa0pDWDBLQ1FrSkNRa0pDWDBLQ1FrSkNRa0pmUW9KQ1FrSkNWMHNDZ2tKQ1FrSkluQmhjblJwWVd4RFlXNWpaV3hzWVhScGIyNUJiR3h2ZDJWa0lqb2dabUZzYzJVS0NRa0pDWDBLQ1FrSmZWMHNDZ2tKQ1NKaFpIVnNkRU52ZFc1MElqb2dNU3dLQ1FrSkltTm9hV3hrUTI5MWJuUWlPaUF4Q2drSmZRb0pmUW9nSUgwPSIKfQ==" }
Suggest Edits

Show Payments Page

 

proceedToPay

(reservationId: string, fallbackUrl: string): Promise<any>
Description: This method needs to be called on an instance of the sdk to open PhonePe's payments page.

Request Parameters

Parameter Name
Type
Description

reservationId

string

Reservation id which is received by initiate transaction API

fallbackURL

string

URL to redirect after PhonePe payments flow completion, in case the webview activity gets killed (android)

Usage:

//Dummy information
// Replace this with the response from /v3/transaction/initiate API, reservation id will be recieved in the response as : 

{ 
"success": Boolean, "code": String, // Response Codes 
"data": { 
"reservationId": String } }

// Use the same in below request


PhonePe.PhonePe.build(PhonePe.Constants.Species.web).then((sdk) => { 
sdk.proceedToPay("R52312738686728361283", "http://google.co.in").then((response) => { 
console.log("Payment was successful = " + response) }).catch((err) => { 
console.log("Payment failed") }) })

Response Parameters

Promise<any> - The promise rejection reasons can be as follows:

Code
Description

PAYMENT_DISMISS

User pressed back button on the payments screen

PAYMENT_TIMEOUT

When the payment timed out based on the timeout interval sent by merchant to PhonePe's server in the payment initiate server call

PARAMS_INVALID_OR_INSUFFICIENT

Insufficient Parameters sent.

INTERNAL_ERROR

PhonePe's Internal error

Promise resolve:
{}

Promise reject:
{
  'error_code': 'PAYMENT_DISMISS/PAYMENT_TIMEOUT'
}