# Cowpay Flutter plugin

## 1. REQUIREMENTS

&#x20;   *Minimum Flutter version 2.5.0*

## 2. INSTALLATION

```dart
dependencies:
  cowpay:
    git:
      url: https://github.com/CowpayPayment/Cowpay-Flutter.git
      ref: latest release version
```

{% hint style="info" %}
You can find the latest version from here:

<https://github.com/CowpayPayment/Cowpay-Flutter/releases>
{% endhint %}

## 3. IMPORT

```dart
import 'package:cowpay/cowpay.dart';
```

## 4. USAGE

Create a widget and just return Cowpay-plugin widget in the build function as:

<pre class="language-dart"><code class="lang-dart"><strong>return Cowpay(
</strong>      localizationCode: LocalizationCode.en,
      amount: amount,
      customerEmail: 'customerEmail',
      customerMobile: 'customerMobile',
      customerLastName: 'customerName',
      customerFirstName: 'customerName',
      isFeesOnCustomer: true,
      logoStringUrl:'logoStringUrl',
      merchantMobile: 'merchantMobile',
      description: 'description',
      customerMerchantProfileId: 'customerMerchantProfileId',
      merchantReferenceId: 'merchantReferenceId',
      activeEnvironment: CowpayEnvironment.staging,
      merchantHashCode: 'merchantHashCode',
      merchantCode: 'merchantCode',
      onSuccess: (val) {
        debugPrint(val.paymentMethodName);
      },
      onError: (val) {
        debugPrint(val.toString());
      },
      onClosedByUser: () {
        debugPrint("closedByUser");
      },
    )
</code></pre>

## 5.  VALUES DESCRIPTION

| Keys                      | Values                                                                                                                                   |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| localizationCode          | Select your language code enum value LocalizationCode.en for English, and LocalizationCode.ar if Arabic.                                 |
| amount                    | two decimal value like "15.60", sent in case of partial capture                                                                          |
| customerEmail             | customer valid email                                                                                                                     |
| customerMobile            | internationally formatted customer mobile <mark style="color:orange;">(Should Start with country code (ex. +20 for Egypt Number))</mark> |
| customerLastName          | customer last name being charged                                                                                                         |
| customerFirstName         | customer first name being charged                                                                                                        |
| isFeesOnCustomer          | is fees on customer or merchant                                                                                                          |
| logoStringUrl             | merchant logo url                                                                                                                        |
| merchantMobile            | merchant mobile                                                                                                                          |
| description               | charge request description that reserve the payment name                                                                                 |
| customerMerchantProfileId | ID of the customer being charged on your system                                                                                          |
| merchantReferenceId       | Unique alphanumeric value required as identifier for the charge request                                                                  |
| activeEnvironment         | CowpayEnvironment.staging \|\| CowpayEnvironment.production                                                                              |
| merchantHashCode          | Hash code that is presented in your panel.                                                                                               |
| merchantCode              | Your code that is presented in your panel.                                                                                               |
| onSuccess                 | Call back function if transaction succeeds.                                                                                              |
| onError                   | Call back function when an error occurres.                                                                                               |
| onClosedByUser            | Call back function if customer goes back before making a transaction.                                                                    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lumin-soft.gitbook.io/cowpay/cowpay-flutter-plugin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
