搜索插件、代码仓与 APP 分类

插件详情v1.0.8

flutter_paymob

使用 Paymob,轻松在您的 Flutter 应用中通过在线信用卡和移动钱包接受付款。

AndroidiOSWebmacOSWindows
近 30 天下载
87
喜欢数
35
Pub 分数
140

安装插件

flutter pub add flutter_paymob

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_paymob 是一个 Flutter 包,可将 Paymob 的支付解决方案无缝集成到 Flutter 应用中。它支持 Android、iOS、Web、macOS 和 Windows 平台上的在线信用卡支付和移动钱包交易。通过 `flutter pub add flutter_paymob` 简单配置,开发者可以快速在应用中实现安全的支付处理。该包提供简洁的 API 来处理支付流程、令牌化和交易状态检查,简化了用户的结账体验。适用于电子商务应用、订阅服务以及任何需要可靠、跨平台支付功能的应用。

适合场景

  • 电子商务应用
  • 订阅计费
  • 应用内购买
  • 数字服务付款
  • 在线票务

主要特点

  • 支持卡片和移动钱包
  • 多平台兼容性
  • 与 pub 的简单集成
  • 安全的令牌处理
  • 实时交易状态
  • 跨平台支持

适合对象

  • 移动和网页电子商务应用
  • 使用 Paymob 的开发者
  • 需要全球支付选项的应用
  • 初创企业正在构建数字市场
  • 需要快速付款设置的项目

使用建议

  • 需要 Paymob 账户和 API 密钥
  • 生产环境需要适当的错误处理
  • 取决于Paymob后端的稳定性
  • 可能需要额外的UI自定义
  • 仅限Paymob支持的地区

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。


🚀 Flutter Paymob — Accept Payments with Zero Hassle

Integrate Paymob card & wallet payments inside your Flutter app with ease. Secure, fast, and ready for production.


📥 Installation

Just add to your pubspec.yaml:

flutter_paymob: ^latest_version

🔧 Setup & Initialization

Before your app runs, initialize:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await FlutterPaymob.instance.initialize(
    apiKey: "YOUR_PAYMOB_API_KEY",
    integrationID: 123456,         // Card integration ID
    walletIntegrationId: 654321,   // Wallet integration ID
    iFrameID: 789012,              // Paymob iframe ID
  );

  runApp(const MyApp());
}

⚡ Quick Usage Guide

Pay with Card 💳
await FlutterPaymob.instance.payWithCard(
  title: Text("Card Payment"), // Optional - Custom title AppBar
  appBarColor: Colors.blueAccent, // Optional - Custom AppBar color
  context: context,
  currency: "EGP", 
  amount: 150, 
  onPayment: (response) {
    if (response.success) {
      print("🎉 Payment Success! TxID: ${response.transactionID}");
    } else {
      print("❌ Payment Failed: ${response.message}");
    }
  },
);
Pay with Wallet 📱
await FlutterPaymob.instance.payWithWallet(
title: Text("Card Payment"), // Optional - Custom title AppBar
appBarColor: Colors.blueAccent, // Optional - Custom AppBar color
  context: context,
  currency: "EGP",
  amount: 150,
  number: "01010101010",
  onPayment: (response) {
    if (response.success) {
      print("🎉 Wallet Payment Successful");
    } else {
      print("❌ Wallet Payment Failed");
    }
  },
);

💡 Response Object Breakdown

Field Type Meaning
success bool Was the payment successful?
transactionID String? Unique ID for the transaction
responseCode String? Numeric response from Paymob API
message String? Description / message from Paymob

🧪 Test Credentials

Type Number / PIN Expiry CVV OTP
Card 5123 4567 8901 2346 12/25 123 -
Wallet 01010101010 - - 123456

🚨 Important Notes

  • Webhook integration is a must! Always verify transactions on your backend with Paymob webhooks to prevent fraud.
  • Customize UI elements (title, appBarColor) to match your brand.
  • Use sandbox keys during development to avoid live charges.
  • Error Handling: Always wrap payment calls with try-catch to gracefully handle network or API failures.
  • Logging: Log transaction attempts and responses for debugging and auditing.
  • Localization: You can customize strings/messages in your app UI to support multiple languages.
  • Security: Never expose your API keys or sensitive info in the client code; keep them safe on the server when possible.

🔄 Handling Payment States

The onPayment callback triggers on success, failure, or cancellation. Use the response.success boolean and response.message to determine the payment state and update your UI accordingly.


🛠️ Troubleshooting

  • Blank iframe or webview?

    • Check your internet connection.
    • Make sure your iFrame ID and payment tokens are valid and not expired.
    • Verify your Paymob account and integration settings.
  • PlatformException about view creation?

    • Make sure you are using the latest webview_flutter package compatible with your Flutter version.
    • Avoid creating multiple instances of the webview controller simultaneously.
  • Payment not completing or stuck?

    • Confirm your API credentials and integration IDs.
    • Enable verbose logging if available to inspect requests and responses.

🔗 Useful Links


📞 Contact

Need help or want to customize? Reach out to me: Ahmed Hosni - LinkedIn


Happy coding & smooth payments! 🎉


所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。