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

A Flutter plugin for making payments via razorpay, paystack, paytm and flutterwave Payment Gateway for accepting online payments in Flutter app.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:uni_payments/methods/googlepay_service.dart';
import 'package:uni_payments/uni_payments.dart';
import 'package:uni_payments_example/helpers/helpers.dart';
import 'package:uni_payments_example/services/services.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        key: _scaffoldkey,
        backgroundColor: Colors.white,
        appBar: AppBar(
          backgroundColor: Colors.white,
          elevation: 0.0,
        ),
        body: Column(
          children: [
            Helpers().titleText(),
            Helpers().sizedBox(20.0, 0.0),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                InkWell(
                  onTap: () async {
                    await Services().callRazorPayService(_scaffoldkey);
                  },
                  child: Container(
                    height: 150,
                    width: 150,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(15),
                      color: Colors.white,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey.withOpacity(0.5),
                          blurRadius: 7,
                          offset: Offset(4, 6),
                        ),
                      ],
                    ),
                    padding: const EdgeInsets.all(8.0),
                    child: Image.asset("assets/images/razorpay.png"),
                  ),
                ),
                SizedBox(
                  width: 15,
                ),
                InkWell(
                  onTap: () async {
                    UniPaymentResponse uniPaymentResponse =
                        await Services().callPayStackService(context: context);

                    if (uniPaymentResponse.paymentStatus) {
                      Helpers().snackBar(
                          _scaffoldkey, true, "Paystack Payment Success");
                    } else {
                      Helpers().snackBar(
                          _scaffoldkey, false, "Paystack Payment Failure");
                    }
                  },
                  child: Container(
                    height: 150,
                    width: 150,
                    padding: const EdgeInsets.all(8.0),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(15),
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey.withOpacity(0.5),
                          blurRadius: 7,
                          offset: Offset(4, 6),
                        ),
                      ],
                    ),
                    child: Image.asset("assets/images/paystack.png"),
                  ),
                ),
              ],
            ),
            Helpers().sizedBox(20.0, 0.0),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                InkWell(
                  onTap: () async {
                    await Services().callPayTmService(_scaffoldkey);
                  },
                  child: Container(
                    height: 150,
                    width: 150,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(15),
                      color: Colors.white,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey.withOpacity(0.5),
                          blurRadius: 7,
                          offset: Offset(4, 6),
                        ),
                      ],
                    ),
                    padding: const EdgeInsets.all(8.0),
                    child: Image.asset("assets/images/paytm.png"),
                  ),
                ),
                SizedBox(
                  width: 15,
                ),
                InkWell(
                  onTap: () async {
                    await Services().callFlutterWaveService(
                      context: context,
                      key: _scaffoldkey,
                    );
                  },
                  child: Container(
                    height: 150,
                    width: 150,
                    padding: const EdgeInsets.all(8.0),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(15),
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey.withOpacity(0.5),
                          blurRadius: 7,
                          offset: Offset(4, 6),
                        ),
                      ],
                    ),
                    child: Image.asset("assets/images/flutterwave.png"),
                  ),
                ),
              ],
            ),
            Helpers().sizedBox(20.0, 0.0),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                InkWell(
                  onTap: () async {},
                  child: Container(
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(15),
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey.withOpacity(0.5),
                          blurRadius: 7,
                          offset: Offset(4, 6),
                        ),
                      ],
                    ),
                    child: UniPayments.uniPaymentGooglePayButton(
                      paymentConfigurationAsset: 'ENTER_ASSET_PATH',
                      height: 150,
                      width: 150,
                      uniPaymentItemStatus: UniPaymentItemStatus.pending,
                      uniPaymentItemTypes: UniPaymentItemTypes.item,
                      payableAmount: "ENTER_AMOUNT_HERE",
                      uniPaymentGoogleButtonStyle:
                          UniPaymentGoogleButtonStyle.flat,
                      uniPaymentGoogleButtonType:
                          UniPaymentGoogleButtonType.donate,
                      paymentLabel: "ENTER_LABLE_PAYMENT",
                      failureListener: (UniPaymentResponse paymentResponse) {
                        Helpers().snackBar(
                            _scaffoldkey, false, paymentResponse.message);
                      },
                      successListener: (UniPaymentResponse paymentResponse) {
                        Helpers().snackBar(
                            _scaffoldkey, true, paymentResponse.message);
                      },
                      onPressed: () {
                        print("Universal Google Pay Button Pressed");
                      },
                    ),
                  ),
                ),
                // Helpers().sizedBox(0.0, 15.0),
                // InkWell(
                //   onTap: () async {},
                //   child: Container(
                //     decoration: BoxDecoration(
                //       color: Colors.white,
                //       borderRadius: BorderRadius.circular(15),
                //       boxShadow: [
                //         BoxShadow(
                //           color: Colors.grey.withOpacity(0.5),
                //           blurRadius: 7,
                //           offset: Offset(4, 6),
                //         ),
                //       ],
                //     ),
                //     child: UniPayments.uniPaymentGooglePayButton(
                //       paymentConfigurationAsset: 'json/gpay.json',
                //       height: 150,
                //       width: 150,
                //       uniPaymentItemStatus: UniPaymentItemStatus.pending,
                //       uniPaymentItemTypes: UniPaymentItemTypes.item,
                //       payableAmount: "ENTER_AMOUNT_HERE",
                //       paymentLabel: "ENTER_LABLE_PAYMENT",
                //       failureListener: (UniPaymentResponse paymentResponse) {
                //         Helpers().snackBar(
                //             _scaffoldkey, false, paymentResponse.message);
                //       },
                //       successListener: (UniPaymentResponse paymentResponse) {
                //         Helpers().snackBar(
                //             _scaffoldkey, true, paymentResponse.message);
                //       },
                //       onPressed: () {
                //         print("Universal Google Pay Button Pressed");
                //       },
                //     ),
                //   ),
                // ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
13
likes
50
pub points
0%
popularity

Publisher

unverified uploader

A Flutter plugin for making payments via razorpay, paystack, paytm and flutterwave Payment Gateway for accepting online payments in Flutter app.

Homepage
Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, flutter_paystack, flutter_web_plugins, flutterwave, http, pay, paytm, razorpay_flutter

More

Packages that depend on uni_payments