eghlflutter 1.0.1 copy "eghlflutter: ^1.0.1" to clipboard
eghlflutter: ^1.0.1 copied to clipboard

outdated

A new Flutter plugin.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:eghlflutter/eghlflutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _eghlPaymentResult = 'Awaiting for payment.';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('eGHL Payment'),
        ),
        body: Container(
          child: Center (
            child: Column (
              mainAxisAlignment:  MainAxisAlignment.center,
              children: [
                Text(this._eghlPaymentResult),
                RaisedButton(
                  child: Text("Pay"),
                  onPressed: () {
                    _Pay(context);
                  },
                  color: Colors.amberAccent,
                  textColor: Colors.black,
                  padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                  splashColor: Colors.amber,
                ),
                RaisedButton(
                  child: Text("Card Pay"),
                  onPressed: () {
                    _CardPay(context);
                  },
                  color: Colors.amberAccent,
                  textColor: Colors.black,
                  padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                  splashColor: Colors.amber,
                )
              ],
            ),
          ),
        ),
      ),
    );
  }

  // ignore: non_constant_identifier_names
  void _Pay(BuildContext context) async {
    String result = '';
    String paymentId = 'SIT${new DateTime.now().millisecondsSinceEpoch}';

    try {
      Map<String, dynamic> payment = {
        'TransactionType': 'SALE',
        'Amount': '1.00',
        'CurrencyCode': 'MYR',
        'PaymentId': paymentId,
        'OrderNumber': paymentId,
        'PaymentDesc': 'Testing Payment',
        'PymtMethod': 'ANY',

        'CustName': 'somebody',
        'CustEmail': 'somebody@someone.com',
        'CustPhone': '0123456789',

        'MerchantReturnURL': 'SDK',
        'MerchantCallbackURL': 'SDK',

        'ServiceId': 'SIT',
        'Password': 'sit12345',
        'LanguageCode': 'EN',
        'PageTimeout': '600',
        'PaymentGateway': true,
        'EnableCardPage': false,
      };

      result = await Eghlflutter.executePayment(payment);
    } catch(e) {
      result = e.message;
    }

    setState(() {
      _eghlPaymentResult = result;
    });
  }

  // ignore: non_constant_identifier_names
  void _CardPay(BuildContext context) async {
    String result = '';
    try {
      result = await Eghlflutter.executeCardPayment();
    } catch (e) {
      result = e.message;
    }

    setState(() {
      _eghlPaymentResult = result;
    });
  }
}
0
likes
0
points
51
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on eghlflutter