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

eGHL Flutter plugin

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:eghlflutter/eghlflutter.dart';

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

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

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

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

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

  // ignore: non_constant_identifier_names
  void _Pay(BuildContext context) async {
    String result = '';
    String paymentId = 'SIT${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,
        'TriggerReturnURL': false,
        'NumOfRequery': 1,
      };

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(_eghlPaymentResult),
              ElevatedButton(
                child: const Text("Pay"),
                onPressed: () {
                  _Pay(context);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
130
pub points
69%
popularity

Publisher

unverified uploader

eGHL Flutter plugin

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on eghlflutter