telr_mobile_payment_sdk 3.0.1
telr_mobile_payment_sdk: ^3.0.1 copied to clipboard
Flutter plugin that wraps Telr native iOS/Android SDKs via platform channels to present the payment UI.
Telr Flutter Payments SDK #
Accept Telr payments in your Flutter app with a single call. The SDK presents the Telr checkout, handles the flow, and returns a clear success/failure result.
Requirements #
- Flutter: ≥ 3.19 (Dart ≥ 3)
- iOS: ≥ 15.1
- Android: minSdk ≥ 21, targetSdk ≥ 34
- Backend: HTTPS
tokenURLandorderURL
Install #
Add to pubspec.yaml and fetch:
dependencies:
telr_mobile_payment_sdk: ^X.Y.Z
flutter pub get
iOS setup #
- Set minimum iOS in
ios/Podfileand enable static frameworks:
platform :ios, '15.1'
target 'Runner' do
use_frameworks! :linkage => :static
end
- Install pods:
cd ios && pod install
- If CocoaPods cannot find
TelrSDK, ensure Telr’s private/spec source is configured in your Podfile, runpod repo update, then re-install.
Android setup #
- Ensure repositories in
android/settings.gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
- Set SDK versions in
android/app/build.gradle:
android {
compileSdkVersion 34
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
}
}
- Optional: initialize on app load (configure language/logging)
Call the SDK initializer early (e.g., in main() before runApp()), especially if you want to set the preferred language or enable debug logging.
import 'package:flutter/widgets.dart';
import 'package:telr_mobile_payment_sdk/telr_mobile_payment_sdk.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await TelrSdk.init(
preferredLanguageCode: 'en',
debugLoggingEnabled: true,
samsungPayServiceId: null,
samsungPayMerchantId: null,
);
runApp(const MyApp());
}
Use #
Minimal example:
import 'package:flutter/material.dart';
import 'package:telr_mobile_payment_sdk/telr_mobile_payment_sdk.dart';
class PayButton extends StatelessWidget {
const PayButton({super.key});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () async {
try {
final res = await TelrSdk.presentPayment(
'https://merchant.example.com/token',
'https://merchant.example.com/order',
);
final msg = res.success
? 'Payment successful'
: 'Payment failed: ${res.message}';
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(msg)));
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Unexpected error: $e')),
);
}
}
},
child: const Text('Pay with Telr'),
);
}
}
If you need to set the language or other options, initialize once on app load as shown in the Android setup section, then call presentPayment when needed.
API #
- init({ preferredLanguageCode, debugLoggingEnabled, samsungPayServiceId, samsungPayMerchantId }) →
Future<PaymentResponse>- Initializes the SDK and applies configuration. Call once on app startup.
- presentPayment(tokenURL, orderURL) →
Future<PaymentResponse>- Presents the Telr payment UI full-screen and resolves when completed.
Types:
class PaymentResponse {
final bool success;
final String message;
const PaymentResponse({required this.success, required this.message});
}
Merchant checklist #
- Expose HTTPS
tokenURLandorderURLfrom your backend. - Ensure device/emulator can reach both URLs.
- Handle the returned result to confirm/cancel the order server-side.
Troubleshooting #
- Android: E002 "Unable to register for Activity Result": Ensure initialization happens during app load. Call
TelrSdk.init(...)inmain()beforerunApp(). - iOS: CocoaPods cannot find
TelrSDK: Configure Telr spec source, runpod repo update, thenpod install. - iOS: Build fails due to iOS version: Set
platform :ios, '15.1'or newer. - Android: minSdk/targetSdk mismatch: Use min 21 / target 34 / compile 34.
- Network/HTTP errors: Verify backend endpoints and connectivity.
Security #
- Always use HTTPS; validate server responses.
- Never embed secrets in the app or log cardholder data.
Links #
- Package on pub.dev: telr_mobile_payment_sdk
- Example app: see
example/
License #
MIT