icash 0.1.1 copy "icash: ^0.1.1" to clipboard
icash: ^0.1.1 copied to clipboard

icash.io is flutter plugin that let's developer to integrate native icash payment method into their flutter application.

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> implements IcashInterface {
  TextEditingController textFieldController = TextEditingController();

  String _icashResult = "Pending";
  String _testPay = "";

  @override
  void initState() {
    super.initState();
    _testPay =
        "{vendor_key:'production_c2c0f0fa-061a-4745-a447-867d165cefc6',amount:10000,title:'Icash Test',description:'This is only for test',transaction_id:" +
            textFieldController.text +
            "}";
  }

  @override
  void onIcashSuccess(Map<String, String> _res) {
    print(_res);
    setState(() {
      _icashResult = _res.toString();
    });
  }

  @override
  void onIcashError(String _action) {
    print(_action + "_error");
    setState(() {
      _icashResult = _action;
    });
  }

  void doPayment(BuildContext _ctx) {
    try {
      iCashPayment _ipayment = iCashPayment(this);
      _ipayment.doPayment(_ctx,
          vendor_key: "production_f2df1e1c-640b-4508-90e0-ba1d2811a23c",
          amount: "1000",
          title: "Icash Test",
          description: "This is only for test",
          transaction_id: textFieldController.text);
    } on PlatformException {
      _icashResult = "Error 1";
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('iCash Payment Test App'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Padding(
                padding: const EdgeInsets.all(32.0),
                child: Text(_icashResult),
              ),
              Padding(
                padding: const EdgeInsets.all(32.0),
                child: TextField(
                  controller: textFieldController,
                  style: TextStyle(
                    fontSize: 24,
                    color: Colors.black,
                  ),
                  onChanged: (value) {
                    setState(() {
                      _testPay =
                          "{vendor_key:'production_f2df1e1c-640b-4508-90e0-ba1d2811a23c',amount:10000,title:'Icash Test',description:'This is only for test',transaction_id:" +
                              textFieldController.text +
                              "}";
                    });
                  },
                ),
              ),
              Builder(
                builder: (context) => RaisedButton(
                  onPressed: () {
                    doPayment(context);
                  },
                  child: Text('Pay 10'),
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(2.0),
                child: Text(_testPay),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
40
points
33
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

icash.io is flutter plugin that let's developer to integrate native icash payment method into their flutter application.

Homepage

License

unknown (license)

Dependencies

flutter, http, webview_flutter

More

Packages that depend on icash

Packages that implement icash