ippo_pay 1.0.1 copy "ippo_pay: ^1.0.1" to clipboard
ippo_pay: ^1.0.1 copied to clipboard

Ippopay Payment Flutter SDK.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:ippo_pay/ippo_pay.dart';

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

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

class _MyAppState extends State<MyApp> {
  TextEditingController orderIdTextField = new TextEditingController();
  final key = new GlobalKey<ScaffoldState>();
  GlobalKey<ScaffoldMessengerState> rootScaffoldMessengerKey =
      GlobalKey<ScaffoldMessengerState>();

  @override
  void initState() {
    super.initState();
    // initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    if (orderIdTextField.text.trim().isNotEmpty) {
      try {
        IppoPay.initSdk("LIVE_KEY");
        IppoPay.setLogVisible(true);
        var result = await IppoPay.makePayment(
            json.encode({"order_id": orderIdTextField.text}));
        print(result);
      } on Exception catch (exception) {
        print(exception);
      }
    } else {
      // key.currentState.showSnackBar(new SnackBar(
      WidgetsBinding.instance.addPostFrameCallback(
        (_) => rootScaffoldMessengerKey.currentState?.showSnackBar(
          new SnackBar(
            content: new Text("Please enter order id"),
          ),
        ),
      );
    }
    // Platform messages may fail, so we use a try/catch PlatformException.

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      // _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      scaffoldMessengerKey: rootScaffoldMessengerKey,
      home: Scaffold(
        key: key,
        appBar: AppBar(
          title: const Text('Ippopay Example'),
        ),
        body: Container(
          child: Center(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  margin: EdgeInsets.all(20),
                  child: TextField(
                    controller: orderIdTextField,
                    decoration: InputDecoration(hintText: "Enter the Order id"),
                  ),
                ),
                InkWell(
                  onTap: () {
                    initPlatformState();
                  },
                  child: Container(
                    margin: EdgeInsets.all(20),
                    height: 50,
                    color: Colors.blue,
                    child: Center(
                      child: Text(
                        "Proceed Payment",
                        style: TextStyle(color: Colors.white, fontSize: 18),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
8
likes
140
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

Ippopay Payment Flutter SDK.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ippo_pay