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
  • 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:
    git:
      url: https://github.com/amwal-pay/amwal_pay_sdk
      ref: main

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
    isSoftPOS: false, // Enable NFC if needed
    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)
isSoftPOS Whether SoftPOS is enabled for the transaction
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! 🎉

Libraries

amwal_pay_sdk
amwal_pay_sdk_flutter
amwal_sdk_settings/amwal_sdk_setting_container
amwal_sdk_settings/amwal_sdk_settings
core/apiview/api_view
core/apiview/state_mapper
core/base_repository/base_repository
core/base_response/base_response
core/base_state/base_cubit_state
core/base_view_cubit/base_cubit
core/loader_mixin
core/merchant_store/merchant_store
core/networking/constants
core/networking/custom_log_interceptor
core/networking/dio_client
core/networking/EncryptionUtil
core/networking/mockup_interceptor
core/networking/network_service
core/networking/network_state
core/networking/secure_hash_interceptor
core/networking/token_interceptor
core/resources/assets/app_assets_paths
core/resources/color/colors
core/tablayout/tab_layout_cubit
core/tablayout/tab_layout_generic_widget
core/tooltip_widget
core/ui/accepted_payment_methods_widget
core/ui/alert_dialog/alert_dialog
core/ui/amountcurrencywidget/amount_currency_widget
core/ui/amountcurrencywidget/amount_currency_widget_cubit
core/ui/amountcurrencywidget/decimal_text_input_formatter
core/ui/app_dialog
core/ui/buttons/app_button
core/ui/buttons/app_main_button
core/ui/cardinfoform/card_form_inputs_formatter
core/ui/cardinfoform/card_info_form_widget
core/ui/cardinfoform/card_type
core/ui/cardinfoform/card_utils
core/ui/count_down_dialog/count_down_dialog
core/ui/directional_widget/directional_widget
core/ui/error_dialog
core/ui/inputfields/date_picker_field
core/ui/inputfields/input_field_widget
core/ui/inputfields/phone_input_field
core/ui/listpicker/bottom_select_list
core/ui/loading_dialog
core/ui/sale_card_feature_common_widgets
core/ui/transactiondialog/transaction
core/ui/transactiondialog/transaction_detail_widget
core/ui/transactiondialog/transaction_details_settings
core/ui/transactiondialog/transaction_dialog_action_buttons
core/ui/transactiondialog/transaction_status_dialog
core/usecase/i_use_case
features/card/amwal_salebycard_sdk
features/card/cubit/sale_by_card_contact_less_cubit
features/card/cubit/sale_by_card_manual_cubit
features/card/data/models/request/customer_token_request
features/card/data/models/request/purchase_request
features/card/data/models/response/CardInfo
features/card/data/models/response/customer_token_response
features/card/data/models/response/purchase_response
features/card/data/repository/sale_by_card_repository
features/card/dependency/injector
features/card/domain/repository/sale_by_card_repo
features/card/domain/sale_by_card_constants
features/card/domain/use_case/get_customer_token_use_case
features/card/domain/use_case/pay_with_token_use_case
features/card/domain/use_case/purchase_otp_step_one_use_case
features/card/domain/use_case/purchase_otp_step_two_use_case
features/card/domain/use_case/purchase_use_case
features/card/module/sale_by_card_module
features/card/presentation/app
features/card/presentation/sale_by_card_contact_less_screen
features/card/presentation/sale_by_card_manual_screen
features/card/presentation/sale_by_card_screen
features/card/presentation/thrree_ds_web_view_page
features/card/presentation/widgets/otp_dialog
features/card/presentation/widgets/select_card_bottom_sheet
features/card/state/sale_by_wallet_state
features/card/transaction_manager/amwal_card_transaction_manager
features/card/transaction_manager/i_card_transaction_manager
features/card/transaction_manager/in_app_card_transaction_manager
features/currency_field/cubit/currency_cubit
features/currency_field/data/models/request/currency_request
features/currency_field/data/models/response/currency_response
features/currency_field/data/repository/currency_repository
features/currency_field/domain/currency_constants
features/currency_field/domain/repository/currency_repository
features/currency_field/domain/use_case/currency_use_case
features/currency_field/module/currency_binds
features/currency_field/presentation/currency_field
features/payment_argument
features/receipt/receipt_handler
features/transaction/data/models/request/transaction_operation_request
features/transaction/data/models/response/merchant_name_response
features/transaction/data/models/response/one_transaction_response
features/transaction/data/models/response/transaction_operation_response
features/transaction/data/repository/transaction_repository_impl
features/transaction/domain/repository/transaction_repository
features/transaction/domain/use_case/get_transaction_by_Id
features/transaction/module/transaction_module
features/transaction/util
features/wallet/amwal_salebywallet_sdk
features/wallet/cubit/sale_by_qr_cubit
features/wallet/cubit/sale_by_wallet_cubit
features/wallet/cubit/sale_by_wallet_pay_cubit
features/wallet/cubit/sale_by_wallet_verify_cubit
features/wallet/data/models/request/dynamic_qr_request
features/wallet/data/models/request/payment_request
features/wallet/data/models/request/sale_by_wallet_request
features/wallet/data/models/request/verification_request
features/wallet/data/models/response/qr_response
features/wallet/data/models/response/sale_by_wallet_response
features/wallet/data/models/response/verify_customer_response
features/wallet/data/models/response/wallet_pay_response
features/wallet/data/repository/sale_by_wallet_repo_imp
features/wallet/data/sale_by_wallet_constant
features/wallet/dependency/injector
features/wallet/domain/sale_by_wallet_repository
features/wallet/domain/use_case/pay_with_alias_use_case
features/wallet/domain/use_case/pay_with_mobile_use_case
features/wallet/domain/use_case/pay_with_qr_use_case
features/wallet/domain/use_case/verify_customer_use_case
features/wallet/module/sale_by_wallet_module
features/wallet/presentation/app
features/wallet/presentation/screen/sale_by_wallet_paying_options
features/wallet/presentation/screen/sale_by_wallet_screen
features/wallet/presentation/widgets/alias_pay_widget
features/wallet/presentation/widgets/phone_pay_widget
features/wallet/presentation/widgets/sale_action_buttons
features/wallet/presentation/widgets/sale_by_wallet_mixins/sale_by_wallet_action_mixin
features/wallet/presentation/widgets/sale_by_wallet_mixins/sale_by_wallet_pay_mixin
features/wallet/presentation/widgets/sale_by_wallet_mixins/sale_by_wallet_verify_mixin
features/wallet/presentation/widgets/scan_qr_to_pay
features/wallet/state/sale_by_wallet_state
localization/app_localizations
localization/app_localizations_delegate
localization/app_localizations_setup
localization/locale_utils
navigator/sdk_navigator
presentation/amwal_pay_screen
presentation/color/colors
presentation/sdk_arguments
sdk_builder/network_service_builder
sdk_builder/sdk_builder
service/nfc_manager