---
agentTools:
  projectIndex: https://aamarpay.readme.io/llms.txt
---

# Flutter Package

aamarPay Payment Module Integration Guide for Flutter

This guide provides step-by-step instructions for integrate the aamarPay payment module for Mobile App in flutter. The aamarPay module allows you to integrate aamarPay payment gateway into your mobile app.

# Requirements

* Android: minSdkVersion 19

# How to Use

* In the dependencies section of your "pubspec.yaml" add the following line:

```yaml
dependencies:  
     aamarpay: ^1.0.10
```

* install packages from the command line:

```shell
flutter pub get
```

# Important Notes

* Read the comments in the example code.
* The transactionID must be unique for every payment.
* There is a test signature key. But when you go to the production you must use your own signature key.

> 🚧 Sandbox Environment
>
> All operations conducted in this environment are considered as trial transaction.
>
> #### <b>Store ID :</b> aamarpaytest
>
> #### <b>Signature Key :</b> dbb74894e82415a2f7ff0ec3a97e4183

> ℹ️ Obtain Live Credentials
>
> For acquiring the necessary live credentials to process payments, please don't hesitate to contact our Support Team at <support@aamarpay.com.> They are readily available to guide you throughout the procedure and provide the essential credentials to facilitate live payment transactions on your platform.

* It is better to practice with the example code first.

```cplusplus Flutter
import 'package:flutter/material.dart';
import 'package:aamarpay/aamarpay.dart';

void main() {
  runApp(MaterialApp(
    home: MyPay(),
  ));
}

class MyPay extends StatefulWidget {
  @override
  _MyPayState createState() => _MyPayState();
}

class _MyPayState extends State<MyPay> {
  bool isLoading = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Aamarpay(
          // This will return a payment url based on failUrl,cancelUrl,successUrl
          returnUrl: (String url) {
            print(url);
          },
          // This will return the payment loading status
          isLoading: (bool loading) {
            setState(() {
              isLoading = loading;
            });
          },
          // This will return the payment event with a message
          status: (EventState event, String message) {
            if (event == EventState.error) {
              setState(() {
                isLoading = false;
              });
            }
          },
          // When you use your own url, you must have the keywords:cancel,confirm,fail otherwise the callback function will not work properly
          cancelUrl: "example.com/payment/cancel",
          successUrl: "example.com/payment/confirm",
          failUrl: "example.com/payment/fail",
          customerEmail: "masumbillahsanjid@gmail.com",
          customerMobile: "01834760591",
          customerName: "Masum Billah Sanjid",
          // That is the test signature key. But when you go to the production you must use your own signature key
          signature: "dbb74894e82415a2f7ff0ec3a97e4183",
           // That is the test storeID. But when you go to the production you must use your own storeID 
          storeID: "aamarpaytest", 
          // Use transactionAmountFromTextField when you pass amount with TextEditingController
          // transactionAmountFromTextField: amountTextEditingController,
          transactionAmount: "200",
          //The transactionID must be unique for every payment
          transactionID: "${DateTime.now().millisecondsSinceEpoch}",
          //The transactionID must be unique for every payment 
          transactionID: "transactionID",
          description: "test",
          // When the application goes to the producation the isSandbox must be false
          isSandBox: true,
          child: isLoading
              ? Center(
                  child: CircularProgressIndicator(),
                )
              : Container(
                  color: Colors.orange,
                  height: 50,
                  child: Center(
                    child: Text(
                      "Payment",
                      style: TextStyle(
                          fontWeight: FontWeight.bold, color: Colors.white),
                    ),
                  ),
                ),
        ),
      ),
    );
  }
}
```

* You can find detailed information about the package "aamarpay" on [pub.dev](https://pub.dev/packages/aamarpay#importance-notes)

> 👍
>
> **Congratulations!** You have successfully integrate the aamarPay payment module for your mobile app using flutter. Your customers can now make payments using the aamarPay payment gateway.

> 📘
>
> Please ensure that you have completed the necessary steps to enable aamarPay on your aamarPay account and obtained the required **Store ID** and **Signature key** before switching to **live mode**.

If you encounter any issues during the installation or configuration process, please reach out to [integration support team](mailto:integration@aamarpay.com) for assistance.