ibad 0.2.8 copy "ibad: ^0.2.8" to clipboard
ibad: ^0.2.8 copied to clipboard

discontinued
PlatformAndroidiOS

Flutter Package for integrating payment gateway across every android device above sdk 17 and iphone 6

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:ibad/ibad.dart';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

late Map<String, dynamic> data = {};
late String message = "";
late String referencenum = "";
late String status = "";
late var isgenerated = false;

final keycontroller = TextEditingController();
final amountcontroller = TextEditingController();
final referencenumbercontroller = TextEditingController();
final customeremailcontroller = TextEditingController();
final customernumbercontroller = TextEditingController();
final consumernamecontroller = TextEditingController();
final tokencontroller = TextEditingController();

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);

    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(body: Checkout(title: "Checkout")),
    );
  }
}

class Checkout extends StatefulWidget {
  Checkout({required this.title});
  final String title;

  @override
  _CheckoutState createState() => _CheckoutState();
}

class _CheckoutState extends State<Checkout> {
  @override
  void initState() {
    super.initState();

    keycontroller.text = "Your API Key";
    referencenumbercontroller.text = "123";
    amountcontroller.text = "123";
    isgenerated = false;
    customeremailcontroller.text = "abc@gmail.com";
    customernumbercontroller.text = "03*********";
    consumernamecontroller.text = "ABC";
  }

  int _radioValue = 1;

  void _handleRadioValueChange(int value) {
    setState(() {
      _radioValue = value;

      switch (_radioValue) {
        case 0:
          setState(() {
            isgenerated = true;
          });
          break;
        case 1:
          setState(() {
            isgenerated = false;
          });
          break;
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;

    return ListView(
      children: [
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              child: Column(
                children: [
                  Container(
                    margin: EdgeInsets.only(left: 5.0, top: 25.0, right: 5.0, bottom: 5.0),
                    child: TextField(
                      controller: keycontroller,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        labelText: "Key",
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
                    child: TextField(
                      controller: amountcontroller,
                      enableSuggestions: false,
                      autocorrect: false,
                      keyboardType: TextInputType.number,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        fillColor: Colors.white,
                        labelText: "Amount",
                      ),
                    ),
                  ),
                  Container(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          margin: EdgeInsets.symmetric(horizontal: 15.0,vertical: 5.0),
                          child: Text("Is Generated :", style: TextStyle(
                              fontWeight: FontWeight.bold,
                              fontSize: 18.0
                          )),
                        ),
                        ListTile(
                          title: Text('True'),
                          leading: Radio(
                            value: 0,
                            groupValue: _radioValue,
                            onChanged: (value) {
                              _handleRadioValueChange(0);
                            },
                          ),
                        ),
                        ListTile(
                          title: Text('False'),
                          leading: Radio(
                            value: 1,
                            groupValue: _radioValue,
                            onChanged: (value) {
                              _handleRadioValueChange(1);
                            },
                          ),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
                    child: TextField(
                      controller: referencenumbercontroller,
                      enableSuggestions: false,
                      autocorrect: false,
                      keyboardType: TextInputType.number,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        fillColor: Colors.white,
                        labelText: "Reference Number",
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
                    child: TextField(
                      controller: customeremailcontroller,
                      enableSuggestions: false,
                      autocorrect: false,
                      keyboardType: TextInputType.emailAddress,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        fillColor: Colors.white,
                        labelText: "Email",
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
                    child: TextField(
                      controller: customernumbercontroller,
                      enableSuggestions: false,
                      autocorrect: false,
                      keyboardType: TextInputType.number,
                      textInputAction: TextInputAction.next,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        fillColor: Colors.white,
                        labelText: "Phone",
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
                    child: TextField(
                      controller: consumernamecontroller,
                      enableSuggestions: false,
                      autocorrect: false,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        fillColor: Colors.white,
                        labelText: "Name",
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),
                    child: TextField(
                      controller: tokencontroller,
                      enableSuggestions: false,
                      autocorrect: false,
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        fillColor: Colors.white,
                        labelText: "Token",
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.all(25.0),
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(5.0),
                        color: Colors.blue),
                    child: FlatButton(
                        onPressed: () {
                          if (int.parse(amountcontroller.text) > 1000000) {
                            return;
                          }
                          data = {
                            'key': keycontroller.text,
                            'amount': int.parse(amountcontroller.text).abs().toString(),
                            'is_generated': isgenerated,
                            'reference_number': referencenumbercontroller.text,
                            'callback': 'callbackflutter',
                            'customer_email_address': customeremailcontroller.text,
                            'customer_phone_number': customernumbercontroller.text,
                            'token': tokencontroller.text,
                            'consumer_name': consumernamecontroller.text,
                          };

                          IbadCheckOut.initiateCheckOut(
                            url: "https://portal-dev.riteidentity.com/rn.html",
                            data: data,
                            context: context,
                            callBack: (args) {
                              keycontroller.text = "";
                              amountcontroller.text = "";
                              referencenumbercontroller.text = "";
                              customeremailcontroller.text = "";
                              customernumbercontroller.text = "";
                              consumernamecontroller.text = "";
                              var statusdata = args['status'].toString();
                              var referencenumber =
                              args['reference_number'];
                              var messagedata = args['message'];
                              setState(() {
                                status = statusdata;
                                referencenum = referencenumber;
                                message = messagedata;
                              });
                            },
                          );
                        },
                        child: Text("Pay Now")),
                  ),
                  Container(
                      width: width,
                      margin: EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          Text(
                            "Status: $status",
                            style: TextStyle(
                              fontSize: 18.0,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                          Text(
                            "Ref No: $referencenum",
                            style: TextStyle(
                              fontSize: 18.0,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                          Text(
                            "Message: $message",
                            style: TextStyle(
                              fontSize: 18.0,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                        ],
                      )
                  ),
                ],
              ),
            )
          ],
        )
      ],
    );
  }
}
0
likes
110
pub points
0%
popularity

Publisher

unverified uploader

Flutter Package for integrating payment gateway across every android device above sdk 17 and iphone 6

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, flutter_inappwebview

More

Packages that depend on ibad