Create PhonePe Instance

build

(species: string): Promise
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

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.

<html-block html=”

Request Parameter

“>

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

<html-block html=”

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.

<html-block html=”

Request Parameter

“>

Parameter NameTypeDescription
methodNamestringName of the method that you’d be calling

<html-block html=”

Response Parameter

“>

boolean

Usage:

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