foundrex_sdk 0.0.2
foundrex_sdk: ^0.0.2 copied to clipboard
Foundrex Payments and KYC Flutter SDK.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:foundrex_sdk/foundrex_sdk.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Foundrex once at app startup
Foundrex.initialize(
apiKey: 'fn_live_sk_xxxxxxxxxxxxxxxxxxxxx', // Tenant API key
baseUrl: 'https://api.foundrex.com',
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(home: PaymentDemo());
}
}
class PaymentDemo extends StatelessWidget {
const PaymentDemo({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Foundrex Payments')),
body: Center(
child: ElevatedButton(
onPressed: () async {
try {
// 🔥 In real apps, this comes from YOUR auth system
// Firebase, Cognito, Auth0, custom backend, etc.
final String fxUserAccessToken =
'USER_JWT_ACCESS_TOKEN_FROM_YOUR_APP';
final success = await Foundrex.payments.checkoutAndPay(
fxUserAccessToken: fxUserAccessToken,
amount: 25000, // RM 250.00
referenceId: 'booking_123',
);
if (success) {
debugPrint('✅ Payment succeeded');
} else {
debugPrint('❌ Payment failed');
}
} catch (e) {
debugPrint('Payment failed: $e');
}
},
child: const Text('Pay RM250'),
),
),
);
}
}