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

Android SDK

Bas Pay SDK — Native Android / Kotlin Integration Guide#

This document explains how to integrate bas_pay-release.aar and BankySDKManager-release.aar into a native Android (Kotlin) project — without Flutter.

Table of Contents#

Overview
Architecture
Requirements
Installation
Step 1: Copy AAR Files
Step 2: Configure build.gradle (Project)
Step 3: Configure build.gradle (Module / app)
Step 4: Configure AndroidManifest.xml
Usage
Method A: BasPay.start() — Activity Result Pattern (Recommended)
Method B: Jetpack Compose — basSdk() Composable
Parameters Reference
Response Handling
Response JSON Structure
Response Fields
ResultModel Helper (Optional)
Environment Configuration
Error Handling
Full Example — Complete Activity
Full Example — Jetpack Compose
Troubleshooting
Files Checklist

Overview#

Bas Pay SDK provides a payment experience for Android applications. It consists of two AAR libraries:
FileDescription
bas_pay-release.aarCore SDK — Contains BasPay class and basSdk Composable for initiating and handling payments
BankySDKManager-release.aarSupporting SDK — Banky banking infrastructure dependency required by the core SDK

Architecture#

┌─────────────────────────────────────┐
│          Your Kotlin App            │
│                                     │
│   BasPay.start(activity, params)    │
│         or basSdk(params)           │
└──────────────┬──────────────────────┘
               │
               ▼
┌──────────────────────────────────────┐
│        bas_pay-release.aar           │
│  ┌──────────────────────────────┐    │
│  │  BasPay (Entry Point)        │    │
│  │  • start()                   │    │
│  │  • getResult()               │    │
│  │  • DEFAULT_REQUEST_CODE      │    │
│  ├──────────────────────────────┤    │
│  │  basSdk() Composable         │    │
│  │  (Jetpack Compose UI)        │    │
│  └──────────────────────────────┘    │
└──────────────┬───────────────────────┘
               │
               ▼
┌──────────────────────────────────────┐
│   BankySDKManager-release.aar        │
│   (Banking infrastructure layer)     │
└──────────────────────────────────────┘

Requirements#

RequirementMinimum Version
Android minSdk24 (Android 7.0)
Android compileSdk36
Kotlin2.1.0
Java Compatibility11
Jetpack ComposeRequired (for Compose method)
AGP (Android Gradle Plugin)8.7.0+

Installation#

Step 1: Copy AAR Files#

Create a libs directory inside your app module and copy both AAR files:
your-project/
├── app/
│   ├── libs/
│   │   ├── bas_pay-release.aar
│   │   └── BankySDKManager-release.aar
│   ├── src/
│   └── build.gradle.kts
├── build.gradle.kts
└── settings.gradle.kts

Step 2: Configure build.gradle (Project)#

Add flatDir to your project-level repositories so Gradle can find local AAR files:
Note (Kotlin DSL):

Step 3: Configure build.gradle (Module / app)#

Step 4: Configure AndroidManifest.xml#

If using the Compose method with a dedicated Activity, register it:
<!-- AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application>

        <!-- Your main activity -->
        <activity android:name=".MainActivity" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Bas Pay Compose Activity (if using Compose method) -->
        <activity
            android:name=".BasPayActivity"
            android:exported="false"
            android:theme="@android:style/Theme.NoTitleBar" />

    </application>
</manifest>
Important: The Theme.NoTitleBar theme is recommended for a clean payment UI experience.

Usage#

There are two methods to integrate Bas Pay:

Method A: BasPay.start() — Activity Result Pattern (Recommended)#

This is the simplest approach. It launches the payment screen as an Activity and returns the result via onActivityResult.

Method B: Jetpack Compose — basSdk() Composable#

Use this method if your app is built with Jetpack Compose. The basSdk() composable renders the full payment UI.
Launching the Compose Activity from another screen:

Parameters Reference#

ParameterTypeRequiredDefaultDescription
trxTokenString✅ Yes—The transaction token obtained from your backend. This is the unique identifier for the payment session.
userIdentifierString?❌ NonullUser identifier (e.g., phone number like "733733733")
fullNameString?❌ NonullFull name of the paying user
languageString?❌ No"ar"UI language: "ar" (Arabic) or "en" (English)
platformString?❌ No"Native"Platform identifier. Use "Native" for Kotlin apps
productString?❌ NonullProduct name or identifier
environmentString?❌ No"prod"Environment: "prod" for production, "dev" for development/testing
requestCodeInt✅ Yes (Method A)BasPay.DEFAULT_REQUEST_CODERequest code for onActivityResult. Always use BasPay.DEFAULT_REQUEST_CODE
onReturnDataToIOSCallback?—nulliOS only. Always pass null on Android

Response Handling#

Response JSON Structure#

After the payment flow completes, BasPay.getResult(data) returns a JSON string with this structure:
{
  "status": true,
  "message": "Payment completed successfully",
  "result": { ... },
  "code": 200
}

Response Fields#

FieldTypeDescription
statusBooleantrue = payment succeeded, false = payment failed
messageStringHuman-readable status message
resultAny?Additional payment result data (structure varies)
codeIntStatus code. 699 = unknown/default error code

ResultModel Helper (Optional)#

You can create a helper data class to parse the response:
Usage with the helper:

Environment Configuration#

EnvironmentValueUse Case
Production"prod"Live payments with real transactions
Development"dev"Testing and development — no real charges

Error Handling#

Common error scenarios and how to handle them:
ScenarioHow to DetectRecommended Action
User cancelled paymentBasPay.getResult(data) returns nullShow "Payment cancelled" message
Payment failedstatus == false in responseShow error message from message field
Invalid tokenstatus == false, check codeRequest a new token from your backend
Network errorstatus == falseAsk user to retry
Unknown errorcode == 699Log error, show generic error message

Full Example — Complete Activity#


Full Example — Jetpack Compose#


Troubleshooting#

ProblemSolution
ClassNotFoundException for BasPayEnsure bas_pay-release.aar is in the libs/ folder and flatDir is configured
Could not resolve BankySDKManagerEnsure BankySDKManager-release.aar is in libs/ or available via Maven
Duplicate class errorsCheck the exclude rules in the BankySDKManager dependency
Compose compilation errorsEnsure org.jetbrains.kotlin.plugin.compose plugin is applied
minSdk errorsSet minSdk = 24 or higher
onActivityResult not calledEnsure you're using BasPay.DEFAULT_REQUEST_CODE
null result from getResult()User likely cancelled the payment flow

Files Checklist#

Before handing off to the Kotlin developer, ensure they have:
📦 bas_pay-release.aar — Core payment SDK
📦 BankySDKManager-release.aar — Banking infrastructure SDK
📄 This documentation file
🔑 Access to generate trxToken from the backend API

API Quick Reference#


Generated from BasPlatform/BasPaymentFlutter source code analysis.
Modified at 2026-05-12 20:54:59
Previous
Flutter SDK
Next
IOS SDK
Built with