any_payment_webview 1.0.0 copy "any_payment_webview: ^1.0.0" to clipboard
any_payment_webview: ^1.0.0 copied to clipboard

A Flutter package that allows displaying any payment URL in a WebView with callback on URL change and success/failure detection.

🧭 any_payment_webview #

platform

A lightweight and flexible Flutter package that helps you handle any payment flow inside a WebView with full control — including URL change callbacks, keyword-based success/failure detection, and real-time monitoring.


🚀 Features #

✅ Load any payment URL seamlessly inside a WebView.
✅ Detect success and failure automatically using keywords.
✅ Get real-time callback for every URL change.
✅ Fully customizable and works with any payment gateway (MyFatoorah, HyperPay, Tap, PayTabs, etc).
✅ Works on Android, iOS, and Web.


🧩 Installation #

Add the package to your pubspec.yaml:

dependencies:
  any_payment_webview: ^1.0.0

Then run:

flutter pub get

Import it in your Dart code:

import 'package:any_payment_webview/any_payment_webview.dart';

💡 Usage Example #

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (_) => AnyPaymentWebView(
      url: "https://example.com/checkout?id=12345",
      successKeyword: "payment-success",
      failKeyword: "payment-failed",
      onUrlChanged: (url) {
        print("🌐 Navigating to: $url");
      },
      onPaymentResult: (status) {
        switch (status) {
          case PaymentStatus.success:
            print("✅ Payment Successful");
            break;
          case PaymentStatus.failed:
            print("❌ Payment Failed");
            break;
          case PaymentStatus.pending:
            print("⏳ Payment Pending");
            break;
          case PaymentStatus.cancelled:
            print("🚫 Payment Cancelled");
            break;
        }
      },
    ),
  ),
);

⚙️ Parameters #

Parameter Type Required Description
url String The initial payment URL to load.
successKeyword String? Keyword to detect a successful payment (default: "success").
failKeyword String? Keyword to detect a failed payment (default: "failed").
onUrlChanged Function(String url)? Called whenever the WebView navigates to a new URL.
onPaymentResult Function(String status)? Called when success/failure keyword is detected.

🖥️ Platform Support #

Platform Supported Notes
Android Requires AndroidX and WebView permissions
iOS WKWebView enabled
Web ⚠️ Limited; depends on browser iframe behavior

📦 Example Project #

You can find a working example inside the example/ folder.

To run it:

cd example
flutter run

🧰 Dependencies #


💬 Author #

Alaa Nabil
👨‍💻 Flutter Developer | Mobile Engineer
🔗 GitHub
📧 Open to contributions and feedback!


If you like this package, please give it a star on pub.dev or GitHub!

2
likes
150
points
66
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package that allows displaying any payment URL in a WebView with callback on URL change and success/failure detection.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, webview_flutter

More

Packages that depend on any_payment_webview