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

IOS SDK

Bas Pay SDK — Native iOS / Swift Integration Guide#

This document explains how to integrate the bas_pay.xcframework into a native iOS (Swift) project — without Flutter.

Table of Contents#

Overview
Architecture
Requirements
Installation
Method 1: Manual Download (Recommended)
Method 2: CocoaPods
Step: Xcode Project Configuration
Usage
Step 1: Import the SDK
Step 2: Register BankyLite Notifications
Step 3: Create the Payment ViewController
Step 4: Present the Payment Screen
Parameters Reference
Response Handling
Response JSON Structure
Response Fields
Parsing the Response
Environment Configuration
Complete Example — UIKit
Complete Example — SwiftUI
Error Handling
Privacy & App Store
Troubleshooting
Files Checklist

Overview#

Bas Pay iOS SDK is distributed as an XCFramework (bas_pay.xcframework). It contains:
ComponentDescription
BasMainIosKt.BasMainIosController(...)Factory method that creates a UIViewController containing the full payment UI (built with Compose Multiplatform)
BankyLiteNotificationManagerNotification manager that must be registered before presenting the payment screen
onReturnDataToIOS callbackClosure that receives the payment result as a JSON string when the payment flow completes
The XCFramework is automatically downloaded from:
https://github.com/BasPlatform/BasPayment-IOS/releases/latest/download/bas_pay.xcframework.zip
Current latest version: 1.0.1

Architecture#

┌──────────────────────────────────────────────┐
│            Your Swift App                     │
│                                               │
│  1. BankyLiteNotificationManager.register()   │
│  2. BasMainIosKt.BasMainIosController(...)    │
│  3. present(viewController)                   │
│  4. onReturnDataToIOS callback ← result JSON  │
└──────────────────┬───────────────────────────-┘
                   │
                   ▼
┌──────────────────────────────────────────────┐
│         bas_pay.xcframework                   │
│  ┌────────────────────────────────────────┐   │
│  │  BasMainIosKt                          │   │
│  │  • BasMainIosController() → UIVC      │   │
│  ├────────────────────────────────────────┤   │
│  │  BankyLiteNotificationManager          │   │
│  │  • .shared.register()                  │   │
│  └────────────────────────────────────────┘   │
│                                               │
│  (Compose Multiplatform UI inside)            │
└──────────────────────────────────────────────-┘

Requirements#

RequirementMinimum Version
iOS Deployment Target13.0
Swift5.0
Xcode15.0+
CocoaPods (if using)1.16.0+

Installation#

Method 1: Manual Download (Recommended)#

Step 1: Download the XCFramework from the latest release:
Or download manually from: https://github.com/BasPlatform/BasPayment-IOS/releases/tag/1.0.1
Step 2: Your project structure should look like:
YourProject/
├── YourProject.xcodeproj
├── YourProject/
│   ├── AppDelegate.swift
│   ├── SceneDelegate.swift
│   ├── ViewController.swift
│   └── ...
└── Frameworks/
    └── bas_pay.xcframework/
        ├── ios-arm64/
        │   └── bas_pay.framework
        └── ios-arm64_x86_64-simulator/
            └── bas_pay.framework
Step 3: Add to Xcode:
1.
Open your .xcodeproj in Xcode
2.
Select your project target → General tab
3.
Scroll to Frameworks, Libraries, and Embedded Content
4.
Click + → Add Other... → Add Files...
5.
Select bas_pay.xcframework from the Frameworks/ directory
6.
Set Embed to "Embed & Sign"

Method 2: CocoaPods#

Create or edit your Podfile:
Then run:
Note: The podspec has a prepare_command that automatically downloads bas_pay.xcframework from GitHub Releases during pod install.

Step: Xcode Project Configuration#

After adding the framework, configure your build settings:
1.
Target → Build Settings → Search Paths:
Add the Frameworks/ directory to Framework Search Paths:
$(PROJECT_DIR)/Frameworks
2.
Target → Build Settings → Other Linker Flags:
If you encounter linking issues, add:
-ObjC
3.
Target → Build Settings → Excluded Architectures:
For simulator builds, you may need:
EXCLUDED_ARCHS[sdk=iphonesimulator*] = i386

Usage#

Step 1: Import the SDK#

Step 2: Register BankyLite Notifications#

This must be called before presenting the payment screen. It registers internal notification handlers needed by the SDK.

Step 3: Create the Payment ViewController#

Step 4: Present the Payment Screen#

Important: The payment ViewController must be wrapped in a UINavigationController before presenting.

Parameters Reference#

ParameterTypeRequiredDefaultDescription
trxTokenString✅ Yes—The transaction token obtained from your backend API. Unique per payment session.
userIdentifierString?❌ NonilUser identifier (e.g., phone number "733733733")
fullNameString?❌ NonilFull name of the paying user
languageString?❌ No"ar"UI language: "ar" (Arabic) or "en" (English)
productString?❌ NonilProduct name or identifier
onReturnDataToIOS((String?) -> Void)?✅ Yes—Callback closure that receives the payment result JSON string
environmentString?❌ No"prod"Environment: "prod" for production, "dev" for development/testing
Note: Unlike Android, there is no platform parameter in iOS — the SDK detects it automatically.

Response Handling#

Response JSON Structure#

The onReturnDataToIOS callback receives a JSON string with this structure:
{
  "status": true,
  "message": "Payment completed successfully",
  "result": { ... },
  "code": 200
}

Response Fields#

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

Parsing the Response#

Create a helper model to parse the result:
Alternative — Quick parsing with JSONSerialization (simpler):

Environment Configuration#

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

Complete Example — UIKit#


Complete Example — SwiftUI#

Usage in your app entry point:

Error Handling#

ScenarioHow to DetectRecommended Action
User cancelled paymentonReturnDataToIOS receives nilShow "Payment cancelled" message
Payment failedstatus == false in response JSONShow error from message field
Invalid tokenstatus == false, check codeRequest a new token from backend
rootViewController not foundCannot present payment screenEnsure app has a key window with a root VC
XCFramework not foundBuild error: No such module 'bas_pay'Verify framework is embedded & signed
Simulator architecture errorBuild fails on simulatorAdd EXCLUDED_ARCHS[sdk=iphonesimulator*] = i386

Privacy & App Store#

The SDK includes a PrivacyInfo.xcprivacy file that declares:
Privacy KeyValue
NSPrivacyTrackingfalse
NSPrivacyTrackingDomainsEmpty (none)
NSPrivacyAccessedAPITypesEmpty (none)
NSPrivacyCollectedDataTypesEmpty (none)
✅ The SDK does not track users and does not collect personal data beyond what is explicitly passed via parameters.

Troubleshooting#

ProblemSolution
No such module 'bas_pay'Ensure bas_pay.xcframework is added to Frameworks, Libraries, and Embedded Content with Embed & Sign
Build error on Simulator (i386)Add to Build Settings: EXCLUDED_ARCHS[sdk=iphonesimulator*] = i386
BankyLiteNotificationManager crashMake sure BankyLiteNotificationManager.shared.register() is called before creating the payment VC
Payment screen doesn't appearEnsure you wrap the VC in UINavigationController before presenting
rootViewController is nilMake sure the app has a visible key window. In SwiftUI, access via UIApplication.shared.connectedScenes
Callback not firingCheck that onReturnDataToIOS closure is not nil. Use [weak self] to prevent retain cycles
CocoaPods prepare_command failsEnsure curl and unzip are available. Check internet connection. Run pod install --verbose for details
Linker errorsAdd -ObjC to Other Linker Flags in Build Settings
use_frameworks! errorThe SDK requires use_frameworks! in your Podfile

Files Checklist#

Before handing off to the iOS developer, ensure they have:
📦 bas_pay.xcframework — Download from GitHub Releases
📄 This documentation file
🔑 Access to generate trxToken from the backend API
📱 Xcode 15+ installed
🍎 iOS 13.0+ deployment target configured

API Quick Reference#


Key Differences from Android#

AspectAndroid (Kotlin)iOS (Swift)
SDK Format.aar files.xcframework
Entry PointBasPay.start()BasMainIosKt.BasMainIosController()
Result MechanismonActivityResultonReturnDataToIOS callback closure
Pre-registrationNot neededBankyLiteNotificationManager.shared.register() required
PresentationStarts an ActivityPresent a UINavigationController
platform parameterAcceptedNot used (auto-detected)
Package ManagerGradle / flatDirCocoaPods / Manual XCFramework

Generated from BasPlatform/BasPaymentFlutter and BasPlatform/BasPayment-IOS source code analysis.
Modified at 2026-05-12 20:55:15
Previous
Android SDK
Next
Signature (Checksum) Documentation
Built with