paymob_flutter 0.1.3 copy "paymob_flutter: ^0.1.3" to clipboard
paymob_flutter: ^0.1.3 copied to clipboard

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.

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


๐Ÿ’ณ Card API #

Card API Demo


๐ŸŒ Card WebView #

Card WebView Demo


๐Ÿ“ฑ Wallet Payment #

Wallet Demo


๐Ÿง Kiosk Payment #

Kiosk Demo

โœจ What's New in 0.1.3 #

  • โœ… Full dartdoc coverage โ€” 160/160 pub points
  • โœ… Fixed isSandbox โ€” now correctly switches between sandbox and production URLs
  • โœ… Replaced deprecated withOpacity() with withValues(alpha:) throughout
  • โœ… tokenExpiration โ€” configure payment-key lifetime (default 3600 s)
  • โœ… extraPaymentKeyData โ€” merge custom fields into the payment-key request
  • โœ… extraOrderData โ€” merge custom fields into the order-registration request
  • โœ… PaymobOrder.merchantOrderId โ€” link Paymob orders to your own order IDs
  • โœ… PaymobOrder.deliveryNeeded โ€” control delivery flag per order
  • โœ… OrderItem โ€” optional description, sku, category, and extra fields
  • โœ… BillingData โ€” all address fields are now optional (default 'NA'), plus extra map
  • โœ… PaymobService is now fully public with dartdocs for advanced use

๐Ÿ“ฆ Installation #

dependencies:
  paymob_flutter: ^0.1.3

๐Ÿš€ 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


โš™๏ธ Advanced Configuration #

Token expiration #

PaymobConfig(
  apiKey: 'YOUR_API_KEY',
  integrationId: 123456,
  iframeId: 789,
  tokenExpiration: 7200, // 2 hours instead of the default 1 hour
)

Extra request fields #

Inject any custom or undocumented Paymob field without modifying the SDK:

PaymobConfig(
  apiKey: 'YOUR_API_KEY',
  integrationId: 123456,
  iframeId: 789,
  extraPaymentKeyData: {'lock_order_when_paid': true},
  extraOrderData: {'notes': 'VIP customer'},
)

Merchant order ID #

Link Paymob orders back to your own order IDs for reconciliation:

PaymobOrder(
  amount: 150.0,
  currency: 'EGP',
  merchantOrderId: 'MY-ORDER-001',
  items: [OrderItem(name: 'Deposit', amount: 150.0, quantity: 1)],
)

Full BillingData example #

BillingData(
  firstName: 'Ahmed',
  lastName: 'Mohamed',
  email: 'ahmed@example.com',
  phone: '+201234567890',
  city: 'Cairo',
  country: 'EGY',
  street: 'Tahrir Square',
  postalCode: '11511',
  extra: {'custom_field': 'value'}, // any extra Paymob billing field
)

๐ŸŽฏ 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 #

โš™๏ธ PaymobConfig Parameters #

Parameter Type Required Default Description
apiKey String โœ… โ€” Your Paymob API Key
integrationId int โœ… โ€” Card integration ID
iframeId int โœ… โ€” Iframe ID from dashboard
walletIntegrationId int? โŒ null Wallet integration ID
kioskIntegrationId int? โŒ null Kiosk integration ID
isSandbox bool โŒ true Switch between sandbox / production
paymentMode PaymentMode โŒ api api (native UI) or webview
tokenExpiration int โŒ 3600 Payment-key lifetime in seconds
extraPaymentKeyData Map? โŒ null Extra fields for the payment-key request
extraOrderData Map? โŒ null Extra fields for the order request

๐Ÿ“Š 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 bill 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.

7
likes
160
points
183
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dio, flutter, url_launcher, webview_flutter

More

Packages that depend on paymob_flutter