flutter_vella_checkout 0.1.4 copy "flutter_vella_checkout: ^0.1.4" to clipboard
flutter_vella_checkout: ^0.1.4 copied to clipboard

Vella payment Checkout for Flutter plugin with support for Android and iOS

example/lib/main.dart

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(VellaPayExample());
}

const String appName = 'VellaPayExample';

class VellaPayExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: appName,
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  HomePageState createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
  String email = 'taj@example.com';
  double amount = 10.00;
  String message = '';
  String name = 'Taje';
  String vellaKey = '';
  String reference = 'PAYXFBFBGYTJTTYJTTJ';
  String merchantId = '';
  String currency = 'NGN';
  final Map<String, dynamic> metaData = {
    'name': 'John Doe',
    'age': 25,
    'email': 'john.doe@example.com',
  };

  dynamic callbackResult;
  void callback(dynamic response) {
    callbackResult = response;
    message = response.message;
  }

  bool isClosed = false;
  void close() {
    isClosed = true;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Vella Example'),
      ),
      body: Padding(
        padding: EdgeInsets.symmetric(
          horizontal: MediaQuery.of(context).size.width / 8,
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              message,
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => VellaCheckout(
                      name: name,
                      email: email,
                      amount: amount,
                      reference: reference,
                      merchantId: merchantId,
                      currency: currency,
                      metadata: metaData,
                      vellakey: vellaKey,
                      onSuccess: (response) {
                        print('Success: $response');
                        // Handle success event
                      },
                      onError: (error) {
                        print('Error: $error');
                        // Handle error event
                      },
                      onClose: () {
                        print('Widget closed');
                        // Handle close event
                      },
                    ),
                  ),
                );
              },
              child: Text(
                'Pay',
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 16.0,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
110
pub points
33%
popularity

Publisher

unverified uploader

Vella payment Checkout for Flutter plugin with support for Android and iOS

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter, flutter_webview_plugin, webview_flutter

More

Packages that depend on flutter_vella_checkout