1. Frontend Bas Payment SDK
BasGate Document v2
  • BAS SDK Payment
    • Payment Flow
    • Payment Api backend
      • Introduction
      • Authentication
      • Initiate Transaction
      • Check Transaction Status
    • Frontend Bas Payment SDK
      • Flutter SDK
      • Android SDK
      • IOS SDK
    • Signature
      • Signature (Checksum) Documentation
    • Tools
      • Laravel Payment Gateway SDK
  1. Frontend Bas Payment SDK

Flutter SDK

Bas flutter SDK#

A Flutter plugin that integrates the Bas Pay native payment experience (Android / iOS) into your Flutter app using a simple Dart API.

Table of Contents#

1.
Overview
2.
Features
3.
Requirements
4.
Installation
5.
Quick Start
6.
InitBasSdkModel Reference
7.
Environments (prod vs dev)
8.
Calling the Payment Flow
9.
Handling Results (ResultModel)
10.
Platform Setup (Android / iOS / Web / Windows)
11.
Internationalization (language)
12.
Error Handling & Troubleshooting
13.
Security Considerations
14.
FAQ
15.
Versioning & Changelog
16.
Contributing
17.
License
18.
Support / Contact

See ٍSource Code in github.#

1. Overview#

bas_pay_flutter exposes a single high‑level method BasPayFlutter().callBasPay(...) that launches the native Bas Pay UI and returns structured result data. You supply a transaction token (trxToken) plus optional user info and preferences; the plugin handles bridging data to Android/iOS and parsing results back into Dart.

2. Features#

Simple one-call payment initiation
Environment selection (prod / dev) via dedicated constructors
Optional user metadata (identifier, full name, product)
Language override (e.g. ar, en) with fallback
Strongly typed result wrapper (ResultModel) with flexible parsing of varied backend field types
Supports Android (Jetpack Compose + AAR), iOS (vendored xcframework), Web (stub), Windows (stub)

3. Requirements#

PlatformMinimumNotes
Dart SDK^3.7.2 (as in pubspec.yaml)Align with your Flutter SDK constraints
Flutter>=3.3.0Tested up to latest stable (update when validated)
AndroidminSdk 24 / compileSdk 36Kotlin 2.1.0, Gradle plugin 8.7.0
iOSiOS 13.0+xcframework auto-fetched in pod install
WindowsSupported plugin targetBasic stub, payment flow may not be implemented
WebSupported plugin targetBasic stub, payment flow may not be implemented
If you target earlier Android/iOS versions you must raise them to meet Bas Pay SDK requirements.

4. Installation#

Add to your pubspec.yaml:
Then run:
Import where needed:

5. Quick Start#

6. InitBasSdkModel Reference#

Two constructors define the environment implicitly:
InitBasSdkModel.prod(...) => environment = "prod"
InitBasSdkModel.dev(...) => environment = "dev"
FieldTypeRequiredDefaultSourceDescription
trxTokenStringYesN/AYou / backendUnique transaction token provided by your server / Bas Pay API
userIdentifierString?NonullYouE.g. phone number or user id for tracking / personalization
fullNameString?NonullYouDisplay / identification purposes
languageString?NoFallback to ar (SDK)YouUI language override (currently supports ar, en)
platformStringInternal"Flutter"PluginSet automatically, do not modify
productString?NonullYouOptional product / channel identifier
environmentString?Internal"prod" or "dev"ConstructorSet automatically based on constructor used
If language is omitted the underlying SDK defaults to Arabic (ar). Confirm behavior with latest backend if multi-language expansion occurs.

7. Environments (prod vs dev)#

Use .prod during production & .dev for testing against Bas Pay's development endpoints. Never mix tokens across environments. Keep dev tokens out of production builds.

8. Calling the Payment Flow#

1.
Construct InitBasSdkModel with proper environment.
2.
Call BasPayFlutter().callBasPay(model: ...).
3.
Await the returned tuple: ({bool resultStatus, ResultModel? resultModel}).
resultStatus indicates the MethodChannel invocation & native flow returned something parseable.
resultModel (may be null if parse failed) holds business outcome.
4.
Inspect resultModel.status to determine payment success.

9. Handling Results (ResultModel)#

ResultModel wraps dynamic response content and normalizes common field types (bool/string/int/double). It exposes:
status (bool): Success indicator; gracefully parses bool, string, int (1), double (1.0). Missing -> false.
message (String): Human-readable summary. Missing -> empty string.
result (dynamic): Raw payload / data structure (map, list, value) from Bas Pay backend. Missing -> null.
code (int): Business/HTTP-like status code; missing or unparseable -> internal fallback 699.
Example pattern:
Custom codes and result schema may evolve. Add shape guards or adapters in your app for resilience.

10. Platform Setup#

Android#

BasActivity is declared in the plugin manifest; you do not need to add it manually.
minSdk 24 required.
Ensure Internet access (add <uses-permission android:name="android.permission.INTERNET"/> in your app manifest if not already present).
If push notifications or other capabilities become necessary, update docs (TODO: confirm exact requirements if Banky Lite notifications rely on additional services).

iOS#

iOS 13.0 minimum.
The xcframework (bas_pay.xcframework) is downloaded automatically during pod install via the podspec prepare_command.
Run cd ios && pod install after first plugin add or when updating.
Ensure you have use_frameworks! only if required elsewhere (not strictly needed here).
If notifications/push tokens are required in future, include appropriate entitlement & user permission flow (TODO: confirm).

Windows & Web#

Stubs exist so your multi-platform project compiles. Payment flow may be unsupported (returns errors or unimplemented). Guard usage by platform check:

11. Internationalization (language)#

Pass language: 'en' for English; omit or pass 'ar' for Arabic (default). Unsupported/unknown values may fallback to Arabic. Validate user preference before sending.

12. Error Handling & Troubleshooting#

ScenarioSymptomAction
Missing / invalid trxTokenNative screen fails / backend rejectsEnsure backend generated valid token before calling
resultStatus == falseTransport / channel failureRetry once; log full arguments; verify platform compatibility
resultModel == nullParse exceptionLog raw string from channel; check backend response shape
status == false with meaningful messageBusiness/payment failureShow message to user; allow retry
iOS root VC errorFlutterError: Could not get rootViewControllerEnsure app has visible window & not during early startup
Activity theming issues (Android)UI style unexpectedOverride theme if BasActivity requires specific attributes (TODO)
Enable verbose logging around the call when diagnosing issues.

13. Security Considerations#

Never hardcode production trxToken values; always request them from a secure backend per transaction.
Treat tokens as short-lived; revoke / expire server-side when consumed.
Avoid logging full tokens in production; mask except last 4–6 chars.
Use HTTPS everywhere between your app & backend issuing the token.

14. FAQ#

Q: Can I reuse the same trxToken?
A: Typically no; each payment intent should have a unique token. Confirm with Bas Pay docs.
Q: How do I switch to sandbox?
A: Use InitBasSdkModel.dev(...) and supply a dev environment token.
Q: What languages are supported?
A: Currently Arabic (ar) and English (en). Others fallback to Arabic.
Q: What if I need to cancel mid-flow?
A: User can dismiss provided native UI; handle returned failure/status accordingly.

15. Versioning & Changelog#

Versioning follows semantic intent. See CHANGELOG.md for release notes. Update the dependency to the latest published version and review changes before deployment.

16. Contributing#

1.
Fork the repository.
2.
Create a feature branch: git checkout -b feature/my-improvement.
3.
Add tests / example updates where relevant.
4.
Run static analysis & format code: dart analyze / dart format ..
5.
Submit a pull request describing changes & rationale.
Please open issues for bugs, enhancement ideas, or questions.

17. License#

Distributed under the terms of the project License (see LICENSE).

18. Support / Contact#

For support or integration questions reach out:
Email: (placeholder) support@example.com
Maintainer email (from podspec): osama.mtm77@gmail.com
Replace placeholder contact with official support channel before publishing.

Roadmap / TODOs#

Confirm additional Android permissions (if any) beyond INTERNET.
Validate push/notification requirements for iOS (BankyLiteNotificationManager registration currently invoked).
Document result payload schema examples once finalized.
Expand Web/Windows implementation or clarify unsupported status.

Example Logging Pattern#


If you discover inaccuracies or need clarifications please open an issue so we can refine this documentation.
Modified at 2026-07-01 20:59:29
Previous
Check Transaction Status
Next
Android SDK
Built with