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 NameTypeDescription
merchantNamestringName of the merchant. This will be displayed in the PhonePe's payments page.
contextobjectData sent by PhonePe server's service initiate() call Initiate Service Request
imageURLundefined/stringURL for an image that reflects the merchant's logo
metaDataarray of objectsThis 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:

CodeDescription
PAYMENT_DISMISSUser pressed back button on the payments screen
PAYMENT_TIMEOUTWhen 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_INSUFFICIENTInvalid or insufficient Parameters sent.
INTERNAL_ERRORPhonePe's Internal error