Show Payments Page

openPaymentsPage

(merchantName:
Description: An instance of this class needs to be created and sent to navigateToPage method to open PhonePe's payment page.

Request Parameters

Parameter Name

Type

Description

merchantName

string

Name of the merchant. This will be displayed in the PhonePe's payments page.

context

object

Data sent by PhonePe server's service initiate() call Initiate Service Request

imageURL

undefined/string

URL for an image that reflects the merchant's logo

metaData

array of objects

This data is shown in the PhonePe's payments screen as a set of key-value pairs.
example :
[
{
"Name of Products": "Ritz Carlton,Test, XYZ"
},
{
"Number of items": "2"
}
]

Usage:

//Dummy information
let merchantName = "DummyMerchant"
let imageURL = "https://image.dummymerchant.com"
//Any metadata to show on PhonePe's payment screen
let metadata = [{
    "Movie": "Avengers"
}, {"Seats": "3E, 4E, 5E"}]

sdk.openPaymentsPage(merchantName, context, null, imageURL, metadata).then((response) => {
  console.log("Payment was successful = " + response)
}).catch((err) => {
  console.log("Payment failed with error = " + err)
})
Promise resolve:
{}

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

Response Parameters

Promise<any>
Promise resolve is called when the payment flow is complete.
Promise reject is called in case of an error.
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

Invalid or insufficient Parameters sent.

INTERNAL_ERROR

PhonePe's Internal error