moneyhash_payment 0.0.1 copy "moneyhash_payment: ^0.0.1" to clipboard
moneyhash_payment: ^0.0.1 copied to clipboard

outdated

MoneyHash is a Super-API infrastructure for payment orchestration and revenue operations in emerging markets. We provide a single integration to your network of pay-in and pay-out providers, and vario [...]

example/lib/main.dart

import 'dart:async';

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  MoneyHashPaymentResult? _result;
  TextEditingController? paymentIdTextEditController =
      TextEditingController(text: "9ep3xXZ");
  String? errorText;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    MoneyHashPaymentResult? result;
    try {
      result = await MoneyhashPayment.startPaymentFlow(
          paymentIdTextEditController!.text);
    } on PlatformException {
      // Handle the errors
    }

    // 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(() {
      _result = result;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MoneyHash Example App'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              TextField(
                onChanged: (value) {
                  setState(() {
                    errorText = null;
                  });
                },
                controller: paymentIdTextEditController,
                decoration: InputDecoration(
                    errorText: errorText,
                    border: const OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10)))),
              ),
              const SizedBox(height: 16),
              ElevatedButton(
                onPressed: () {
                  if (paymentIdTextEditController!.text.isNotEmpty) {
                    initPlatformState();
                  } else {
                    setState(() {
                      errorText = "Please enter payment id";
                    });
                  }
                },
                child: const Text("Click"),
              ),
              const SizedBox(height: 32),
              Text(
                  'Payment Status: ${_result?.result?.transaction?.status ?? "no payment status"}\n'),
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
0
points
200
downloads

Publisher

verified publishermoneyhash.io

Weekly Downloads

MoneyHash is a Super-API infrastructure for payment orchestration and revenue operations in emerging markets. We provide a single integration to your network of pay-in and pay-out providers, and various other services that you can utilize and combine to build a unique custom payment stack.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on moneyhash_payment