paymob_flutter
A Flutter SDK for Paymob payment gateway. Supports Card (WebView & Direct API), Mobile Wallet (Vodafone Cash, Orange Money, Etisalat, WE), and Kiosk (Fawry / Aman) payments.
๐น Demo Videos
WebView Mode
https://github.com/AbanobNabeh/paymob_flutter/raw/main/demo/Paymob_Webview.mp4
API Mode (Native UI)
https://github.com/AbanobNabeh/paymob_flutter/raw/main/demo/Paymob_API.mp4
โจ What's New in 0.1.0
- โ Direct API card payment โ no WebView required
- โ Mobile Wallet support (Vodafone Cash, Orange Money, Etisalat, WE)
- โ Kiosk support (Fawry / Aman) with bill reference
- โ Dynamic bottom sheet โ only shows available payment methods
- โ
PaymentMode.apiorPaymentMode.webviewโ your choice - โ
PaymentResultwithsuccess,failed,pending,cancelled
๐ฆ Installation
dependencies:
paymob_flutter: ^0.1.0
๐ Quick Start
import 'package:paymob_flutter/paymob_flutter.dart';
final result = await Paymob.pay(
context: context,
config: PaymobConfig(
apiKey: 'YOUR_API_KEY',
integrationId: 123456,
iframeId: 789,
isSandbox: true,
),
order: PaymobOrder(
amount: 100.0,
currency: 'EGP',
items: [
OrderItem(name: 'Product', amount: 100.0, quantity: 1),
],
),
billing: BillingData(
firstName: 'John',
lastName: 'Doe',
email: 'john@example.com',
phone: '+201234567890',
),
);
if (result.isSuccess) {
print('Payment ID: ${result.transactionId}');
} else if (result.isPending) {
print('Pending: ${result.transactionId}');
} else if (result.isCancelled) {
print('Cancelled by user');
} else {
print('Failed: ${result.errorMessage}');
}
๐๏ธ Payment Modes
API Mode (Recommended)
No WebView โ full native Flutter UI.
PaymobConfig(
apiKey: 'YOUR_API_KEY',
integrationId: 123456,
iframeId: 789,
paymentMode: PaymentMode.api, // default
)
WebView Mode
Classic Paymob hosted iframe page.
PaymobConfig(
apiKey: 'YOUR_API_KEY',
integrationId: 123456,
iframeId: 789,
paymentMode: PaymentMode.webview,
)
Note: WebView mode only supports Card payments. Wallet and Kiosk always use Direct API regardless of
paymentMode.
๐ณ Adding Wallet Support
PaymobConfig(
apiKey: 'YOUR_API_KEY',
integrationId: 123456,
walletIntegrationId: 789012,
iframeId: 789,
)
Supported wallets: ๐ฑ Vodafone Cash ยท ๐ Orange Money ยท ๐ Etisalat Cash ยท ๐ต WE Pay
๐ง Adding Kiosk Support
PaymobConfig(
apiKey: 'YOUR_API_KEY',
integrationId: 123456,
kioskIntegrationId: 345678,
iframeId: 789,
)
Returns a bill reference number โ user pays cash at any Fawry or Aman kiosk.
๐ All Three Methods
PaymobConfig(
apiKey: 'YOUR_API_KEY',
integrationId: 123456,
walletIntegrationId: 789012,
kioskIntegrationId: 345678,
iframeId: 789,
isSandbox: true,
paymentMode: PaymentMode.api,
)
Bottom sheet will show: Card / Wallet / Kiosk
๐ฏ Direct Methods
// Card only
await Paymob.payWithCard(context: context, config: config, order: order, billing: billing);
// Wallet only
await Paymob.payWithWallet(context: context, config: config, order: order, billing: billing);
// Kiosk only
await Paymob.payWithKiosk(context: context, config: config, order: order, billing: billing);
โ๏ธ PaymobConfig Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| apiKey | String | โ | Your Paymob API Key |
| integrationId | int | โ | Card integration ID |
| iframeId | int | โ | Iframe ID from dashboard |
| walletIntegrationId | int? | โ | Wallet integration ID |
| kioskIntegrationId | int? | โ | Kiosk integration ID |
| isSandbox | bool | โ | Default: true |
| paymentMode | PaymentMode | โ | api (default) or webview |
๐ PaymentResult
| Property | Type | Description |
|---|---|---|
| isSuccess | bool | Payment completed successfully |
| isPending | bool | Kiosk reference generated / Wallet OTP sent |
| isCancelled | bool | User cancelled |
| transactionId | String? | Transaction ID or Kiosk reference |
| errorMessage | String? | Error message if failed |
| rawResponse | Map? | Full Paymob API response |
๐ Getting Paymob Credentials
- Go to Paymob Dashboard
- API Key โ Settings โ Account Info
- Card Integration ID โ Developers โ Payment Integrations โ Card
- Wallet Integration ID โ Developers โ Payment Integrations โ Wallet
- Kiosk Integration ID โ Developers โ Payment Integrations โ Kiosk
- Iframe ID โ Developers โ Iframes
๐งช Sandbox Test Cards
| Card | Number | Expiry | CVV |
|---|---|---|---|
| โ Success | 4987654321098769 |
Any future date | Any 3 digits |
| โ Failure | 4111111111111111 |
Any future date | Any 3 digits |
๐จโ๐ป Author
Abanob Nabeh
๐ License
MIT License โ feel free to use in commercial projects.