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

PlatformAndroid

OpenMoney payment gateway plugin for android. To know more about openmoney, visit https://open.money/products/payments

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_openmoney/flutter_openmoney.dart';
import 'package:fluttertoast/fluttertoast.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final FlutterOpenmoney flutterOpenmoney;

  @override
  void initState() {
    super.initState();

    flutterOpenmoney = FlutterOpenmoney();
    flutterOpenmoney.on(
      FlutterOpenmoney.eventPaymentSuccess,
      _handlePaymentSuccess,
    );
    flutterOpenmoney.on(
      FlutterOpenmoney.eventPaymentError,
      _handlePaymentError,
    );
  }

  void _initPayment() async {
    /// get from openmoney dashboard
    const accessKey = 'xxxxxxxx-xxxx-xxxx-xxxx-cfd6fc92bd19';

    /// Generated using openmoney create token api in server
    /// refer https://docs.bankopen.com/reference/generate-token
    const paymentToken = 'sb_pt_BUFJpEalhWmO6cm';
    final options = PaymentOptions(accessKey, paymentToken);

    try {
      flutterOpenmoney.initPayment(options);
    } catch (e) {
      debugPrint('Error: e');
    }
  }

  void _handlePaymentSuccess(PaymentSuccessResponse response) {
    Fluttertoast.showToast(
      msg: 'SUCCESS: ${response.paymentId}',
      toastLength: Toast.LENGTH_LONG,
    );
  }

  void _handlePaymentError(PaymentFailureResponse response) {
    Fluttertoast.showToast(
      msg: 'ERROR: ${response.code} - ${response.message}',
      toastLength: Toast.LENGTH_LONG,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('FlutterOpenmoney Plugin example app'),
        ),
        body: Center(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(
                onPressed: _initPayment,
                child: const Text('initPayment'),
              )
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
30
downloads

Publisher

verified publisherappist.com

Weekly Downloads

OpenMoney payment gateway plugin for android. To know more about openmoney, visit https://open.money/products/payments

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

eventify, flutter

More

Packages that depend on flutter_openmoney

Packages that implement flutter_openmoney