flutter_fincra_checkout 0.0.2 copy "flutter_fincra_checkout: ^0.0.2" to clipboard
flutter_fincra_checkout: ^0.0.2 copied to clipboard

A community Flutter SDK wrapper for Fincra Checkout with in-app WebView support and custom transaction references.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Fincra Checkout Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const CheckoutExamplePage(),
    );
  }
}

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

  Future<void> _startPayment(BuildContext context) async {
    // In a real app, this URL is obtained from your backend by calling the Fincra API.
    // Ensure that you set a redirectUrl during the Fincra backend API call so that
    // Fincra redirects back with the status parameters appended.
    const mockCheckoutUrl =
        'https://sandbox-checkout.fincra.com/pay/your-unique-session-id';

    final result = await FincraCheckout.open(
      context,
      checkoutUrl: mockCheckoutUrl,
      redirectUrl: 'https://myapp.com/callback',
      appBarTitle: 'Fincra Payment',
    );

    if (context.mounted) {
      switch (result) {
        case FincraCheckoutSuccess():
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(
              content: Text(
                'Payment Successful! Ref: ${result.response.reference}',
              ),
              backgroundColor: Colors.green,
            ),
          );
          break;
        case FincraCheckoutError():
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(
              content: Text('Payment Failed: ${result.error.message}'),
              backgroundColor: Colors.red,
            ),
          );
          break;
        case FincraCheckoutCancelled():
          ScaffoldMessenger.of(context).showSnackBar(
            const SnackBar(
              content: Text('Payment Cancelled by User'),
              backgroundColor: Colors.orange,
            ),
          );
          break;
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Fincra SDK Example')),
      body: Center(
        child: ElevatedButton(
          onPressed: () => _startPayment(context),
          style: ElevatedButton.styleFrom(
            padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
          ),
          child: const Text('Pay with Fincra', style: TextStyle(fontSize: 18)),
        ),
      ),
    );
  }
}
1
likes
0
points
232
downloads

Publisher

unverified uploader

Weekly Downloads

A community Flutter SDK wrapper for Fincra Checkout with in-app WebView support and custom transaction references.

Repository (GitHub)
View/report issues

Topics

#fincra #payment #checkout #fintech #gateway

License

unknown (license)

Dependencies

flutter, webview_flutter

More

Packages that depend on flutter_fincra_checkout