mono_flutter

pub package

A Flutter plugin integrating the official android and ios SDK for Mono (financial data Platform) (https://mono.co/)

Mono Connect.js is a quick and secure way to link bank accounts to Mono from within your app. Mono Connect is a drop-in framework that handles connecting a financial institution to your app (credential validation, multi-factor authentication, error handling, etc). It works on mobile and web.

For accessing customer accounts and interacting with Mono's API (Identity, Transactions, Income, DirectPay) use the server-side Mono API. For complete information about Mono Connect, head to the docs. https://docs.mono.co/docs/ .

Getting Started

Register on the Mono website and get your public and secret keys. Setup a server to exchange tokens to access user financial data with your Mono secret key.

Screenshot Screenshot

Web Screenshot

Web Screenshot

Preview

you can checkout a web preview here https://wiseminds.github.io/mono-flutter

Usage

Import package:mono_flutter/mono_flutter.dart and use the methods in MonoFlutter class.

For web support add the following to index.html :

<script src="https://connect.withmono.com/connect.js"></script>
 <script>
   function setupMonoConnect(key, reference, config, authCode, paymentMode) {
     const options = {
       key,
       reference,
       onSuccess: onSuccess,
       onEvent: onEvent,
       onClose: onClose,
       onLoad: onLoad
     };
     if(paymentMode) {
           options.scope = "payment";
       }
     const MonoConnect = new Connect(options);
     const configJson = JSON.parse(config ?? `{}`);

     MonoConnect.setup(configJson);
     
     if(authCode && String(authCode).length > 0) {
       MonoConnect.reauthorise(authCode);
     }

     MonoConnect.open()
    
   }
 </script>

Example:

import 'package:mono_flutter/mono_flutter.dart';

void main() async {
    runApp(App());
}

class App extends StatelessWidget {

    @override
    Widget build(BuildContext context) {
        return  Center(
          child: RaisedButton(
        child: Text('launch mono'),
        onPressed: () {
          MonoFlutter().launch(
              context,
              'YOUR_PUBLIC_KEY_HERE',
              // authCode: 'code_sGjE1Zh48lFR8vr3FkrD',
              reference: DateTime.now().millisecondsSinceEpoch.toString(),
              config: jsonEncode({
                "selectedInstitution": {
                  "id": "5f2d08bf60b92e2888287703",
                  "auth_method": "internet_banking"
                }
              }),
              onEvent: (event, data) {
                print('event: $event, data: $data');
              },
              onClosed: () {
                print('Modal closed');
              },
              onLoad: () {
                print('Mono loaded successfully');
              },
              onSuccess: (code) {
                print('Mono Success $code');
              },
            );
    }
}

Checkout the example project for full implementation

###Reauthorization Passing the authCode to the launch command This package will automatically call connect.reauthorise(authCode)

  connect.reauthorise(authCode);

Reauth code is a mono generated code for the account you want to re-authenticate, which must be requested by your server and sent to your frontend where you can pass it to mono connect widget. Mono connect widget will ask for the required information and re-authenticate the user's account and notify your server. Once the reauthorisation is complete, the mono.events.account_reauthorized event will be sent to your webhook, following with mono.events.account_updated once the synced data is available.

Customizations

For a custom page or with a dialog, use the MonoFlutterWebView widget, but this is not supported on the web.

 showDialog(
      context: context,
      builder: (c) => MonoWebView(
        apiKey: 'test_pk_qtys19MqGkmrkGk9RDjc',
        config: const {
          "selectedInstitution": {
            "id": "5f2d08bf60b92e2888287703",
            "auth_method": "internet_banking"
          }
        },
        reAuthCode: reAuthCode,
        onEvent: (event, data) {
          print('event: $event, data: $data');
        },
        onClosed: () {
          print('Modal closed');
        },
        onLoad: () {
          print('Mono loaded successfully');
        },
        onSuccess: (code) {
          print('Mono Success $code');
        },
      ),
    );