Flutter eGHL Sdk

A eGHL packages for Flutter project.

⚠️ eGHL Flutter SDK now only Implement ECR function!!

Features ✨

  • Ecr Sale
  • Ecr Void
  • Ecr Refund
  • Ecr Settlement
  • Ecr Last Settlement

Flutter

Import the package in your code:

import 'package:flutter_eghl_ecr/flutter_eghl_ecr.dart';

Android

In android please add this in manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.your.app">
   <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

iOS

  1. Platform version has to be at least 11.0. Modify ios/Podfile and update accordingly.
platform :ios, '11.0'

Remove the # heading if the line starts with it.

Macos

  1. Platform version has to be at least 10.15. Modify macos/Podfile and update accordingly.

    platform :osx, '10.15'
    

    Remove the # heading if the line starts with it.

  2. Set the minimum deployment target of the macOS to 10.15. Use XCode to open macos/Runner.xcworkspace .

  3. Follow the iOS instructions and modify Info.plist accordingly.

  4. add below details to your macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements

    <key>com.apple.security.network.client</key> 
    true
    

Simple usage

// your Eghl public PEM format key
  final String _publicKeyPath = "";

  // your Eghl private PEM format key
  final String _privateKeyPath = "";

  // your Eghl url
  final String url = "";

  // Eghl MID
  final String merchantID = "";

  // Eghl TID
  final String terminalID = "";

  void main() {
    EghlEcrSdk.init(
      publicKeyPath: _publicKeyPath,
      privateKeyPath: _privateKeyPath,
      url: url,
      merchantID: merchantID,
      terminalID: terminalID,
    );
  }

  // get Eghl instance
  final sdk = EghlSdk.instance;
  // check eghl network is work or not
   await sdk.networkCheck();

ercSale

// notify Eghl terminal sale
sdk.ecrSale(amount: 4.5, operatorID: "LISHII")

Fields in ecrSale

Name Type Description
amount String (Required) Transaction Amount Eg. 10.50
aperatorID String (Optional) Operator ID in this transaction
customField String(Optional) Eg: "{"ecr_invoice_number":"ECR20211028153155_01"}"

ercVoid

// void transaction
sdk.ecrVoid(amount: 4.5);

Fields in ecrVoid

Name Type Description
amount String (Required) Transaction Amount Eg. 10.50
operatorID String (Optional) Operator ID in this transaction
orgTxnRef String (Optional) transaction reference for void
txnTraceID String (Optional) unique ID to identify each transaction request
customField String(Optional) Eg: "{"terminal_invoice_number":"007821"}"

ercRefund

// refund the transaction
sdk.ecrRefund(amount: 4.5, operatorID: "LSHII");

Fields in ecrRefund

Name Type Description
amount String (Required) Transaction Amount Eg. 10.50
operatorID String (Optional) Operator ID in this transaction
orgTxnRef String (Optional) transaction reference for refund
txnTraceID String (Optional) unique ID to identify each transaction request
productCode String (Optional) provided by GHL/e-pay. More details see Appendix
customField String(Optional) Eg: "{"ecr_invoice_number":"ECR20211028153155_01"}"

ecrSettlement

// notify Eghl terminal show settlement
sdk.ecrSettlement();

ecrLastSettlement

// notify Eghl terminal show last settlement
sdk.ecrLastSettlement();

Eghl Response Code

Response Code Response Message
0 Successful
XT Timeout
01-99 Error from response message from MAH Host
B0 The transaction timed out from Bank’s end
C0 The transaction timed out from Extended Device’ end
C1 Card Not Supported
C2 Maximum Amount Exceeded
C3 No transaction found (eg:Invalid invoice number)
C4 EMV related error (eg: Card declined)
C5 Transaction already voided
C6 Extended Device Memory Full
C7 Transaction cancelled
C8 Invalid card input’s entry mode.
C9 Settlement must be perform before proceed.
CA Communication error
CB Batch empty
CC Settlement Failed
D1 CRC failed (eg. Make sure Device’s DateTime is correct with actual,
and input request message is correct)
D2 Invalid message format
D3 Invalid command ID
D4 Invalid source ID/destination ID
D5 Missing tag
D6 No Acknowledgement for last transaction response
D7 Get Last Transaction Failed
D8 Print Day Total Report failed. It may due to invalid Report Date input;
or there is no sales performed on selected date
E1 Encryption Fail
E2 Decryption Fail
E3 KCV Mismatch
E4 Device ID not available
E5 Initial Key Fail
E6 Session Key Fail
E7 Missing Key
E8 Invalid TID
E9 Invalid MID
EA Transaction Pending
S0 JsonStr is empty!
S1 Please upload your private key first
S2 Response JSON parsing failed
S3 Communication error
S4 JSON parsing failed. Please check if your JSON format is correct
S6 Request json is null or not valid json
S7 Invalid signature
S8 pubkeyPath is null, please upload your public
S9 Response JSON parsing failed
SA Communication error
SC JSON parsing failed. Please check if your json format is correct
SD MsgType cannot be empty
SE POSDateTime cannot be empty
SF POSDateTime should be number and lenght should be 14
SG Msgtype can only be one of these: 'Sale', 'Void','Refund','LastTxn','Settlement','LastSettle
SH TxnType cannot be empty and can only be one of 'ECRPMT'
SJ Amount cannot be empty
SK Amount must be greater than 0 and less than 999999.99
SL Amount consists of numbers only
SM Customfield1 and RetTxnRef cannot both be empty
X1 Your input string is not a valid json , Please check
X2 Your input string is invalid signature , Please check signature
X3 Your input string should have MsgType,please check
X4 Your input string should have MerchantID,please check
X5 Your input string should have TerminalID,please check
X6 Your input string should have Amount,please check
X7 Your input string cann't covert to XMPP request,please check
X8 Your input MID/TID cann't map any XMPPID,please check
XA XMPPGW Could not create XMPP Connection
XB Your input string cann't covert to XMPP request,please check
XC Your input MID/TID cann't map any XMPPID,please check
XD Pos terminal return json invalid,it should have param: xmpp_id
XE No received POS terminal return xmpp msg
XF Your MID/TID map xmppid not online
XG XMPPGW server error,it cann't connect to Ejabber server to get roster
XH ECR terminal not answer echo.Please check it's online
XJ ECR terminal not XMPPGW friends,Please set in the ejab first
1 SERVICE UNAVAILABLE, PLEASE TRY AGAIN
2 INVALID ACCOUNT / MOBILE NUMBER
3 MOBILE NOT PREPAID
4 MOBILE NOT ACTIVE
5 MOBILE IS BARRED
13 ACCOUNT LIMIT EXCEEDED
14 UNMATCHING TRANSACTION FROM TELCO
16 TRANSACTION AREADY REVERSED FROM TELCO
18 REVERSAL PERIOD EXCEEDED
20 ACCOUNT INSUFFICIENT CREDIT
21 TRANSACTION REJECTED
22 TRANSACTION DECLINED
23 TRANSACTION IN PROCESS
27 INVALID MAC
30 Card Not Found
31 KAD TIDAK SAH, KOD 1
32 KAD TIDAK SAH, KOD 2
33 KAD TIDAK SAH, KOD 3
34 KAD TIDAK SAH, KOD 4
35 AUTO RELOAD CARD
36 CARD EXPIRED
37 KAD TIDAK SAH, KOD 7
38 KAD TIDAK SAH, KOD 8
39 KAD TIDAK SAH, KOD 9
40 REJECTED, INVALID VALUE
43 REJECTED, VALUE BELOW MINIMUM
44 REJECTED, VALUE ABOVE MAXIMUM
45 REJECTED, VALUE NOT IN STEP
50 KAD TIDAK SAH, KOD 10
51 KAD TIDAK SAH, KOD 11
52 KAD TIDAK SAH, KOD 12
53 KAD TIDAK SAH, KOD 13
54 INSUFFICIENT BALANCE
55 KAD TIDAK SAH, KOD 15
56 TRANSACTION EXCEEDED
57 DATA NOT FOUND
58 KAD TIDAK SAH, KOD 18
59 READER ERROR
60 CONTACT CUSTOMER SERVICES
I0040 - PIN TXN Disabled
I0041 - ETU TXN Disabled
I0042 - PMT TXN Disabled
61 DAILY LIMIT EXCEEDED
62 TRANSACTION FAILED PLEASE TRY AGAIN
70 INVALID MESSAGE FORMAT
71 COMMUNICATION ERROR
72 RESPONSE TIMEOUT
73 REVERSAL THRESHOLD EXCEEDED
74 SSL AUTHENTICATION FAILED
79 INACTIVE ACCOUNT
80 INVALID TERMINAL
81 TERMINAL REFUSED
82 CREDIT LIMIT EXCEEDED
83 NO PRODUCT FOUND
84 FEATURE UNAVAILABLE
85 OUT OF STOCK
86 INVALID VALUE
87 DUPLICATE TXN REFERENCE

Whenever received "DUPLICATE TXN REFERENCE" (response code 87),

Client should not retry the same request with same RetTxnRef again.

If client continuous retry, system will block the client’s account.
88 INVALID CARD NUMBER FORMAT
90 UNMATCHED TRANSACTION
93 REVERSAL ALREADY PROCESSED
94 REVERSAL PENDING
95 AMOUNT MISMATCH
99 TRANSACTION FAILED
RK INVALID MAC
T1 LOGIN IS REQUIRED
T2 INVALID TNG CRYPTO
T5 INVALID TNG CARD
T6 INSUFFICIENT BALANCE
T7 DAILY LIMIT EXCEEDED
T8 PURSE LIMIT EXCEED
PN Transaction is still pending for status

Common Question ❔

I have setup all correct setting but stil got timeout response

Please make sure your terminal is connected succeed.

Credits

Thanks to Dart-Basic-Utils provide crypto utils