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.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:any_payment_webview/any_payment_webview.dart';

void main() {
  runApp(const PaymentExampleApp());
}

class PaymentExampleApp extends StatelessWidget {
  const PaymentExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Any Payment WebView Example',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const ExampleHomeScreen(),
    );
  }
}

class ExampleHomeScreen extends StatelessWidget {
  const ExampleHomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Payment Example")),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                builder: (_) => AnyPaymentWebView(
                  url: "https://example.com/payment",
                  successKeyword: "success",
                  failKeyword: "failed",
                  onUrlChanged: (url) {
                    debugPrint("🔄 Navigating to: $url");
                  },
                  onPaymentResult: (status) {
                    debugPrint("💳 Payment status: $status");
                    if (status == PaymentStatus.success) {
                      ScaffoldMessenger.of(context).showSnackBar(
                        const SnackBar(content: Text("✅ Payment Successful")),
                      );
                    } else if (status == PaymentStatus.failed) {
                      ScaffoldMessenger.of(context).showSnackBar(
                        const SnackBar(content: Text("❌ Payment Failed")),
                      );
                    }
                  },
                ),
              ),
            );
          },
          child: const Text("Open Payment WebView"),
        ),
      ),
    );
  }
}
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