foloosi_plugins 1.0.15 copy "foloosi_plugins: ^1.0.15" to clipboard
foloosi_plugins: ^1.0.15 copied to clipboard

A Flutter plugin for making payments via Foloosi Payment Gateway. Fully supports Android and iOS.

example/lib/main.dart

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

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  TextEditingController amountTextField = TextEditingController();
  final GlobalKey<ScaffoldState> key = GlobalKey<ScaffoldState>();
  var output = '';

  /// Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    if (amountTextField.text.trim().isNotEmpty) {
      try {
        var initData = {
          "merchantKey": "Your Merchant Key",
          "customColor": "#1E8449",
        };
        await FoloosiPlugins.init(json.encode(initData));

        FoloosiPlugins.setLogVisible(true);
        var res = {
          "orderId": "521",
          "orderDescription": "Order Description",
          "orderAmount": double.parse(amountTextField.text),
          "state": "",
          "postalCode": "",
          "country": "ARE",
          "currencyCode": "AED",
          "customerUniqueReference": "",
          "customer": {
            "name": "Foloosi Test",
            "email": "tester@foloosi.com",
            "mobile": "501234567",
            "code": "",
            "address": "",
            "city": "",
          },
        };
        var result = await FoloosiPlugins.makePayment(json.encode(res));
        // var referenceToken = "";
        // var result = await FoloosiPlugins.makePaymentWithReferenceToken(referenceToken);
        debugPrint("Payment Response: $result");

      } on Exception catch (exception) {
        exception.runtimeType;
      }
    } else {
      debugPrint("Error: Please enter amount");
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        key: key,
        appBar: AppBar(
          backgroundColor: Colors.blue,
          title: const Text('Foloosi Example',
              style: TextStyle(color: Colors.white)),
        ),
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                margin: const EdgeInsets.all(20),
                child: TextField(
                  controller: amountTextField,
                  keyboardType: TextInputType.text,
                  decoration:
                      const InputDecoration(hintText: "Enter the amount"),
                ),
              ),
              GestureDetector(
                onTap: () {
                  initPlatformState();
                },
                child: Container(
                  margin: const EdgeInsets.all(20),
                  height: 50,
                  color: Colors.blue,
                  child: const Center(
                    child: Text(
                      "Proceed Payment",
                      style: TextStyle(color: Colors.white, fontSize: 18),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
130
points
42
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for making payments via Foloosi Payment Gateway. Fully supports Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on foloosi_plugins