iframe_cashpay_plugin 0.0.8 copy "iframe_cashpay_plugin: ^0.0.8" to clipboard
iframe_cashpay_plugin: ^0.0.8 copied to clipboard

outdated

A plugin to add payments iframe_cashpay to your flutter application..

iframe_cashpay_plugin #

iframe_cashpay_plugin. A plugin to add payments iframe_cashpay to your Flutter application.

Platform Support #

Android

Getting Started #

Before you start, create an APIs with the payment providers and follow the setup instructions: https://documenter.getpostman.com/view/17550185/2s93XzwN9o

Usage #

To start using this plugin, add iframe_cashpay_plugin as a dependency in your pubspec.yaml file:

dependencies:
  pay: ^0.0.8

Example #

import 'package:iframe_cashpay_plugin/iframe_cashpay_plugin.dart';

class PaySampleAppState extends State<PaySampleApp> {
  List<BeneficiaryList> beneficiaryList = [];
  bool check1 = false;
  String desc = "";
  String result = "";

  //Token returned from Response login
  //Documentation https://documenter.getpostman.com/view/17550185/2s93XzwN9o
  String token = "**********************************************************";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        backgroundColor: Colors.white,
        body: ListView(children: [
          CheckboxListTile(
            title: const Text(
              'ساعة 5000ريال',
              textDirection: TextDirection.rtl,
            ),
            value: check1,
            onChanged: (bool? value) {
              onChackWristwatch(value!, 5000, "ساعة,");
            },
            secondary: const Icon(Icons.help),
          ),
          ElevatedButton(
              child: const Text('الدفع عبر كاش باي'),
              onPressed: () async {
                (beneficiaryList.isNotEmpty)
                    ? await createOrder(token)
                        .then((value) => value.ResultCode == 1
                            ? showModalBottomSheet<void>(
                                context: context,
                                isScrollControlled: true,
                                builder: (BuildContext context) {
                                  return Container(
                                      height:
                                          MediaQuery.of(context).size.height *
                                              0.7,
                                      decoration: const BoxDecoration(
                                        color: Colors.white,
                                        borderRadius: BorderRadius.only(
                                          topLeft: Radius.circular(25.0),
                                          topRight: Radius.circular(25.0),
                                        ),
                                      ),
                                      //BottomSheetIframeCashPay SDK to use iFrame CashPay
                                      child: IframeCashPay(
                                        iframeURL: value.iframeURL,
                                        onConfirmPayment: onConfirmPayment,
                                      ));
                                })
                            : null)
                    : null;
              }),
          Text(result)
        ]));
  }

//Await for iFrameCashPay to return message {NEEDTOCHECK or Confirmation}
  onConfirmPayment(message) {
    if (message.message == "Confirmation" || message.message == "NEEDTOCHECK") {
      //After Confirmatin from iFrame Returned message {NEEDTOCHECK or Confirmation}.
      //Here use CheckOrderStatus to check order status.
      //Documentation https://documenter.getpostman.com/view/17550185/2s93XzwN9o
      Navigator.pop(context);
    }
    setState(() {
      result = message.message;
    });
  }
}
5
likes
0
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin to add payments iframe_cashpay to your flutter application..

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_webview_plugin

More

Packages that depend on iframe_cashpay_plugin