lankapay_justpay_flutter 0.2.1
lankapay_justpay_flutter: ^0.2.1 copied to clipboard
Flutter plugin bridging LankaPay LPTrusted (JustPay): getDeviceId and createIdentityAndSign over MethodChannel justpay_sdk/methods. Host apps must supply bank JSON and SDK binaries per README.
lankapay_justpay_flutter #
→ Full step-by-step integration (permissions, Gradle, plist, ATS, JSON, verification): doc/COMPLETE_SETUP_GUIDE.md
Flutter MethodChannel bridge to the LankaPay LPTrusted (JustPay) native SDK. It exposes:
getDeviceId()— LPTrusted device identifiercreateIdentityAndSign({ challenge, contentToSign })— create identity if needed, sign content, validate mobile
Channel name: justpay_sdk/methods (package-owned; not tied to a specific app).
This package does not include bank REST APIs, onboarding UI, or LankaPay proprietary binaries unless your distribution model explicitly adds them. Confirm redistribution rights for .aar / .xcframework with LankaPay and your legal team before publishing a build that vendors those files.
Prerequisites #
- Completed (or in-progress) JustPay / MID onboarding with your acquiring bank
- Flutter SDK compatible with
pubspec.yaml - Android: min SDK as required by your app (plugin
minSdkis 24) - iOS: deployment target 13.0+ (MID); disable Bitcode per MID
- From the bank / LankaPay kit:
justpay.json,mnv.json,LPTrustedSDK.aar(Android),LPTrustedSDK.xcframework(iOS)
Installation #
dependencies:
lankapay_justpay_flutter: ^0.2.1
Path / git:
dependencies:
lankapay_justpay_flutter:
path: ../lankapay_justpay_flutter
Then:
flutter pub get
cd ios && pod install && cd ..
Android configuration #
-
SDK binary
CopyLPTrustedSDK.aartoandroid/app/libs/LPTrustedSDK.aar. -
App
build.gradle/build.gradle.kts
Ensure the host application depends on the AAR (Gradle must see it at app level for packaging):dependencies { implementation(files("libs/LPTrustedSDK.aar")) }The plugin uses
compileOnlyagainst the same path (android/app/libs/LPTrustedSDK.aar) so it can compile against LPTrusted APIs; your app must stillimplementationthe AAR so classes are packaged in the APK. -
MID dependencies
The plugin already depends on OkHttp 4.9.3 and json-simple 1.1.1 (transitive = false). You may keep the same lines in the app if your MID or other code requires them explicitly. -
JSON config
Placejustpay.jsonandmnv.jsonunderandroid/app/src/main/res/raw/with resource namesjustpayandmnv(filesjustpay.jsonandmnv.json). The bridge validates required keys before calling the SDK (same checks as typical native LPTrusted integration). -
Manifest & network
INTERNETpermissionandroid:networkSecurityConfigreferencingres/xml/network_security_config.xmlwith MID cleartext / certificate rules for the four hosts specified in your MID (obtain exact hostnames from the official MID or your bank; do not commit secrets).
-
Package name
Thepackagefield insidejustpay.jsonmust match the appapplicationId(watch product flavors and suffixes). -
Release / R8
The plugin shipsconsumer-rules.prowith a keep rule forcom.lankapay.justpay.**. Replace or extend with rules LankaPay supplies. Test release builds on device.
iOS configuration #
-
SDK binary
CopyLPTrustedSDK.xcframeworkinto your Flutter app under:ios/JustPaySDK/LPTrustedSDK.xcframework(sibling folder to
Pods, as referenced by the plugin podspec’sFRAMEWORK_SEARCH_PATHS.) -
Embed & Sign
Per MID §7.1.1: add the xcframework to the Runner target in Xcode if required by your setup, and ensure it is Embed & Sign where the MID dictates. -
JSON config
Addjustpay.jsonandmnv.jsonto the Runner target → Copy Bundle Resources (filenamesjustpay.jsonandmnv.json). -
App Transport Security
Add ATS exception domains from MID §6.5 (four hosts — use the MID / bank documentation; do not commit confidential endpoints in public repos). -
Build settings
- Bitcode: No (MID §7.1.2)
- iOS deployment target: ≥ 13
-
Linking
The podspec setsFRAMEWORK_SEARCH_PATHSto"${PODS_ROOT}/../JustPaySDK"and links-framework LPTrustedSDK. If your layout differs, adjust paths or use apost_installhook in yourPodfileto align search paths with your xcframework location.
Build without LPTrusted (Dart-only / CI) #
Swift uses #if canImport(LPTrustedSDK) so analysis can succeed when the framework is absent, but release/debug iOS builds that link the real module still require the xcframework at the documented path.
Dart usage #
import 'package:lankapay_justpay_flutter/lankapay_justpay_flutter.dart';
final justPay = LankapayJustpayFlutter();
Future<void> enroll() async {
final deviceId = await justPay.getDeviceId();
// Send deviceId to your bank API if required.
final challenge = '...'; // from your bank JustPay API
final terms = '...'; // text the user agreed to (per integration guide)
final result = await justPay.createIdentityAndSign(
challenge: challenge,
contentToSign: terms,
);
if (result.success) {
final signature = result.signature;
final mobileReference = result.mobileReference;
// POST to your bank register/onboarding API.
} else {
// result.message — user-facing error handling
}
}
Operational & troubleshooting #
- Missing / invalid JSON: SDK or validation may surface errors (e.g. codes such as 201 / MNV 501 — refer to MID / bank docs).
- Wrong applicationId / package: Identity and signing can fail; align
justpay.jsonwith the built app id. - ATS / cleartext blocked: Check
Info.plistexception domains. - Identity already exists / retry: Android bridge retries identity creation for selected error codes (300–303, 305) up to two retries after
clearIdentity(), matching common native LPTrusted retry behavior. - iOS: If signing fails, confirm Embed & Sign and framework search paths for the plugin pod.
Distribution variants #
| Variant | What you ship | Integrator work |
|---|---|---|
| BYO SDK (typical public pub.dev) | Dart + native bridge source only | Add AAR, xcframework, JSON, ATS, network config in the host app |
| Private / licensed bundle | Above + vendored AAR/xcframework | Legal clearance required; may simplify Gradle/CocoaPods setup |
Migrating from embedded native JustPay code #
If you previously wired LPTrusted yourself in MainActivity / FlutterActivity or AppDelegate:
- Add
lankapay_justpay_fluttertopubspec.yaml. - Remove your custom JustPay
MethodChanneland duplicate LPTrusted helpers from the host app; useLankapayJustpayFlutterfrom this package instead. - Keep Firebase, notifications, and other channels as they are.
- This plugin registers
justpay_sdk/methodsonly; remove any old app-specific JustPay channel name from your code. - Run a full JustPay onboarding regression on Android and iOS.