foloosi 1.0.0 copy "foloosi: ^1.0.0" to clipboard
foloosi: ^1.0.0 copied to clipboard

outdated

Foloosi Payment Flutter SDK.

example/lib/main.dart

import 'dart:convert';

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

import 'package:flutter/services.dart';
import 'package:foloosi/foloosi.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>();

  @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 {
        await Foloosi.init(
            "your_merchant_key");
        Foloosi.setLogVisible(true);
        var res = {
          "orderId": "xmadfadg",
          "orderDescription": "hello world",
          "orderAmount": 100,
          "state": "india",
          "postalCode": "23366",
          "customColor":"",
          "country": "ARE",
          "currencyCode": "INR",
          "customer": {
            "name": "jhon",
            "email": "[email protected]",
            "mobile": "9876543210",
            "code": "91",
            "address": "hello check 123",
            "city": "chennai",
          }
        };

        var result = await Foloosi.makePayment(json.encode(res));
        print(result);
      } on Exception catch (exception) {}
    } else {
      // key.currentState.showSnackBar(new SnackBar(
      WidgetsBinding.instance.addPostFrameCallback(
        (_) => key.currentState.showSnackBar(
          new SnackBar(
            content: new Text("Please enter orderid"),
          ),
        ),
      );
    }
    // 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(
      home: Scaffold(
        key: key,
        appBar: AppBar(
          title: const Text('Foloosi 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),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

Foloosi Payment Flutter SDK.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on foloosi

Packages that implement foloosi