fundlypay 0.0.7 copy "fundlypay: ^0.0.7" to clipboard
fundlypay: ^0.0.7 copied to clipboard

A Flutter library by Fundly Pay for seamless and standardized payment integration across multiple payment methods — simplifying invoice collection, reconciliation, and settlement.

example/lib/main.dart

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

final credential = {
  "username": "demo_user",
  "password": "dummy_password_123",
  "source": "FUNDLY_CUSTOMER_APP",
};

// Alternative: identify the customer with full payment details instead of `erpDetails`.
// Only one of `paymentDetails` or `erpDetails` may be provided.
// final paymentDetails = {
//   "distributorId": "D00000000XX",
//   "chemistId": "R00000000YY",
//   "paymentType": "INVOICE_COLLECT",
//   "payableAmount": 1000.0,
//   "invoice": [
//     {"invoiceNumber": "INV1001", "paidAmount": 600.0},
//     {"invoiceNumber": "INV1002", "paidAmount": 400.0},
//   ],
// };

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FundlyPay Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Color(0XFF16558B)),
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final _erpCodeController = TextEditingController(text: "orion");
  final _erpCustomerIdController = TextEditingController(text: "FOR-DIST-4-1");
  final _partyCodeController = TextEditingController();

  @override
  void dispose() {
    _erpCodeController.dispose();
    _erpCustomerIdController.dispose();
    _partyCodeController.dispose();
    super.dispose();
  }

  void _startPayment() {
    final erpCode = _erpCodeController.text.trim();
    final erpCustomerId = _erpCustomerIdController.text.trim();
    final partyCode = _partyCodeController.text.trim();
    if (erpCode.isEmpty || erpCustomerId.isEmpty) {
      ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(
          content: Text('Enter both ERP code and ERP customer id'),
        ),
      );
      return;
    }

    Navigator.of(context).push(
      MaterialPageRoute(
        builder:
            (_) => Scaffold(
              body: FundlyPayService(
                fundlyPayObject: {
                  "credential": credential,
                  "erpDetails": {
                    "erpCode": erpCode,
                    "erpCustomerId": erpCustomerId,
                    if (partyCode.isNotEmpty) "partyCode": partyCode,
                  },
                },
                onEvent: (event, data) {
                  debugPrint("FundlyPayService Event: $event -> $data");
                  if (event == FundlyPayEvent.HOME) {
                    Navigator.of(context).popUntil((route) => route.isFirst);
                  } else if (event == FundlyPayEvent.CLOSE) {
                    if (Navigator.of(context).canPop()) {
                      Navigator.of(context).pop();
                    }
                  }
                },
              ),
            ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('FundlyPay Demo')),
      body: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            TextField(
              controller: _erpCodeController,
              decoration: const InputDecoration(
                labelText: 'ERP Code',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 16),
            TextField(
              controller: _erpCustomerIdController,
              decoration: const InputDecoration(
                labelText: 'ERP Customer Id',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 16),
            TextField(
              controller: _partyCodeController,
              decoration: const InputDecoration(
                labelText: 'Party Code (optional)',
                border: OutlineInputBorder(),
              ),
            ),
            const SizedBox(height: 16),
            ElevatedButton(onPressed: _startPayment, child: const Text('Pay')),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
153
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter library by Fundly Pay for seamless and standardized payment integration across multiple payment methods — simplifying invoice collection, reconciliation, and settlement.

Homepage

License

unknown (license)

Dependencies

file_picker, flutter, flutter_image_compress, flutter_inappwebview, http, image_picker, path_provider, permission_handler, share_plus, url_launcher

More

Packages that depend on fundlypay