> For the complete documentation index, see [llms.txt](https://docs.foloosi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.foloosi.com/mobile-sdk-integrations/ios-sdk-1/make-payment.md).

# Make Payment

This Section briefs about how to initiate a payment !

Foloosi's React Native SDK provides easy payment collections.

You can use it on the front-end to open payment page or use the actual flow to create Payment Token

### Step - 1 - Install dependency with npm package <a href="#markdown-header-step-1-install-dependency-with-npm-package" id="markdown-header-step-1-install-dependency-with-npm-package"></a>

`$ npm install react-native-foloosi --save`

### Step - 2 - Usage <a href="#markdown-header-step-2-usuage" id="markdown-header-step-2-usuage"></a>

{% code lineNumbers="true" %}

```javascript
import Foloosi from 'react-native-foloosi';

var initData = {
  merchantKey: 'YOUR_KEY', // public key
  customColor: '#AB34FD', // make payment page loading color as app color. // optional
};

Foloosi.initSDK(JSON.stringify(initData))
```

{% endcode %}

### a. Make Payment with order object

You need to give the order id, title, description, currency code, order amount and customer details like name, email and mobile number.

{% code lineNumbers="true" %}

```javascript
// Customer field is optional.
var orderData = {
  orderAmount: 1.0, // in double format ##,###.##
  orderId: 'orderId', // unique order id
  orderDescription: 'order description', // any description. // optional
  currencyCode: 'AED',
  customerUniqueReference: 'customer reference id', // optional
  country: 'ARE', // mandatory for ios
  postalCode: '000000', //optional
  state: 'Dubai', //optional
  customer: {
    name: 'Test',
    email: 'email@gmail.com',
    mobile: '9876543210',
    address: 'Test Adddddress', // optional
    city: 'Test City', // optional
  },
};
```

{% endcode %}

&#x20;Use the line of code below to make payment with the order data&#x20;

{% code lineNumbers="true" %}

```javascript
Foloosi.makePayment(JSON.stringify(orderData), (response) => {
  let { success, message, transaction_id } = JSON.parse(response);
  //success - type boolean
  //message - type string
  //transaction_id - type string if success is true otherwise it's null
});
```

{% endcode %}

### &#x20;b. Make Payment with reference token

#### Initialize api <a href="#initialize-api" id="initialize-api"></a>

## Get Reference Token

<mark style="color:green;">`POST`</mark> `https://api.foloosi.com/aggregatorapi/web/initialize-setup`

#### Headers

| Name                                          | Type   | Description                              |
| --------------------------------------------- | ------ | ---------------------------------------- |
| secret\_key<mark style="color:red;">\*</mark> | String | Your Merchant Key get from Foloosi Panel |

#### Request Body

| Name                                                  | Type   | Description                    |
| ----------------------------------------------------- | ------ | ------------------------------ |
| transaction\_amount<mark style="color:red;">\*</mark> | Double |                                |
| currency<mark style="color:red;">\*</mark>            | String |                                |
| customer\_unique\_identifier                          | String |                                |
| customer\_mobile                                      | String |                                |
| customer\_email                                       | String |                                |
| customer\_name                                        | String |                                |
| customer\_city                                        | String |                                |
| customer\_address                                     | String |                                |
| billing\_state                                        | String |                                |
| billing\_country                                      | String |                                |
| billing\_postal\_code                                 | String |                                |
| description                                           | String | Product or order information   |
| optional1                                             | String | You can pass additional fields |
| optional2                                             | String | You can pass additional fields |
| optional3                                             | String | You can pass additional fields |

{% tabs %}
{% tab title="200: OK success response" %}

```javascript
{
 "message": "Application setup successfully",
 "data": {
   "reference_token":
   "U0sjdGVzdF8kMnkkMTAkM21LRi0xZGliVDhldTV4NHlZSm9tZXZobnZxWTNEVnZmay1MdHNndTNFenNBTDU0clhWYkccVE4jRkxTQVBJNWM3Njk2ZDkwOWIzNxxSVCMkMnkkMTAkQXZ4ay9wdjlpTFlYLzRSZ2FjSkxpZWhHb2o0U0wvTFpZNXAyVjRGOVFycWNQZ2lHQ3VEZ08="
  }
 }
```

{% endtab %}

{% tab title="401: Unauthorized Invalid Api mode" %}

```javascript
{
    "message": "Invalid Integration settings! Kindly check both foloosi merchant application settings and your integration keys"
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid Header response" %}

```javascript
{
    "message": "Invalid secret key"
}
```

{% endtab %}

{% tab title="404: Not Found Invalid request type" %}

```javascript
{
    "message": "No routes found"
}
```

{% endtab %}
{% endtabs %}

Use the line of code below to make payment with the  reference token

{% code lineNumbers="true" %}

```javascript
Foloosi.makePaymentWithReferenceToken('REFERENCE_TOKEN', (response) => {
  let { success, message, transaction_id } = JSON.parse(response);
  //success - type boolean
  //message - type string
  //transaction_id - type string if success is true otherwise it's null
});
```

{% endcode %}

#### Api Specification <a href="#api-specification" id="api-specification"></a>

* Request call must be on **POST.**
* This Api will be used to confirm the feature you are about to Use.
* For **Saved Card Payment** Method, You need to pass your customer unique details like email,etc. to **customer\_unique\_identifier**.

**Post Request Body**

​

| Name                         | Description                                                                                                                                  |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| customer\_unique\_identifier | <ol><li>This is mandatory when you are using saved card payment.</li><li>This data must be Unique like email id,customer id, etc.,</li></ol> |

### Support

Visit <https://www.foloosi.com> for support requests or email to <tech@foloosi.com>.

## Developed by

Foloosi Technologies Pvt Ltd.

## License

Copyrights (c) 2025 Foloosi

#### &#x20;<a href="#api-specification" id="api-specification"></a>
