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.

pub version license platform


๐Ÿ“น 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.api or PaymentMode.webview โ€” your choice
  • โœ… PaymentResult with success, 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

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

  1. Go to Paymob Dashboard
  2. API Key โ†’ Settings โ†’ Account Info
  3. Card Integration ID โ†’ Developers โ†’ Payment Integrations โ†’ Card
  4. Wallet Integration ID โ†’ Developers โ†’ Payment Integrations โ†’ Wallet
  5. Kiosk Integration ID โ†’ Developers โ†’ Payment Integrations โ†’ Kiosk
  6. 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

GitHub   LinkedIn   Instagram


๐Ÿ“„ License

MIT License โ€” feel free to use in commercial projects.

Libraries

paymob_flutter