Payment Gateway SDK — Flutter
Integrate DigetPay payments into your Flutter application using the official digetpay_plugin package.
The Flutter SDK is a pure-Dart package that provides a DigetPay-hosted checkout experience through a WebView. It supports Android and iOS and is designed to keep raw card data out of your application during hosted checkout.
Requirements
| Requirement | Supported Version |
|---|---|
| Flutter SDK | Compatible with Flutter applications using Dart |
| Android | Android 7.0+ |
| Android API | 24+ |
| iOS | iOS 13.0+ |
| Platforms | Android / iOS |
| Language | Dart |
| Package | digetpay_plugin |
Flutter Web and desktop are not supported in the current SDK version.
Installation
Add the DigetPay package to your Flutter application:
flutter pub add digetpay_plugin
Or add the package to your pubspec.yaml:
dependencies:
digetpay_plugin: ^0.5.0Then install the package dependencies:
flutter pub getQuick Start
1. Initialize the SDK
Initialize the SDK once when your application starts:
import 'package:digetpay_plugin/digetpay_plugin.dart';
DigetPaySdk.initialize(
apiKey: '<your-mobile-api-key>',
baseUrl: kDigetPayDefaultBaseUrl,
);Use the appropriate DigetPay environment and a mobile-restricted or publishable API key.
Every SDK operation requires initialization. Calling an SDK method before
initialize()results in aDigetPaySdkIsNotInitializedException.
2. Launch Hosted Checkout
Hosted Checkout is the recommended payment flow for card payments.
await DigetPaySdk.cardPay()
.setOrder(
DigetPaySaleOrder(
id: orderId,
description: 'Coffee',
currency: 'SAR',
amount: 15,
),
)
.setPayer(
DigetPayPayer(
firstName: 'Ahmed',
lastName: 'Ali',
address: 'Riyadh',
country: 'SA',
city: 'Riyadh',
zip: '00000',
email: '[[email protected]](mailto:[email protected])',
phone: '+966500000000',
),
)
.onTransactionSuccess((res) {
');
)
.onTransactionFailure((res) {
');
)
.onDismiss(() \{
cancelled');
)
.start(context);The SDK creates the checkout session, opens the DigetPay-hosted payment page, handles the WebView flow, and returns the payment outcome through the registered callbacks.
Hosted Checkout
Hosted Checkout is the recommended default for card payments.
The customer enters their card details on the DigetPay-hosted payment page rather than inside your application's own UI.
The SDK handles:
- Checkout session creation
- Hosted payment page
- 3-D Secure flow
- Checkout result handling
- Transaction status verification
- Success, failure, and cancellation callbacks
The final transaction status returned by the gateway should be treated as authoritative.
Do not rely only on the success URL or visual checkout result when determining whether an order was paid. Verify the final transaction status before fulfilling the order.
Payment Results
The hosted checkout flow provides three possible application outcomes:
| Callback | When it is triggered |
|---|---|
onTransactionSuccess | The transaction is successfully approved |
onTransactionFailure | The transaction fails or is declined |
onDismiss | The customer closes or leaves the checkout without reaching a final result |
For successful payments, store the relevant transaction identifiers on your backend and verify the transaction before updating your order state.
Available Capabilities
The Flutter SDK currently provides APIs for:
| Capability | Availability |
|---|---|
| Hosted Checkout | ✓ |
| Direct S2S Card Sale | ✓ |
| Checkout Session Payment | ✓ |
| Transaction Status | ✓ |
| Transaction History | ✓ |
| Transaction Lookup by ID | ✓ |
| Checkout Session Listing | ✓ |
| Capture | ✓ |
| Void | ✓ |
| Refunds | ✓ |
| Recurring Charges | ✓ |
| Recurring Subscriptions | ✓ |
| Apple Pay | Not available |
| External Payment | Not available |
Direct S2S card operations require your application to handle raw card data and therefore have a larger PCI-DSS scope. Prefer Hosted Checkout unless your integration has been independently assessed for the required PCI responsibilities.
Recurring Payments
The SDK supports recurring charges using a recurringToken obtained from an eligible payment.
Recurring operations do not require the customer's card details again.
Use the recurring API that matches the payment flow used to obtain the token:
- Hosted Checkout recurring payments
- Direct S2S recurring payments
- Existing subscription charges
Keep recurring tokens secure and handle them as sensitive payment credentials.
Transaction Operations
The SDK provides operations for managing existing transactions, including:
- Capture
- Void
- Refund
- Transaction status
- Transaction history
Use the transaction identifier returned by DigetPay when performing an operation.
For refunds, use the operation that matches the original payment flow.
Platform Setup
Android
The Flutter application must support:
- Android 7.0 or later
- Android API 24 or later
- Internet connectivity
- WebView support
Add the required Internet permission to the Android application manifest if it is not already provided by your application configuration:
<uses-permission android:name="android.permission.INTERNET"/>iOS
The Flutter application must support:
- iOS 13.0 or later
- Standard HTTPS networking
- WebView support
DigetPay endpoints and hosted checkout pages use HTTPS, so no blanket App Transport Security exception should be required.
Security
The mobile API key is embedded in the application and may potentially be extracted.
Use a restricted or publishable mobile API key for the Flutter application. Never embed a server-side secret or privileged credential in the mobile application.
For card payments, prefer cardPay() because raw card data does not pass through your application during Hosted Checkout.
Direct methods such as sale() explicitly collect card data inside the application and therefore increase your PCI-DSS responsibilities.
Sensitive business logic, privileged operations, and server-side credentials should remain on your backend.
SDK Versioning
| Item | Current Version |
|---|---|
| Flutter SDK | 0.5.0 |
| Package | digetpay_plugin |
| License | MIT |
| Platforms | Android / iOS |
Check the official package page for the latest released version and changes before upgrading.
Version Compatibility
| Platform | Minimum Version |
|---|---|
| Android | 7.0 / API 24 |
| iOS | 13.0 |
| Flutter Web | Not supported |
| Flutter Desktop | Not supported |
Version and platform requirements may change in future releases.
Not Yet Available
The following SDK methods are currently unavailable because their corresponding backend endpoints are not available:
applePayexternalPaymentgetTransactionByOrderIdgetTransactionByRrn
These methods currently return UnsupportedError.
Full DocumentationThe
digetpay_pluginpackage contains the complete API documentation, advanced payment flows, transaction operations, recurring payment details, models, filters, and implementation examples.
Related
Updated 28 days ago

