amwal_pay_sdk 1.0.100 copy "amwal_pay_sdk: ^1.0.100" to clipboard
amwal_pay_sdk: ^1.0.100 copied to clipboard

A Flutter SDK for integrating Amwal Pay payment solutions into your mobile apps, providing secure, seamless, and customizable payment experiences.

Amwal Pay SDK #

The Amwal Pay SDK is a Flutter-based SDK designed to simplify online payments. It supports multiple payment methods, including wallet-based payments (via mobile number, alias, QR code, or NFC) and card payments. This SDK is highly customizable and easy to integrate into your Flutter applications.


Features #

  • Payment With Wallet
    • With mobile number
    • With alias name
    • With QRCode
    • With SoftPOS
  • Payment With Card
    • Credit/Debit Cards
    • Google Pay
  • Environment Support
    • SIT (System Integration Testing)
    • UAT (User Acceptance Testing)
    • PROD (Production)

Screenshots #

Example Screenshot View Screenshot


Installation #

Add the Amwal Pay SDK to your pubspec.yaml file:

dependencies:
  amwal_pay_sdk: ^1.0.81

Then, run flutter pub get to install the package.


Usage #

1. Import the Package #

Import the package in your Dart file:

import 'package:amwal_pay_sdk/amwal_pay_sdk.dart';

2. Fetch the Customer ID and Session Token #

To initialize the payment process, you need to fetch the customerId and then retrieve the session token from your backend. Here's how you can do it:

final customerId = await _getCustomerId(); // Fetch the customer ID

final sessionToken = await getSDKSessionToken( // Fetch the session token from the backend
  merchantId: _merchantId,
  customerId: customerId,
);

if (sessionToken == null) return;

3. Initialize the SDK #

Use the AmwalPaySdk.instance.initSdk method to initialize the SDK with the required settings:

await AmwalPaySdk.instance.initSdk(
  settings: AmwalSdkSettings(
    environment: Environment.UAT, // Specify the environment (SIT, UAT, or PROD)
    sessionToken: sessionToken ?? '', // Session token from backend
    currency: 'OMR', // Currency (e.g., OMR)
    amount: '100', // Amount (e.g., 100)
    transactionId: const Uuid().v1(), // Unique transaction ID
    merchantId: 'YOUR_MERCHANT_ID', // Your merchant ID
    terminalId: 'YOUR_TERMINAL_ID', // Your terminal ID
    locale: Locale('en'), // Locale for the payment (e.g., "en")
    isMocked: false, // Disable mocked data
    transactionType: TransactionType.cardWallet, // Specify the transaction type
    customerCallback: _onCustomerId, // Callback for customer ID
    customerId: customerId, // The customer ID for this transaction
    onResponse: _onResponse, // Callback for the payment response
  ),
);

Example #

You can find a complete example of how to use the Amwal Pay SDK in the Example Directory.


Parameters #

AmwalSdkSettings Parameters #

Parameter Description
environment The environment for the SDK (Environment.SIT, Environment.UAT, or Environment.PROD)
sessionToken The session token obtained from your backend
currency Name of the currency that the client will pay with
amount The amount of payment
transactionId Unique identifier for the transaction
merchantId Your Merchant Id
terminalId Your terminalId
locale The locale for the payment process (e.g., "en" or "ar")
isMocked Whether to use mocked data (for testing)
transactionType The type of transaction (TransactionType.nfc or TransactionType.cardWallet)
customerCallback The callback function for customer id after finish
customerId The customer ID for this transaction
onResponse The callback function to handle the payment response

Callbacks #

customerCallback #

This callback is triggered after the payment process is completed. It provides the customerId as a parameter:

void _onCustomerId(String customerId) {
  print('Customer ID: $customerId');
}

onResponse #

This callback is triggered when the payment response is received. It provides the payment response as a parameter:

void _onResponse(dynamic response) {
  print('Payment Response: $response');
}

Environment Configuration #

The environment parameter allows you to specify the environment for the SDK:

  • Environment.SIT: System Integration Testing
  • Environment.UAT: User Acceptance Testing
  • Environment.PROD: Production

Example:

environment: Environment.UAT, // Use UAT for testing

Issues #

If you encounter any issues while using the SDK, please file a bug report in the Github Issue Tracker.


Contributing #

We welcome contributions! Please read the Contributing Guidelines before submitting a pull request.


License #

This project is licensed under the MIT License. See the LICENSE file for details.


Free Software, Hell Yeah! 🎉