패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소ahmedhosni803/flutter_paymob

flutter_paymob

ahmedhosni803/flutter_paymob open-source repository details.

flutter_paymob 프로젝트 이미지
스타
2
포크
3
최근 푸시(UTC)
2025. 8. 13.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.


🚀 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! 🎉


Ahmed Hosni GitHub avatar
GitHub 작성자

Ahmed Hosni ↗

언어DartObjective-CJavaSwiftShellKotlin

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 5 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗