Skip to content

Swerv-Ltd/swervpay_flutter

Repository files navigation

Flutter Widget for Swervpay

pub package License: MIT


Explore the docs »

X (Twitter) · Linkedin · Changelog

Installation

$ flutter pub add swervpay_widget

Configuration

Create a new instance of Swervpay with your secret_key and business_id:

import "package:swervpay_widget/swervpay_widget.dart";

Navigator.of(context).push(
    CupertinoPageRoute(
        builder: (c) => SwervpayView(
            sandbox: true,
            debugMode: true,
            key: const String.fromEnvironment('SWERV_PUBLIC_KEY', defaultValue: 'pk_dev_123'),
            businessId: const String.fromEnvironment('SWERV_BUSINESS_ID', defaultValue: 'bsn_123'),
            //checkoutId: 'hbnbbbbbb',
            data: SwervpayCheckoutDataModel(
                reference: DateTime.now().toString(),
                amount: 10000,
                description: 'description',
                currency: 'NGN',
            ),
            onSuccess: (response) {
                print(response);
            },
            onClose: () => print('closed'),
            onLoad: () => print('loaded'),
            onEvent: (value) => print(value),
        ),
    ),
);


// OR

await SwervpayWidget.launchWidget(
    context,
    sandbox: true,
    debugMode: true,
    key: const String.fromEnvironment('SWERV_PUBLIC_KEY', defaultValue: 'pk_dev_123'),
    businessId: const String.fromEnvironment('SWERV_BUSINESS_ID', defaultValue: 'bsn_123'),
    //checkoutId: 'hbnbbbbbb',
    data: SwervpayCheckoutDataModel(
        reference: DateTime.now().toString(),
        amount: 100,
        description: 'description',
        currency: 'NGN',
    ),
    onSuccess: (response) {
        print(response);
    },
    onClose: () => print('closed'),
    onLoad: () => print('loaded'),
    onEvent: (value) => print(value),
);

Replace <SWERV_PUBLIC_KEY> and <SWERV_BUSINESS_ID> with your actual secret key and business ID.

Documentation

See docs for widget here