Kashier Flutter SDK
Accept Card, Apple Pay, and mobile wallet payments in Egypt with a prebuilt, localized (English/Arabic) payment sheet — all from a single API call.
Platform support: iOS and Android for Card and mobile wallet payments. Apple Pay is iOS-only and requires iOS 14.0+. Android apps should not add Apple Pay setup; Card and Wallet do not require it.
Installation
Add the dependency to your pubspec.yaml:
dependencies:
kashier_flutter_sdk: ^0.1.0
For iOS apps, ensure your ios/Podfile targets at least iOS 14.0:
platform :ios, '14.0'
Setup
Wrap your app with KashierPaymentProvider so the SDK can render its payment
sheet on its own overlay (works with any navigation solution):
void main() {
runApp(
KashierPaymentProvider(
child: MaterialApp(home: HomeScreen()),
),
);
}
Initialize the SDK once before starting any payment:
KashierSDK.initialize(
mode: KashierMode.test, // or KashierMode.live
language: KashierLanguage.en, // or KashierLanguage.ar
);
Quick start
Your backend creates a payment session via Kashier's Payment Sessions API and hands the session ID to your app. The app passes only that session ID to the SDK — no API keys or card data ever live in the mobile binary.
KashierSDK.startPayment(
sessionId: 'sess_abc123', // from your backend
onSuccess: (KashierPaymentResult result) {
print('Paid: ${result.transactionId}');
},
onPending: (KashierPaymentPending pending) {
// Terminal: payment still settling — confirm via webhook/backend
print('Pending order: ${pending.orderId}');
},
onFailure: (KashierPaymentError error) {
if (error.code == KashierErrorCode.userCancelled) return;
print('Failed: ${error.message}');
},
);
The SDK fetches the session, shows the method-selection sheet (Apple Pay, Wallet, Card — whichever the session and device support), runs the chosen flow end-to-end (including 3DS WebViews and wallet reconcile polling), and fires exactly one callback when done.
Apple Pay
Apple Pay is available only on iOS. You use your own Apple Pay Merchant ID — Kashier acts as the payment processor (the same per-merchant model Stripe and Adyen use). The SDK never bundles or exposes any Kashier merchant identifier.
-
Register your own Apple Pay Merchant ID (e.g.
merchant.com.yourcompany.app) in the Apple Developer portal. -
Enable the Apple Pay capability in Xcode (Signing & Capabilities →
- Capability → Apple Pay).
-
Add your Merchant ID to your app's entitlements file (
com.apple.developer.in-app-payments), mirroringexample/ios/Runner/Runner.entitlements:<key>com.apple.developer.in-app-payments</key> <array> <string>merchant.com.yourcompany.app</string> </array> -
Pass the same Merchant ID to the SDK when you initialize it:
KashierSDK.initialize( mode: KashierMode.live, appleMerchantId: 'merchant.com.yourcompany.app', // must match the entitlement );
The entitlement value and appleMerchantId must match exactly. When
appleMerchantId is omitted, Apple Pay is not offered. Contact the Kashier team
to have your Merchant ID provisioned as a processing certificate on their side.
Testing Apple Pay requires a physical iOS device; the Simulator reports
applePayNotAvailable.
Apple Pay without the payment sheet
To open native Apple Pay from your own button in one tap, call
KashierSDK.payWithApplePay instead of startPayment:
KashierApplePayButton(
onPressed: () => KashierSDK.payWithApplePay(
sessionId: 'sess_abc123', // from your backend
onSuccess: (result) => print('Paid: ${result.transactionId}'),
onFailure: (error) {
if (error.code == KashierErrorCode.userCancelled) return;
print('Failed: ${error.message}');
},
),
)
It fails with applePayNotAvailable when the session does not allow Apple Pay.
Otherwise, when appleMerchantId was not passed to initialize, it fails with
applePayConfigError on every platform. With appleMerchantId set, it fails
with applePayNotAvailable when the device cannot pay with Apple Pay
(including on Android).
It does not need KashierPaymentProvider.
startPayment takes the same shortcut on its own when Apple Pay is the only
method available for the session on this device (for example a session created
with allowedMethods: "applePay"). In that case, closing the Apple Pay sheet
ends the payment with onFailure(userCancelled), because there is no Kashier
sheet to return to.
In both cases no Kashier sheet is shown, neither before Apple Pay nor after it: the native Apple Pay sheet shows its own success or failure tick, and your callbacks decide what the customer sees next.
Wallets and cards
- Mobile wallets (Vodafone Cash and other Egyptian R2P wallets): the customer enters their phone number and approves the charge in their wallet app while the SDK polls for reconciliation.
- Cards: new card, saved cards, and 3-D Secure are handled inside the SDK's own sheet. Card data is tokenized directly against Kashier — it never touches your app, keeping you out of PCI scope.
Card authorization
An authorization holds the customer's funds on their card; your server captures or voids the hold later. To hold card payments instead of charging them:
- Create the payment session on your server with
manualCapture: true. - Present the sheet as usual. There is nothing to configure in the app: the SDK reads the flag from the session and sends an authorization for new-card and saved-card payments.
- A successful authorization reaches
onSuccesswithresult.status == "AUTHORIZED". The funds are held, not captured.
Without manualCapture, or with manualCapture: false, cards are charged at
once, as before.
Things to know:
- Apple Pay and wallet payments charge at once, even on a manual-capture
session. When every payment must be a hold, restrict
allowedMethodstocardwhen you create the session. - Authorize-and-capture must be enabled on your Kashier merchant account.
- Capture and void run on your server with your secret key. The SDK never captures or voids, and the secret key must never ship in an app.
See Authorize and capture for the server-side calls.
Error handling
All failures (including user cancellation) arrive via
onFailure(KashierPaymentError). Inspect error.code
(a KashierErrorCode) to decide how to respond — for example, suppress error
UI for userCancelled, and offer a retry for networkError or
paymentDeclined. Every error carries localized message (English) and
messageAr (Arabic) copy.
Test mode
Initialize with KashierMode.test and create sessions against Kashier's test
API. Use the test card to exercise the card flow:
4508 7500 1574 1019
Documentation
Full integration guide, API reference, and backend session setup: developers.kashier.io/flutter
License
MIT — see LICENSE.
Libraries
- kashier_flutter_sdk
- Kashier Flutter SDK — accept payments in your Flutter app.
- models/kashier_language
- models/kashier_mode
- models/kashier_payment_error
- models/kashier_payment_pending
- models/kashier_payment_result
- models/kashier_wallet_provider