---
title: Mobile SDKs
slug: sdks/mobile-sdks
hidden: false
metadata:
  robots: index
  title: Mobile SDKs Integration Steps | Pine Labs Payment gateway
  description: >-
    Mobile SDKs Integration Steps for Pine Labs Payment gateway for all the
    platforms.
sidebar_order: 3
---

## Integration Steps

Learn how you can integrate with Pine Labs Native SDKs across all platforms. The SDK provides a secure hosted checkout experience using backend APIs and client-side SDKs for seamless payment processing.

1. <a href ="#prerequisites" >Prerequisites</a>
2. <a href ="#integrate-apis-in-your-backend" >Integrate APIs in Your Backend</a>
3. <a href ="#sdk-installation--initialization" >SDK Installation and Initialization</a>
4. <a href ="#handle-payment-callbacks" >Handle Payment Callbacks</a>
5. <a href ="#manage-transactions" >Manage Transactions</a>


> ### ❗️ Security Best Practices:
> 
> - Ensure you store your Client ID and Secret in your Backend securely.
> - Integrate our APIs on your backend system.
> - We strictly recommend not to call our APIs from the frontend.
> - Failure to adhere to the above guidelines may result in legal implications. In such cases, you will be held responsible for any damage or loss arising from non-compliance.

<h2 id="prerequisites">1. Prerequisites</h2>

### 1.1. Android

#### 1.1.1. Requirements:

- Android SDK version 21 (Lollipop) or higher
- Android Studio 4.0 or higher
- Internet permissions configured in AndroidManifest.xml

### 1.2. iOS
#### 1.2.1. Requirements:

| Category | Minimum Supported |
| --- | --- |
| iOS Version | `iOS 16.0+` |
| Xcode Version | `Xcode 15.0+` |
| Swift Version (SDK) | `Swift 5.x` |
| Swift Version (App) | `Swift 4+` |
| Framework Type | `XCFramework` |
| Architectures | `arm64` |

#### 1.2.2. Enable Apple Pay Capability in Xcode:

**1.2.2.1. Open Your Project in Xcode**

1. Launch **Xcode** and open your project.
2. In the **Project Navigator** (left panel), select your **project name**.
3. Under **Targets**, select your **app target**.

**1.2.2.2. Configure Signing & Capabilities**

1. Click on the **Signing & Capabilities** tab at the top of the main editor.
2. Ensure that your **Team** and **Bundle Identifier** are properly configured.
3. Verify that your project uses a valid **Apple Developer account** (with Merchant ID access).

**1.2.2.3. Add the Apple Pay Capability**

1. Click the `**+ Capability**` button in the top-left corner.
2. In the popup, search for **Apple Pay**.
3. Double-click **Apple Pay** (or press Enter) to add it.
4. The **Apple Pay** capability will now appear under your app’s capabilities list.

**1.2.2.4. Configure Merchant IDs**

1. Under the newly added Apple Pay section, locate **Merchant IDs**.
2. Click the “+” button to add one.
3. Select an existing Merchant ID if already created in the Apple Developer Portal.
4. If not available, choose “Add an Account → Manage Certificates, Identifiers & Profiles” to create a new Merchant ID.
5. Use a naming convention such as:

```text
bussiness_name.com.yourcompany.app
```

**1.2.2.5. Verify Entitlements**

Xcode automatically adds the required **entitlements file** (if not already present) and enables the following key:

```xml
<key>com.apple.developer.in-app-payments</key>
<array>
<string>merchant.com.yourcompany.app</string>
</array>
```

This ensures your app is authorized to process Apple Pay transactions using the registered Merchant ID(s).

<h2 id="sdk-installation--initialization"> 2. Integrate APIs in Your Backend</h2>

Start a payment by triggering the payment flow. To start a payment follow the below steps:

### 2.1. Generate Auth Token

Integrate our Generate Token API in your backend servers to generate the auth token. Use the token generated to authenticate Pine Labs Online APIs.

Below are the sample requests and response for the Generate Token API.

```curl cURL – UAT
curl --location 'https://pluraluat.v2.pinepg.in/api/auth/v1/token' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--data '
{
  "client_id": "a17ce30e-f88e-4f81-ada1-c3b4909ed232",
  "client_secret": "fgwei7egyhuggwp39w8rh",
  "grant_type": "client_credentials"
}
'
```
```curl cURL – PROD
curl --location 'https://api.pluralpay.in/api/auth/v1/token' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--data '
{
  "client_id": "a17ce30e-f88e-4f81-ada1-c3b4909ed232",
  "client_secret": "fgwei7egyhuggwp39w8rh",
  "grant_type": "client_credentials"
}
'
```
```json Sample Response
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "expires_in": 3600
}
```

<GenerateToken />

Refer to our <a href="../api/authentication/generate-token" >Generate Token API</a> documentation to learn more.

## 2.2. Generate Checkout Link

Use this API to Generate a checkout link, for authentication use the generated access token in the headers of the API request.

Below are the sample requests and response for a Generate Checkout Link API.

```curl cURL - UAT
curl --request POST \
     --url https://pluraluat.v2.pinepg.in/api/checkout/v1/orders \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "merchant_order_reference": "112345",
  "order_amount": {
    "value": 1100,
    "currency": "INR"
  },
  "integration_mode": "SDK",
  "pre_auth": false,
  "allowed_payment_methods": [
    "CARD",
    "UPI",
    "NETBANKING",
    "POINTS",
    "WALLET"
  ],
  "notes": "order1",
  "callback_url": "https://sample-callback-url",
  "failure_callback_url": "https://sample-failure-callback-url",
  "purchase_details": {
    "customer": {
      "email_id": "kevin.bob@example.com",
      "first_name": "Kevin",
      "last_name": "Bob",
      "customer_id": "123456",
      "mobile_number": "9876543210",
			"country_code": "91",
      "billing_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",
        "full_name": "harsh kumar",
        "address_type": "HOME/WORK/OTHER",
        "address_category": "BILLING"
      },
      "shipping_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",
        "full_name": "harsh kumar",
        "address_type": "HOME/WORK/OTHER",
        "address_category": "BILLING"
      }
    },
    "merchant_metadata": {
      "express_checkout_enabled": "TRUE",
      "express_checkout_allowed_action": "checkoutCollectAddress",
      "key1": "DD",
      "key2": "XOF"
    }
  },
  "cart_details": {
    "cart_items": [
      {
        "item_id": "cart_id_1",
        "item_name": "T Shirt",
        "item_description": "Test Description",
        "item_details_url": "https://chriscross.in/cdn/shop/files/95_800x.jpg",
        "item_image_url": "https://chriscross.in/cdn/shop/files/95_800x.jpg",
        "item_original_unit_price": 1,
        "item_discounted_unit_price": 1,
        "item_quantity": 1,
        "item_currency": "INR"
      }
    ]
  }
}
'
```
```curl cURL - PROD
curl --request POST \
     --url https://api.pluralpay.in/api/checkout/v1/orders \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "merchant_order_reference": "112345",
  "order_amount": {
    "value": 1100,
    "currency": "INR"
  },
  "integration_mode": "SDK",
  "pre_auth": false,
  "allowed_payment_methods": [
    "CARD",
    "UPI",
    "NETBANKING",
    "POINTS",
    "WALLET"
  ],
  "notes": "order1",
  "callback_url": "https://sample-callback-url",
  "failure_callback_url": "https://sample-failure-callback-url",
  "purchase_details": {
    "customer": {
      "email_id": "kevin.bob@example.com",
      "first_name": "Kevin",
      "last_name": "Bob",
      "customer_id": "123456",
      "mobile_number": "9876543210",
			"country_code": "91",
      "billing_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",
        "full_name": "harsh kumar",
        "address_type": "HOME/WORK/OTHER",
        "address_category": "BILLING"
      },
      "shipping_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",
        "full_name": "harsh kumar",
        "address_type": "HOME/WORK/OTHER",
        "address_category": "BILLING"
      }
    },
    "merchant_metadata": {
      "express_checkout_enabled": "TRUE",
      "express_checkout_allowed_action": "checkoutCollectAddress",
      "key1": "DD",
      "key2": "XOF"
    }
  },
  "cart_details": {
    "cart_items": [
      {
        "item_id": "cart_id_1",
        "item_name": "T Shirt",
        "item_description": "Test Description",
        "item_details_url": "https://chriscross.in/cdn/shop/files/95_800x.jpg",
        "item_image_url": "https://chriscross.in/cdn/shop/files/95_800x.jpg",
        "item_original_unit_price": 1,
        "item_discounted_unit_price": 1,
        "item_quantity": 1,
        "item_currency": "INR"
      }
    ]
  }
}
'
```
```json Sample Response
{
  "token": "REDIRECT TOKEN",
  "order_id": "ORDER ID",
  "redirect_url": "https://api.pluralonline.com/api/v3/checkout-bff/redirect/checkout?token=REDIRECT TOKEN",
  "response_code": 200,
  "response_message": "Order Creation Successful."
}
```

Refer to our <a href="../api/checkout/generate-checkout-link" >Generate Checkout Link</a> documentation to learn more.

<h2 id="integrate-apis-in-your-backend"> 3. SDK Installation & Initialization</h2>

### 3.1. Android

#### 3.1.1. Installation

Follow the steps below to add the Infinity SDK to your Android application and initialize it using the token from the Order Creation API.

**Step 1: Add the SDK Dependency**

Add the dependency to your app-level `build.gradle` file.

```gradle gradle
  dependencies {
      implementation("com.github.plural-pinelabs:Pinelabs-Android-SDK:1.1.8")
  }
```

Alternatively, you can declare it through catalog styling using libs.versions.toml.


<DocImage src="images/image-1779282457358.png" alt="image" sizing="70%" caption="" />


  **Step 2: Sync Your Project**

  Sync your project with Gradle to download the SDK and make it available in your build.
  
#### 3.1.2. Initialization

To initialise the android web SDK, follow the below steps:

**Step 1: Initialize and Launch the SDK**

Use the method below to start the SDK and pass the token received from the Create Order API.

  ```kotlin Kotlin
  ExpressSDKInitializer().initializeSDK(
      this@MainActivity,
      "${tokenEt.text}", // Replace with the actual Redirect token
      object : ExpressSDKCallback {

          override fun onError(
              errorCode: String?,
              errorMessage: String?,
              errorDescription: String?
          ) {
              Toast.makeText(
                  this@MainActivity,
                  "Error: $errorCode, $errorMessage, $errorDescription",
                  Toast.LENGTH_LONG
              ).show()
              Log.e("ExpressSDK", "Error: $errorCode, $errorMessage, $errorDescription")
          }

          override fun onSuccess(
              responseCode: String?,
              responseMessage: String?,
              responseDescription: String?
          ) {
              Toast.makeText(
                  this@MainActivity,
                  "Success: $responseCode, $responseMessage, $responseDescription",
                  Toast.LENGTH_LONG
              ).show()
              Log.i("ExpressSDK", "Success: $responseCode, $responseMessage, $responseDescription")
          }

          override fun onCancel(
              responseCode: String?,
              responseMessage: String?,
              responseDescription: String?
          ) {
              Toast.makeText(
                  this@MainActivity,
                  "Cancelled: $responseCode, $responseMessage, $responseDescription",
                  Toast.LENGTH_LONG
              ).show()
              Log.d("ExpressSDK", "Cancelled: $responseCode, $responseMessage, $responseDescription")
          }
      },
      true // Set to false for PROD, true for UAT
  )
  ```


<DocImage src="images/image-1779282510385.png" alt="image" sizing="70%" caption="" />


**Step 2: Configure the Environment**

Configure the `runInSandBox` flag based on the environment:

1. **UAT (Testing)**: `Set runInSandBox = true`
2. **Production (Live)**: `Set runInSandBox = false`

  <Callout icon="fa-info-circle" theme="info">
    <strong>Note:</strong> Always validate the full flow in UAT before switching to Production.
  </Callout>

### 3.2. iOS

#### 3.2.1. Installation

##### 3.2.1.1. Swift Package Manager

###### Add the SDK via Swift Package Manager

Recommended method for easy updates and dependency management

### Requirements

- Xcode 12.5+
- iOS 11.0+

### Installation Steps

1. **Open your project in Xcode**
Launch Xcode and open your iOS project.

2. **Navigate to Add Packages**
Go to the menu:

```text
File → Add Packages…
```

<DocImage src="images/image-1779282539939.png" alt="Packages" sizing="50%"  caption="" />


3. **Enter SDK GitHub URL**

In the search bar, paste the SDK GitHub URL `https://github.com/plural-pinelabs/Infinity_Checkout_iOS_SDK`.

<DocImage src="images/image-1779282581592.png" alt="SDK GitHub" sizing="70%"  caption="" />


4. **Select Release Tag**

Choose the latest Release Tag (e.g., `1.1.1`).

5. **Add to App Target**

Add the package to your App Target.

<DocImage src="images/image-1779282635266.png" alt="Add to App Target" sizing="70%"  />


6. **Verify Installation**

Once added, it should appear in the General tab of your app target. You can also see the package details by clicking on the Package Dependency.


<DocImage src="images/image-1779282684586.png" alt="Verify Installation" sizing="70%"  />


You can also see the package details by clicking on the Package Dependency.

<DocImage src="images/image-1779282713960.png" alt="Package Dependency" sizing="70%"  />


<Callout icon="fa-info-circle" theme="info">
      <strong>Easy Updates</strong>
      <br />
      In case of any new release update, simply select <strong>Update Package</strong> and it will automatically get the latest build.
    </Callout>

<DocImage src="images/image-1779282758082.png" alt="Update Package" sizing="70%"  />

    
#### 3.2.1.2. Manual Installation   
##### Add the SDK via Manual Method

To add the SDK to your app, import the `(SDKFramework).xcframework` file to the project using the following steps:

### Installation Steps

1. **Download the SDK Framework**

You can download the SDK as a `(SDKFramework).xcframework` file here, which is in a package format that Apple recommends for distributing binary frameworks.

2. **Drag and Drop Framework**

Drag and drop the `(SDKFramework).xcframework` file into your Xcode project in the Project Navigator under the Frameworks section.

3. **Configure Dialog Settings**

A dialog box will appear when you drop the framework file into your project.

<Callout icon="fa-exclamation-triangle" theme="warning">
         Ensure that the checkbox labeled <strong>"Copy items if needed"</strong> is selected. This ensures the framework gets copied into your project directory, making it available for builds.
       </Callout>

4. **Complete Installation**

Drag and drop the .xcframework in the app.

<DocImage src="images/image-1779282801823.png" alt="Complete Installation" sizing="70%"  />


Copy files to destination.

<DocImage src="images/image-1779282842399.png" alt="copy to destination" sizing="70%" />

    

### 3.2.2. Configuration

You need to configure the target to embed the SDK framework properly.

1. **Navigate to the General tab of your target's settings**- Add the `(SDKFramework).xcframework` file under the Frameworks, Libraries, and Embedded Content section.
2. **Ensure you choose `Embed & Sign`** -  This ensures the framework is embedded in your app when it's built and signed properly to run on iOS devices.

<DocImage src="images/image-1779282877324.png" alt="Configuration" sizing="70%" />


<Callout icon="fa-info-circle" theme="info">
    <strong>Note:</strong> Once the `.xcframework` is embedded, you can import the package in the view controller.
  </Callout>

3. **Info.plist update:** To ensure proper functionality, you must update your app’s Info.plist (**Information Property List**) file to allow the required connections.

To enable UPI payments, add the necessary URL Schemes in the Info.plist file as shown below:

<DocImage src="images/image-1779282904612.png" alt="UPI payments" sizing="70%" />


<DocImage src="images/image-1779282932904.png" alt="URL Schemes" sizing="40%" />


Without these entries, the SDK won’t be able to navigate to the required UPI payment app.


### 3.2.3. Initialization

To initialise the iOS Native SDK, follow the below steps:

1. Import the SDK into the app.
2. Create an object of the class `PineLabsOnlineSDKManager` to initiate the payment function. In your application, you are creating a function that passes the **order token** received from the create order response to start the payment function of our SDK.


<DocImage src="images/image-1779282965405.png" alt="Initialize Code" sizing="70%"/>

#### Parameters for startPayment:

**from**: Pass the context of the current ViewController where the SDK is invoked(generally ‘self’).  
**orderToken**: The token generated from the Create Hosted Checkout API response.  
**environment**: Use .uat for testing (default) or .prod for production.  
**MerchantCallbackResponse**: An instance that sends callback messages to the merchant IOS app. This value remains constant.

<Callout icon="fa-info-circle" theme="info">
    <strong>Note:</strong> You can use a single build and change the environment variable to run the SDK in either <code>UAT</code> or <code>Production</code>. Currently, only two modes are supported: <code>.uat</code> for UAT and <code>.prod</code> for Production.
  </Callout>

<DocImage src="images/image-1779282999928.png" alt="two modes" sizing="70%"/>


<h2 id="handle-payment-callbacks"> 4. Handle Payment Callbacks</h2>

You need to implement call-back methods to handle your payment responses. This will provide the payment status and reason for transaction failures. Based on the reasons for failures, handling can be built at your end. Transaction callbacks can be listened to via overriding methods of EdgeResponseCallback.

### 4.1. Android
### Callback Methods

- **onSuccess()** : Triggered when the transaction is successfully completed
- **onError()** : Triggered when an error occurs (network, API failures, etc.)
- **onCancel()** : Triggered when the user cancels the transaction

### 4.2. iOS
### Callback Methods

- **onSuccessResponse** : Triggered when the transaction is successfully completed
- **onFailureResponse** : Triggered when an error occurs (network, API failures, etc.)
- **onCancelTxn** : Triggered when the user cancels the transaction
- **onPressedBackButton** : Triggered when the user presses the back button

### Implementation Code Samples

```swift iOS
public class MerchantCallbackResponse: UIViewController, ResponseCallback {

    public func onFailureResponse(orderID: String, status: String, code: String, message: String) {
        print("Test app response: error occurred")
    }

    public func onSuccessResponse(orderId: String, status: String) {
        print("Test app response: transaction response")
    }

    public func onCancelTxn(orderId: String, code: Int, message: String) {
        print("Test app response: transaction cancelled")
    }

    public func onPressedBackButton(code: Int, message: String) {
        print("Test app response: back pressed")
    }
}
```

<h2 id="manage-transactions">5. Manage Transactions </h2>

Track and verify transaction status using Pine Labs APIs. To retrieve the latest status, use the Fetch APIs or subscribe to webhooks for real-time transaction updates.


<div className="not-prose card-grid-2">
  <div className="card-grid-item">
    <h3>Get Order by Order ID</h3>
    <p>Fetch real-time transaction status by order ID.</p>
    <a href="../api/orders/get-order-by-id">Learn More →</a>
  </div>
  <div className="card-grid-item">
    <h3> Webhooks </h3>
    <p>Configure webhook events for automatic transaction updates.</p>
    <a href="../developer-tools/webhooks">Learn More →</a>
  </div>
</div>

