π³ Koin Payments Flutter Plugin
The Koin Payments Flutter Plugin provides a unified Flutter interface to integrate the Koin Checkout SDK for both Android and iOS platforms.
It allows you to initialize the SDK, build payment requests (PaymentRequest), and start checkout flows using PIX, Card, BNPL (Buy Now, Pay Later), and PayPal with a single crossβplatform API.
π§© Features
- β Works with Flutter 3.10+ and Dart 3.0+
- πͺ Supports BottomSheet and Fullscreen checkout presentations
- π° Payment methods: PIX, Credit Card, BNPL, PayPal
- π§ Uses the native Koin SDKs under the hood (iOS & Android)
- βοΈ Simple initialization and strongly typed request mapping
π¦ Installation
In your project pubspec.yaml:
dependencies:
payments_flutter_plugin:
git:
url: https://github.com/koinlatam/payments-flutter-plugin.git
ref: main
Then run:
flutter pub get
π§ Android Setup
1οΈβ£ Add Koin's Maven repository
In your android/settings.gradle or android/build.gradle file (plugin and app):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven { url = uri("https://koinlatam.github.io/koin-checkout-android/") }
maven { url = uri("https://storage.googleapis.com/download.flutter.io") }
}
}
2οΈβ£ Internet permission
Make sure your app's manifest includes:
<uses-permission android:name="android.permission.INTERNET" />
3οΈβ£ Initialization
You donβt need a custom Application class β the Flutter pluginβs
PaymentsFlutter.initialize() method automatically initializes
the Koin SDK for you.
π iOS Setup
1οΈβ£ Podfile
Enable dynamic frameworks:
use_frameworks!
use_modular_headers!
2οΈβ£ Koin CocoaPods repository
The iOS SDK (KoinPaymentCheckout) is fetched automatically by CocoaPods when installing the plugin.
Run:
cd ios
pod install
3οΈβ£ Initialization
On iOS, initialization is also handled by PaymentsFlutter.initialize().
π Basic Usage
1οΈβ£ Initialize the SDK
await PaymentsFlutter.initialize(
key: 'sk_your_private_key_here',
paypalClientID: 'your_paypal_client_id',
isHomolog: true, // true = sandbox
enableLogs: true,
maxRetries: 3,
pollingInterval: 3.0, //seconds
pollingTimeout: 360.0, //seconds
);
2οΈβ£ Build a payment request
You can use mocks (from the example) or build manually.
final input = {
'input': {
'payment': {
'data': {
'country_code': 'BR',
'store': {'code': 'YOUR_SDK_CODE'},
'transaction': {
'reference_id': 'REF${DateTime.now().millisecondsSinceEpoch}',
'account': 'YOUR_ACCOUNT',
'amount': {'currency_code': 'BRL', 'value': 250.0},
},
'payer': {
'email': 'user@email.com',
'document': {'type': 'cpf', 'number': '29517016085'},
'full_name': 'John Doe'
},
'payment_method': {'code': 'PIX'},
'presentation_style': 'bottomsheet', // or 'fullscreen'
},
'kind': 'pix',
},
},
};
3οΈβ£ Start the checkout
final result = await PaymentsFlutter.startCheckout(input: input);
print(result);
π Internationalization (i18n)
This plugin and its example apps support multiple languages (English, Portuguese, Spanish).
For full setup instructions, see the Internationalization Guide.
π¨ Presentation Modes (BottomSheet / Fullscreen)
The unified field presentation_style controls how the checkout view appears.
| Value | iOS Equivalent | Android Equivalent |
|---|---|---|
'bottomsheet' |
.bottomSheet |
useBottomSheet = true |
'fullscreen' |
.fullscreen |
useBottomSheet = false |
The plugin automatically maps presentation_style β useBottomSheet on Android.
π‘ Full Example
await PaymentsFlutter.initialize(
key: 'sk_your_private_key_here',
isHomolog: true,
enableLogs: true,
);
final input = {
'input': {
'payment': {
'data': {
'country_code': 'BR',
'store': {'code': 'YOUR_SDK_CODE'},
'transaction': {
'reference_id': 'REF123',
'account': 'YOUR_ACCOUNT',
'amount': {'currency_code': 'BRL', 'value': 250.0},
},
'payer': {
'email': 'user@email.com',
'document': {'type': 'cpf', 'number': '29517016085'},
'full_name': 'John Doe',
},
'payment_method': {'code': 'PIX'},
'presentation_style': 'bottomsheet',
},
'kind': 'pix',
},
},
};
final result = await PaymentsFlutter.startCheckout(input: input);
print(result);
π§ Example Project Structure
example/
ββ lib/
β ββ main.dart # Main screen
β ββ views/
β β ββ payment_view.dart
β ββ viewmodels/
β β ββ payment_viewmodel.dart
β ββ mocks/
β β ββ mock_pix.dart
β β ββ mock_card.dart
β β ββ mock_bnpl.dart
β β ββ mock_paypal.dart
β ββ models/
β β ββ payment_input.dart
ββ android/
β ββ build.gradle, settings.gradle (with Koin repo)
ββ ios/
β ββ Podfile, Podfile.lock (links Koin iOS SDK)
π§ͺ Checkout Results
The startCheckout method returns a Map<String, dynamic> describing the result:
| Result Type | type field |
Example |
|---|---|---|
| Success | processed |
{ "data": { "referenceId": "...", "status": { "type": "APPROVED" } } } |
| Failure | failure |
{ "error": { "code": "NETWORK", "message": "Timeout" } } |
| Canceled | canceled |
{ "type": "canceled" } |
π§Ύ License
This project is licensed under the MIT License.
π·οΈ Plugin Version
Koin Payments Flutter Plugin v0.0.3
PaymentsFlutter.version == "0.0.3"
π§° Useful Links
- π Android SDK
- π iOS SDK
Built by the Koin team.