# ionic-capacitor-phonepe-pg

A Plugin to integrate with Ionic Platform for PhonePe Payment Solutions

## Install

```bash
npm i ionic-capacitor-phonepe-pg
npx cap sync
```

## API

<docgen-index>

* [`init(...)`](#init)
* [`startTransaction(...)`](#starttransaction)
* [`getUpiAppsForAndroid()`](#getupiappsforandroid)
* [`getUpiAppsForIos()`](#getupiappsforios)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### init(...)

```typescript
init(options: { environment: string; merchantId: string; flowId: string; enableLogging: boolean | false; }) => Promise<Record<string, boolean>>
```

This method is used to initiate PhonePe Payment sdk.
Provide all the information as requested by the method signature.
Params:
   - environment: This signified the environment required for the payment sdk
     possible values: SANDBOX, PRODUCTION
     if any unknown value is provided, PRODUCTION will be considered as default.
   - merchantId: The merchant id provided by PhonePe  at the time of onboarding.
   - flowId : An alphanumeric string without any special character. It acts as a common ID b/w
     your app user journey and PhonePe SDK. This helps to debug prod issue.
     Recommended - Pass user-specific information or merchant user-id to track the journey.
   - enableLogging: If you want to enable / visualize sdk log @IOS
       - enabled = TRUE
       - disable = FALSE
   - Return: <a href="#boolean">Boolean</a> (TRUE -&gt; SUCCESS).
       - SUCCESS: TRUE
       - FAILURE: FALSE
           - in iOS = False (if AppID missing:-Please provide PhonePe AppId)
           - in Android = Error in case of invalid arguments ex: "Invalid environment or merchantId!"

| Param         | Type                                                                                              |
| ------------- | ------------------------------------------------------------------------------------------------- |
| **`options`** | <code>{ environment: string; merchantId: string; flowId: string; enableLogging: boolean; }</code> |

**Returns:** <code>Promise&lt;<a href="#record">Record</a>&lt;string, boolean&gt;&gt;</code>

--------------------


### startTransaction(...)

```typescript
startTransaction(options: { request: string; showLoaderFlag: Boolean | true; appSchema: string | null; }) => Promise<Record<string, string>>
```

This method is used to initiate PhonePe B2B PG Flow.
Provide all the information as requested by the method signature.
Params:
   - request : The request body for the transaction as per the developer docs, Make sure the request body is base64encoded.
   - appSchema: @Optional(Not need for Android) For iOS, Your custom URL Schemes, as per the developer docs.
   - showLoaderFlag: @Optional(Default: true) used for hiding the loader visibility in phonepe app intent launch.
Return: Will be returning a dictionary / hashMap
 { 
    status: String, // string value to provide the status of the transaction
                    // possible values: SUCCESS, FAILURE, INTERRUPTED
    error: String   // if any error occurs
 }

| Param         | Type                                                                                                                 |
| ------------- | -------------------------------------------------------------------------------------------------------------------- |
| **`options`** | <code>{ request: string; showLoaderFlag: true \| <a href="#boolean">Boolean</a>; appSchema: string \| null; }</code> |

**Returns:** <code>Promise&lt;<a href="#record">Record</a>&lt;string, string&gt;&gt;</code>

--------------------


### getUpiAppsForAndroid()

```typescript
getUpiAppsForAndroid() => Promise<Record<string, string>>
```

This method is called to get list of upi apps in @Android only.
Return: String
 JSON String -&gt; List of UPI App with packageName, applicationName & versionCode
 NOTE :- In iOS, it will throw os error at runtime.

**Returns:** <code>Promise&lt;<a href="#record">Record</a>&lt;string, string&gt;&gt;</code>

--------------------


### getUpiAppsForIos()

```typescript
getUpiAppsForIos() => Promise<Record<string, string>>
```

This method is called to get list of upi apps in @iOS only.
Return: String
 JSON String -&gt; List of UPI App with applicationName that are installed in the device and supported by PhonePe SDK
 NOTE :- In Android, it will throw os error at runtime.

**Returns:** <code>Promise&lt;<a href="#record">Record</a>&lt;string, string&gt;&gt;</code>

--------------------


### Interfaces


#### Boolean

| Method      | Signature        | Description                                          |
| ----------- | ---------------- | ---------------------------------------------------- |
| **valueOf** | () =&gt; boolean | Returns the primitive value of the specified object. |


### Type Aliases


#### Record

Construct a type with a set of properties K of type T

<code>{ [P in K]: T; }</code>

</docgen-api>
