Flutter Community: iframe_cashpay_plugin


pub package

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

alt iframe_cashpay_plugin

Platform Support


Getting Started

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


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

  iframe_cashpay_plugin: ^2.0.9


import 'package:iframe_cashpay_plugin/iframe_cashpay_plugin.dart';
import 'package:iframe_cashpay_plugin/CashPayButton.dart';

class PaySampleAppState extends State<PaySampleApp> {

  Future<String> sendItems(itemList) async {
    //Send itemList for yor server and post CreateOrder.
    //iframeURL returned from Response CreateOrder
    //Documentation https://documenter.getpostman.com/view/29850098/2s9YXcd5Fd
    //String iframeURL = "**********************************************************";
    return iframeURL;

  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        backgroundColor: Colors.white,
        body: ListView(children: [
          CashPayButton(width:MediaQuery.of(context).size.width ,onTap: () async {
            await sendItems({
                "itemName": "كتاب",
                "amount": 2000,
                "itemName": "ساعة",
                "amount": 5000,
            }).then((iframeURL) => showModalBottomSheet(
                context: context,
                isDismissible: false,
                shape: const RoundedRectangleBorder(
                  borderRadius: BorderRadius.vertical(
                    top: Radius.circular(30.0),
                isScrollControlled: true,
                builder: (BuildContext context) {
                  return Container(
                      padding: const EdgeInsets.only(
                          left: 10.0, right: 10.0, top: 10.0),
                      height: MediaQuery.of(context).size.height * 0.7,
                      //IframeCashPay widget displays the Cash E-wallet payment iframe.
                      /// This widget IframeCashPay displays the Cash E-wallet payment iframe.
                      /// @param iframeURL .
                      /// @param onConfirmPayment.
                      /// @param onCancel.
                      /// @param onError.
                      /// @return message onConfirmPayment or onCancel or onError.
                      /// Example:
                      /// ```
                      ///  IframeCashPay( iframeURL: "https://########",
                      ///    onConfirmPayment: onConfirmPayment,
                      ///    onCancel: onCancel,
                      ///    onError: onError,);
                      /// ```
                      child: IframeCashPay(
                        iframeURL: iframeURL,
                        onConfirmPayment: onConfirmPayment,
                        onCancel: onCancel,
                        onError: onError,

  //Await for iFrameCashPay
  onConfirmPayment(message) {
    //After Confirmatin from iFrame Returned message {NEEDTOCHECK or Confirmation}.
    //if(message.messsage==NEEDTOCHECK || message.messsage==Confirmation)
    //Here use CheckOrderStatus to check order status.
    //Documentation https://documenter.getpostman.com/view/29850098/2s9YXcd5Fd

//Await for iFrameCashPay
  onCancel(message) {
    //After Cancel from iFrameCashPay.

//Await for iFrameCashPay
  onError(message) {
    //After return Error from iFrameCashPay.