> 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/flutter/make-payment.md).

# Make Payment

### Step 1 - Initiate SDK

```dart
var initData = {
          "merchantKey": "Your Merchant Key",
          "customColor": "#1E8449",
        };
   await FoloosiPlugins.init(json.encode(initData));
```

### sample escape string

```
merchantKey: 'key_\$2\$1\$1xxxxxxxxxxxxxxxxxxxxx'
```

**Important Note** - You can Follow any one of the methods below to initiate payment widget

### a. Make Payment with order object

#### &#x20;Create Order Data Object with necessary inputs

You can create the order data or payment input with our OrderData Model class. Here you need to provide order id, title, description, currency code, order amount and customer details like name, email and mobile number.

```dart
var orderData = {
          "orderId": "521",
          "orderDescription": "Order Description",
          "orderAmount": double.parse(amountTextField.text),
          "state": "",
          "postalCode": "",
          "country": "ARE",
          "currencyCode": "AED",
          "customerUniqueReference": "",
          "customer": {
            "name": "Foloosi Test",
            "email": "example@foloosi.com",
            "mobile": "501234567",
            "code": "",
            "address": "",
            "city": "",
          },
        };
var result = await FoloosiPlugins.makePayment(json.encode(orderData));
if (kDebugMode) {
          print("Payment Response: $result");
}
```

#### \*Important Note\*

orderData.customerUniqueReference = "Unique value"

// Unique value must be customer id/email/mobile number for saved card feature.&#x20;

Now make payment with order data you created above.

### &#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                               |
| ----------------------------------------------------- | ----------------- | ----------------------------------------- |
| source<mark style="color:red;">\*</mark>              | String (ios\_sdk) | For apple pay "ios\_sdk" should be passed |
| transaction\_amount<mark style="color:red;">\*</mark> | Double            |                                           |
| currency<mark style="color:red;">\*</mark>            | String            |                                           |
| customer\_mobile<mark style="color:red;">\*</mark>    | String            |                                           |
| customer\_email<mark style="color:red;">\*</mark>     | String            |                                           |
| customer\_name<mark style="color:red;">\*</mark>      | String            |                                           |
| customer\_city                                        | String            |                                           |
| customer\_address                                     | String            |                                           |
| billing\_state                                        | String            |                                           |
| billing\_country                                      | String            |                                           |
| billing\_postal\_code                                 | String            |                                           |
| customer\_unique\_identifier                          | 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 %}

```javascript
var referenceToken = "YOUR REFERENCE TOKEN";
var result = await FoloosiPlugins.makePaymentWithReferenceToken(referenceToken);
if (kDebugMode) {
          print("Payment Response: $result");
}
```

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

* Request call must be in **POST.**
* With this api only your going to confirm which feature you are using.
* For **Saved Card Payment** Method, You need to pass your customer unique details like email,etc., in **customer\_unique\_identifier**.

**Post Request Body**

​

| Name                         | Description                                                                                                                         |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| customer\_unique\_identifier | <ol><li>It is mandatory when you are using saved card payment.</li><li>It 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
