fortenew commit test
parent
e224df165a
commit
c397062da2
|
|
@ -47,7 +47,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "kz.com.aman.kassa"
|
applicationId "kz.com.aman.kassa"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 31
|
targetSdkVersion 35
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/LaunchTheme"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:exported="true">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,14 @@ class MainActivity : FlutterActivity() {
|
||||||
if (call.argument<Long>("amount") != null) {
|
if (call.argument<Long>("amount") != null) {
|
||||||
amount = call.argument<Long>("amount")!!.toLong()
|
amount = call.argument<Long>("amount")!!.toLong()
|
||||||
}
|
}
|
||||||
|
val packageName = call.argument<String>("packageName").toString()
|
||||||
val operationParameters = createOperationParameters(token)
|
val operationParameters = createOperationParameters(token)
|
||||||
startOperation(OperationType.PAYMENT, JsonForExternalCall.getPaymentCardJson(operationParameters.authToken, amount.toString()))
|
val body = JsonForExternalCall.getRefundCardJson(operationParameters.authToken, terminalId, operDay, transNum, amount)
|
||||||
|
startOperation(
|
||||||
|
OperationType.REFUND,
|
||||||
|
body,
|
||||||
|
packageName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun operationRefund(call: MethodCall) {
|
private fun operationRefund(call: MethodCall) {
|
||||||
|
|
@ -79,8 +85,14 @@ class MainActivity : FlutterActivity() {
|
||||||
val operDay = call.argument<String>("operDay").toString()
|
val operDay = call.argument<String>("operDay").toString()
|
||||||
val transNum = call.argument<String>("transNum").toString()
|
val transNum = call.argument<String>("transNum").toString()
|
||||||
val amount = call.argument<String>("amount").toString()
|
val amount = call.argument<String>("amount").toString()
|
||||||
|
val packageName = call.argument<String>("packageName").toString()
|
||||||
val operationParameters = createOperationParameters(token)
|
val operationParameters = createOperationParameters(token)
|
||||||
startOperation(OperationType.REFUND, JsonForExternalCall.getRefundCardJson(operationParameters.authToken, terminalId, operDay, transNum, amount))
|
val body = JsonForExternalCall.getRefundCardJson(operationParameters.authToken, terminalId, operDay, transNum, amount)
|
||||||
|
startOperation(
|
||||||
|
OperationType.REFUND,
|
||||||
|
body,
|
||||||
|
packageName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun operationReversal(call: MethodCall) {
|
private fun operationReversal(call: MethodCall) {
|
||||||
|
|
@ -89,15 +101,24 @@ class MainActivity : FlutterActivity() {
|
||||||
val operDay = call.argument<String>("operDay").toString()
|
val operDay = call.argument<String>("operDay").toString()
|
||||||
val transNum = call.argument<String>("transNum").toString()
|
val transNum = call.argument<String>("transNum").toString()
|
||||||
val operationParameters = createOperationParameters(token)
|
val operationParameters = createOperationParameters(token)
|
||||||
val body = JsonForExternalCall.getReversalJson(operationParameters.authToken, terminalId, operDay, transNum);
|
val packageName = call.argument<String>("packageName").toString()
|
||||||
println(body)
|
val body = JsonForExternalCall.getReversalJson(operationParameters.authToken, terminalId, operDay, transNum)
|
||||||
startOperation(OperationType.REVERSAL, body)
|
startOperation(
|
||||||
|
OperationType.REVERSAL,
|
||||||
|
body,
|
||||||
|
packageName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun operationCloseDay(call: MethodCall) {
|
private fun operationCloseDay(call: MethodCall) {
|
||||||
val token = call.argument<String>("token").toString()
|
val token = call.argument<String>("token").toString()
|
||||||
|
val packageName = call.argument<String>("packageName").toString()
|
||||||
val operationParameters = createOperationParameters(token)
|
val operationParameters = createOperationParameters(token)
|
||||||
startOperation(OperationType.CLOSE_DAY, JsonForExternalCall.getCloseDayJson(operationParameters.authToken))
|
startOperation(
|
||||||
|
OperationType.CLOSE_DAY,
|
||||||
|
JsonForExternalCall.getCloseDayJson(operationParameters.authToken),
|
||||||
|
packageName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,12 +126,13 @@ class MainActivity : FlutterActivity() {
|
||||||
return OperationParameters(authToken = token, operDay = operDay, terminalId = terminalId, transNum = transNum)
|
return OperationParameters(authToken = token, operDay = operDay, terminalId = terminalId, transNum = transNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startOperation(operationType: OperationType, inputJsonData: String?) {
|
private fun startOperation(
|
||||||
|
operationType: OperationType,
|
||||||
|
inputJsonData: String?,
|
||||||
|
packageName: String) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
intent.component = ComponentName("ru.m4bank.softpos.halyk", "ru.m4bank.feature.externalapplication.ExternalApplicationActivity")
|
intent.component = ComponentName(packageName, "ru.m4bank.feature.externalapplication.ExternalApplicationActivity")
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
// intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
// intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||||
intent.putExtra(externalOperationTypeKey, operationType.code)
|
intent.putExtra(externalOperationTypeKey, operationType.code)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ object JsonForExternalCall {
|
||||||
"instrument": "CARD",
|
"instrument": "CARD",
|
||||||
"amountData" : {
|
"amountData" : {
|
||||||
"currencyCode": "348",
|
"currencyCode": "348",
|
||||||
"amount": "6000",
|
"amount": "$amount",
|
||||||
"amountExponent": "2"
|
"amountExponent": "2"
|
||||||
},
|
},
|
||||||
"parentTransaction" : {
|
"parentTransaction" : {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/services/BankService.dart';
|
import 'package:aman_kassa_flutter/core/services/BankService.dart' as bank;
|
||||||
|
import 'package:aman_kassa_flutter/core/services/ForteService.dart' as forte;
|
||||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
import 'package:aman_kassa_flutter/core/services/blue_print_service.dart';
|
||||||
|
|
||||||
|
|
@ -37,6 +38,8 @@ class LocatorInjector {
|
||||||
_log.d('Initializing DataService Service');
|
_log.d('Initializing DataService Service');
|
||||||
locator.registerLazySingleton<DataService>(() => DataService());
|
locator.registerLazySingleton<DataService>(() => DataService());
|
||||||
_log.d('Initializing BankService Service');
|
_log.d('Initializing BankService Service');
|
||||||
locator.registerLazySingleton<BankService>(() => BankService());
|
locator.registerLazySingleton<bank.BankService>(() => bank.BankService());
|
||||||
|
_log.d('Initializing Forte Service');
|
||||||
|
locator.registerLazySingleton<forte.ForteService>(() => forte.ForteService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
||||||
|
|
||||||
import 'halyk/halyk_close_day_dao.dart';
|
import 'forte_close_day_dao.dart';
|
||||||
|
|
||||||
class CloseDayData {
|
class CloseDayData {
|
||||||
final String? title;
|
final String? title;
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
/// result : {"code":"0","description":"Successfully completed"}
|
||||||
|
/// transactions : {"transaction":[{"type":"PAYMENT","instrument":"CARD","amount":"6000","terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}},{"type":"REFUND","instrument":"CARD","amount":"4500","terminalId":"123321","operationDay":"4","transactionNumber":"70","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"},"parentTransaction":{"terminalId":"123321","operationDay":"4","transactionNumber":"69"}}]}
|
||||||
|
/// closeDayResults : {"reconciliationResult":[{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]}
|
||||||
|
|
||||||
|
class ForteCloseDayDao {
|
||||||
|
ResultBean? result;
|
||||||
|
TransactionsBean? transactions;
|
||||||
|
CloseDayResultsBean? closeDayResults;
|
||||||
|
|
||||||
|
ForteCloseDayDao({ this.result, this.closeDayResults, this.transactions});
|
||||||
|
|
||||||
|
static ForteCloseDayDao? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ForteCloseDayDao forteCloseDayDaoBean = ForteCloseDayDao();
|
||||||
|
forteCloseDayDaoBean.result = ResultBean.fromMap(map['result']);
|
||||||
|
forteCloseDayDaoBean.transactions = TransactionsBean.fromMap(map['transactions']);
|
||||||
|
forteCloseDayDaoBean.closeDayResults = CloseDayResultsBean.fromMap(map['closeDayResults']);
|
||||||
|
return forteCloseDayDaoBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"result": result,
|
||||||
|
"transactions": transactions,
|
||||||
|
"closeDayResults": closeDayResults,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// reconciliationResult : [{"hostResultCode":"000","hostResultDescription":"Success","terminalExternalId":"example_terminal_id"}]
|
||||||
|
|
||||||
|
class CloseDayResultsBean {
|
||||||
|
List<ReconciliationResultBean>? reconciliationResult;
|
||||||
|
|
||||||
|
static CloseDayResultsBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
CloseDayResultsBean closeDayResultsBean = CloseDayResultsBean();
|
||||||
|
closeDayResultsBean.reconciliationResult = List.empty()..addAll(
|
||||||
|
(map['reconciliationResult'] as List).map((o) => ReconciliationResultBean.fromMap(o))
|
||||||
|
);
|
||||||
|
return closeDayResultsBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"reconciliationResult": reconciliationResult,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// hostResultCode : "000"
|
||||||
|
/// hostResultDescription : "Success"
|
||||||
|
/// terminalExternalId : "example_terminal_id"
|
||||||
|
|
||||||
|
class ReconciliationResultBean {
|
||||||
|
String? hostResultCode;
|
||||||
|
String? hostResultDescription;
|
||||||
|
String? terminalExternalId;
|
||||||
|
|
||||||
|
static ReconciliationResultBean fromMap(Map<String, dynamic> map) {
|
||||||
|
ReconciliationResultBean reconciliationResultBean = ReconciliationResultBean();
|
||||||
|
reconciliationResultBean.hostResultCode = map['hostResultCode'];
|
||||||
|
reconciliationResultBean.hostResultDescription = map['hostResultDescription'];
|
||||||
|
reconciliationResultBean.terminalExternalId = map['terminalExternalId'];
|
||||||
|
return reconciliationResultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"hostResultCode": hostResultCode,
|
||||||
|
"hostResultDescription": hostResultDescription,
|
||||||
|
"terminalExternalId": terminalExternalId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// transaction : [{"type":"PAYMENT","instrument":"CARD","amount":"6000","terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}},{"type":"REFUND","instrument":"CARD","amount":"4500","terminalId":"123321","operationDay":"4","transactionNumber":"70","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"},"parentTransaction":{"terminalId":"123321","operationDay":"4","transactionNumber":"69"}}]
|
||||||
|
|
||||||
|
class TransactionsBean {
|
||||||
|
List<TransactionBean>? transaction;
|
||||||
|
|
||||||
|
static TransactionsBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
TransactionsBean transactionsBean = TransactionsBean();
|
||||||
|
transactionsBean.transaction = List.empty()..addAll(
|
||||||
|
(map['transaction'] as List).map((o) => TransactionBean.fromMap(o))
|
||||||
|
);
|
||||||
|
return transactionsBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"transaction": transaction,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// type : "PAYMENT"
|
||||||
|
/// instrument : "CARD"
|
||||||
|
/// amount : "6000"
|
||||||
|
/// terminalId : "123321"
|
||||||
|
/// operationDay : "4"
|
||||||
|
/// transactionNumber : "69"
|
||||||
|
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}
|
||||||
|
|
||||||
|
class TransactionBean {
|
||||||
|
String? type;
|
||||||
|
String? instrument;
|
||||||
|
num amount = 0;
|
||||||
|
int? terminalId;
|
||||||
|
int? operationDay;
|
||||||
|
int? transactionNumber;
|
||||||
|
InstrumentSpecificDataBean? instrumentSpecificData;
|
||||||
|
|
||||||
|
static TransactionBean fromMap(Map<String, dynamic> map) {
|
||||||
|
TransactionBean transactionBean = TransactionBean();
|
||||||
|
transactionBean.type = map['type'];
|
||||||
|
transactionBean.instrument = map['instrument'];
|
||||||
|
transactionBean.amount = map['amount'] ?? 0;
|
||||||
|
transactionBean.terminalId = map['terminalId'];
|
||||||
|
transactionBean.operationDay = map['operationDay'];
|
||||||
|
transactionBean.transactionNumber = map['transactionNumber'];
|
||||||
|
transactionBean.instrumentSpecificData = InstrumentSpecificDataBean.fromMap(map['instrumentSpecificData']);
|
||||||
|
return transactionBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"type": type,
|
||||||
|
"instrument": instrument,
|
||||||
|
"amount": amount,
|
||||||
|
"terminalId": terminalId,
|
||||||
|
"operationDay": operationDay,
|
||||||
|
"transactionNumber": transactionNumber,
|
||||||
|
"instrumentSpecificData": instrumentSpecificData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// authorizationCode : "000000"
|
||||||
|
/// rrn : "1234567890"
|
||||||
|
/// cardholderName : "IVAN IVANOV"
|
||||||
|
/// maskedPan : "123456******7890"
|
||||||
|
|
||||||
|
class InstrumentSpecificDataBean {
|
||||||
|
String? authorizationCode;
|
||||||
|
String? rrn;
|
||||||
|
String? cardholderName;
|
||||||
|
String? maskedPan;
|
||||||
|
|
||||||
|
static InstrumentSpecificDataBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
|
||||||
|
instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
|
||||||
|
instrumentSpecificDataBean.rrn = map['rrn'];
|
||||||
|
instrumentSpecificDataBean.cardholderName = map['cardholderName'];
|
||||||
|
instrumentSpecificDataBean.maskedPan = map['maskedPan'];
|
||||||
|
return instrumentSpecificDataBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"authorizationCode": authorizationCode,
|
||||||
|
"rrn": rrn,
|
||||||
|
"cardholderName": cardholderName,
|
||||||
|
"maskedPan": maskedPan,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// code : "0"
|
||||||
|
/// description : "Successfully completed"
|
||||||
|
|
||||||
|
class ResultBean {
|
||||||
|
int? code;
|
||||||
|
String? description;
|
||||||
|
|
||||||
|
ResultBean({this.code, this.description});
|
||||||
|
|
||||||
|
static ResultBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ResultBean resultBean = ResultBean();
|
||||||
|
resultBean.code = map['code'];
|
||||||
|
resultBean.description = map['description'];
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"code": code,
|
||||||
|
"description": description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
class FortePosSession {
|
||||||
|
const FortePosSession(
|
||||||
|
{this.login,
|
||||||
|
this.token,
|
||||||
|
this.serverTime,
|
||||||
|
this.tokenTimeout,
|
||||||
|
this.result});
|
||||||
|
|
||||||
|
final String? login;
|
||||||
|
final String? token;
|
||||||
|
final DateTime? serverTime;
|
||||||
|
final int? tokenTimeout;
|
||||||
|
final ResultBean? result;
|
||||||
|
|
||||||
|
static FortePosSession fromJson(Map<String, dynamic> data) => FortePosSession(
|
||||||
|
login: data['login'],
|
||||||
|
token: data['token'],
|
||||||
|
result: ResultBean.fromMap(data['result']),
|
||||||
|
serverTime: data['ServerTime'] != null
|
||||||
|
? new DateFormat("dd.MM.yyyy HH:mm:ss ZZZ").parse(data['ServerTime'])
|
||||||
|
: null,
|
||||||
|
tokenTimeout: data['TokenTimeout']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ServerTime : "25.06.2021 13:18:00 GMT+06:00"
|
||||||
|
/// ResultCode : "040"
|
||||||
|
/// ResultStr : "Unknown operator login. Check the correctness of the data or contact support."
|
||||||
|
/// Response : {"Code":"040","Description":"Unknown operator login. Check the correctness of the data or contact support."}
|
||||||
|
|
||||||
|
class ResultBean {
|
||||||
|
String? ServerTime;
|
||||||
|
String? ResultCode;
|
||||||
|
String? ResultStr;
|
||||||
|
ResponseBean? Response;
|
||||||
|
|
||||||
|
static ResultBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ResultBean resultBean = ResultBean();
|
||||||
|
resultBean.ServerTime = map['ServerTime'];
|
||||||
|
resultBean.ResultCode = map['ResultCode'];
|
||||||
|
resultBean.ResultStr = map['ResultStr'];
|
||||||
|
resultBean.Response = ResponseBean.fromMap(map['Response']);
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"ServerTime": ServerTime,
|
||||||
|
"ResultCode": ResultCode,
|
||||||
|
"ResultStr": ResultStr,
|
||||||
|
"Response": Response,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Code : "040"
|
||||||
|
/// Description : "Unknown operator login. Check the correctness of the data or contact support."
|
||||||
|
|
||||||
|
class ResponseBean {
|
||||||
|
String? Code;
|
||||||
|
String? Description;
|
||||||
|
|
||||||
|
static ResponseBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ResponseBean responseBean = ResponseBean();
|
||||||
|
responseBean.Code = map['Code'];
|
||||||
|
responseBean.Description = map['Description'];
|
||||||
|
return responseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() => {
|
||||||
|
"Code": Code,
|
||||||
|
"Description": Description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,155 @@
|
||||||
|
/// result : {"code":"0","description":"Successfully completed","hostResponse":{"code":"0","description":"Successfully completed"}}
|
||||||
|
/// transaction : {"terminalId":"123321","operationDay":"4","transactionNumber":"69","instrumentSpecificData":{"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}}
|
||||||
|
|
||||||
|
class ForteResponse {
|
||||||
|
ResultBean? result;
|
||||||
|
TransactionBean? transaction;
|
||||||
|
|
||||||
|
ForteResponse({this.result, this.transaction});
|
||||||
|
|
||||||
|
static ForteResponse? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ForteResponse forteResponseBean = ForteResponse();
|
||||||
|
forteResponseBean.result = ResultBean.fromMap(map['result']);
|
||||||
|
forteResponseBean.transaction = TransactionBean.fromMap(map['transaction']);
|
||||||
|
return forteResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() =>
|
||||||
|
{
|
||||||
|
"result": result,
|
||||||
|
"transaction": transaction,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// terminalId : "123321"
|
||||||
|
/// operationDay : "4"
|
||||||
|
/// transactionNumber : "69"
|
||||||
|
/// instrumentSpecificData : {"authorizationCode":"000000","rrn":"1234567890","cardholderName":"IVAN IVANOV","maskedPan":"123456******7890"}
|
||||||
|
|
||||||
|
class TransactionBean {
|
||||||
|
int? terminalId;
|
||||||
|
int? operationDay;
|
||||||
|
int? transactionNumber;
|
||||||
|
InstrumentSpecificDataBean? instrumentSpecificData;
|
||||||
|
|
||||||
|
static TransactionBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
TransactionBean transactionBean = TransactionBean();
|
||||||
|
transactionBean.terminalId = map['terminalId'];
|
||||||
|
transactionBean.operationDay = map['operationDay'];
|
||||||
|
transactionBean.transactionNumber = map['transactionNumber'];
|
||||||
|
transactionBean.instrumentSpecificData = InstrumentSpecificDataBean.fromMap(map['instrumentSpecificData']);
|
||||||
|
return transactionBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() =>
|
||||||
|
{
|
||||||
|
"terminalId": terminalId,
|
||||||
|
"operationDay": operationDay,
|
||||||
|
"transactionNumber": transactionNumber,
|
||||||
|
"instrumentSpecificData": instrumentSpecificData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// authorizationCode : "000000"
|
||||||
|
/// rrn : "1234567890"
|
||||||
|
/// cardholderName : "IVAN IVANOV"
|
||||||
|
/// maskedPan : "123456******7890"
|
||||||
|
|
||||||
|
class InstrumentSpecificDataBean {
|
||||||
|
String? authorizationCode;
|
||||||
|
String? rrn;
|
||||||
|
String? cardholderName;
|
||||||
|
String? maskedPan;
|
||||||
|
|
||||||
|
static InstrumentSpecificDataBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
InstrumentSpecificDataBean instrumentSpecificDataBean = InstrumentSpecificDataBean();
|
||||||
|
instrumentSpecificDataBean.authorizationCode = map['authorizationCode'];
|
||||||
|
instrumentSpecificDataBean.rrn = map['rrn'];
|
||||||
|
instrumentSpecificDataBean.cardholderName = map['cardholderName'];
|
||||||
|
instrumentSpecificDataBean.maskedPan = map['maskedPan'];
|
||||||
|
return instrumentSpecificDataBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() =>
|
||||||
|
{
|
||||||
|
"authorizationCode": authorizationCode,
|
||||||
|
"rrn": rrn,
|
||||||
|
"cardholderName": cardholderName,
|
||||||
|
"maskedPan": maskedPan,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// code : "0"
|
||||||
|
/// description : "Successfully completed"
|
||||||
|
/// hostResponse : {"code":"0","description":"Successfully completed"}
|
||||||
|
|
||||||
|
class ResultBean {
|
||||||
|
int? code;
|
||||||
|
String? description;
|
||||||
|
HostResponseBean? hostResponse;
|
||||||
|
ErrorResponseBean? errorData;
|
||||||
|
|
||||||
|
ResultBean({this.code, this.description});
|
||||||
|
|
||||||
|
static ResultBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ResultBean resultBean = ResultBean();
|
||||||
|
resultBean.code = map['code'];
|
||||||
|
resultBean.description = map['description'];
|
||||||
|
resultBean.hostResponse = HostResponseBean.fromMap(map['hostResponse']);
|
||||||
|
resultBean.errorData = ErrorResponseBean.fromMap(map['errorData']);
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() =>
|
||||||
|
{
|
||||||
|
"code": code,
|
||||||
|
"description": description,
|
||||||
|
"hostResponse": hostResponse,
|
||||||
|
"errorData": errorData,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// code : "0"
|
||||||
|
/// description : "Successfully completed"
|
||||||
|
|
||||||
|
class HostResponseBean {
|
||||||
|
String? code;
|
||||||
|
String? description;
|
||||||
|
|
||||||
|
static HostResponseBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
HostResponseBean hostResponseBean = HostResponseBean();
|
||||||
|
hostResponseBean.code = map['code'];
|
||||||
|
hostResponseBean.description = map['description'];
|
||||||
|
return hostResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() =>
|
||||||
|
{
|
||||||
|
"code": code,
|
||||||
|
"description": description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class ErrorResponseBean {
|
||||||
|
int? code;
|
||||||
|
String? description;
|
||||||
|
|
||||||
|
static ErrorResponseBean? fromMap(Map<String, dynamic>? map) {
|
||||||
|
if (map == null) return null;
|
||||||
|
ErrorResponseBean errorResponseBean = ErrorResponseBean();
|
||||||
|
errorResponseBean.code = map['code'];
|
||||||
|
errorResponseBean.description = map['description'];
|
||||||
|
return errorResponseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toJson() =>
|
||||||
|
{
|
||||||
|
"code": code,
|
||||||
|
"description": description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
|
||||||
|
import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
||||||
|
|
||||||
|
import 'halyk_close_day_dao.dart';
|
||||||
|
|
||||||
|
class CloseDayData {
|
||||||
|
final String? title;
|
||||||
|
final num? totalAmount;
|
||||||
|
final int? totalCount;
|
||||||
|
final num? paymentAmount;
|
||||||
|
final int? paymentCount;
|
||||||
|
final num? refundAmount;
|
||||||
|
final int? refundCount;
|
||||||
|
final num? cancelAmount;
|
||||||
|
final int? cancelCount;
|
||||||
|
|
||||||
|
final List<TransactionBean>? items;
|
||||||
|
CloseDayData({
|
||||||
|
this.title,
|
||||||
|
this.items,
|
||||||
|
this.totalAmount, this.totalCount,
|
||||||
|
this.paymentAmount, this.paymentCount,
|
||||||
|
this.refundAmount, this.refundCount,
|
||||||
|
this.cancelAmount, this.cancelCount
|
||||||
|
});
|
||||||
|
|
||||||
|
static CloseDayData fromJson(Map<String, dynamic> json) {
|
||||||
|
return CloseDayData(
|
||||||
|
title: json['title'],
|
||||||
|
totalAmount: json['totalAmount'],
|
||||||
|
totalCount: json['totalCount'],
|
||||||
|
paymentAmount: json['paymentAmount'],
|
||||||
|
paymentCount: json['paymentCount'],
|
||||||
|
refundAmount: json['refundAmount'],
|
||||||
|
refundCount: json['refundCount'],
|
||||||
|
cancelAmount: json['cancelAmount'],
|
||||||
|
cancelCount: json['cancelCount'],
|
||||||
|
items: (json['items'] as List).map((e) => TransactionBean.fromMap(e)).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Map<String, dynamic> toJson() =>
|
||||||
|
{
|
||||||
|
'title': title,
|
||||||
|
'totalAmount': totalAmount,
|
||||||
|
'totalCount': totalCount,
|
||||||
|
'paymentAmount': paymentAmount,
|
||||||
|
'paymentCount': paymentCount,
|
||||||
|
'refundAmount': refundAmount,
|
||||||
|
'refundCount': refundCount,
|
||||||
|
'cancelAmount': cancelAmount,
|
||||||
|
'cancelCount': cancelCount,
|
||||||
|
'items': items?.map((e) => e.toJson()).toList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ const String SettingsViewRoute = "SettingsViewRoute";
|
||||||
const String QrViewRoute = "QrViewRoute";
|
const String QrViewRoute = "QrViewRoute";
|
||||||
const String BankViewRoute = "BankViewRoute";
|
const String BankViewRoute = "BankViewRoute";
|
||||||
const String BankSettingViewRoute = "BankSettingViewRoute";
|
const String BankSettingViewRoute = "BankSettingViewRoute";
|
||||||
|
const String ForteSettingViewRoute = "ForteSettingViewRoute";
|
||||||
|
|
||||||
|
|
||||||
const String SettingsPrinterRoute = "SettingsPrinterRoute";
|
const String SettingsPrinterRoute = "SettingsPrinterRoute";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/close_day_data.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/close_day_data.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/close_day_data.dart';
|
||||||
import 'package:aman_kassa_flutter/views/bank_setting/bank_setting_view.dart';
|
import 'package:aman_kassa_flutter/views/bank_setting/bank_setting_view.dart';
|
||||||
import 'package:aman_kassa_flutter/views/bank_view/bank_view.dart';
|
import 'package:aman_kassa_flutter/views/bank_view/bank_view.dart';
|
||||||
import 'package:aman_kassa_flutter/views/check/image_show_container.dart';
|
import 'package:aman_kassa_flutter/views/check/image_show_container.dart';
|
||||||
|
|
@ -17,6 +18,7 @@ import 'package:aman_kassa_flutter/views/settings/printer/views/PrinterPaperSize
|
||||||
import 'package:aman_kassa_flutter/views/settings/setting_printer_view.dart';
|
import 'package:aman_kassa_flutter/views/settings/setting_printer_view.dart';
|
||||||
import 'package:aman_kassa_flutter/views/login/login_view.dart';
|
import 'package:aman_kassa_flutter/views/login/login_view.dart';
|
||||||
import './route_names.dart';
|
import './route_names.dart';
|
||||||
|
import 'package:aman_kassa_flutter/views/bank_setting/forte_setting_view.dart';
|
||||||
|
|
||||||
|
|
||||||
Route<dynamic> generateRoute(RouteSettings settings) {
|
Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
|
|
@ -69,6 +71,11 @@ Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
routeName: settings.name!,
|
routeName: settings.name!,
|
||||||
viewToShow: BankSettingView(),
|
viewToShow: BankSettingView(),
|
||||||
);
|
);
|
||||||
|
case ForteSettingViewRoute:
|
||||||
|
return _getPageRoute(
|
||||||
|
routeName: settings.name!,
|
||||||
|
viewToShow: ForteSettingView(),
|
||||||
|
);
|
||||||
case QrViewRoute:
|
case QrViewRoute:
|
||||||
ImageShowModel data = settings.arguments as ImageShowModel;
|
ImageShowModel data = settings.arguments as ImageShowModel;
|
||||||
return _getPageRoute(
|
return _getPageRoute(
|
||||||
|
|
@ -102,12 +109,12 @@ Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
routeName: settings.name!,
|
routeName: settings.name!,
|
||||||
viewToShow: PrinterPaperView(),
|
viewToShow: PrinterPaperView(),
|
||||||
);
|
);
|
||||||
case CloseDayShowRoute:
|
// case CloseDayShowRoute:
|
||||||
CloseDayData data = settings.arguments as CloseDayData;
|
// CloseDayData data = settings.arguments as CloseDayData;
|
||||||
return _getPageRoute(
|
// return _getPageRoute(
|
||||||
routeName: settings.name!,
|
// routeName: settings.name!,
|
||||||
viewToShow: CloseDayShowContainer(data),
|
// viewToShow: CloseDayShowContainer(data),
|
||||||
);
|
// );
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => Scaffold(
|
builder: (_) => Scaffold(
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_post_session.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_post_session.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_post_session.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'package:aman_kassa_flutter/views/login/login_view.dart';
|
import 'package:aman_kassa_flutter/views/login/login_view.dart';
|
||||||
|
|
@ -79,6 +80,18 @@ class ApiService extends BaseService {
|
||||||
return HalykPosSession.fromJson(jsonDecode(response));
|
return HalykPosSession.fromJson(jsonDecode(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<FortePosSession> fortePosToken(String token, login, password) async {
|
||||||
|
String salt = '!=uF:w1N_Salh?1gVSJ#eGfJYHA(wS4D';
|
||||||
|
String hash = md5.convert(utf8.encode('$login$salt')).toString();
|
||||||
|
print(hash);
|
||||||
|
|
||||||
|
Map<String, String> requestBody = <String, String>{'login': login, 'hash': hash};
|
||||||
|
String pointUrl = test ? '/fortepos/test/gettoken' : '/fortepos/prod/gettoken';
|
||||||
|
var response = await requestFormData(pointUrl, requestBody, bodyEntry: true, posEndPoint: true, statusCheck: false);
|
||||||
|
print(response);
|
||||||
|
return FortePosSession.fromJson(jsonDecode(response));
|
||||||
|
}
|
||||||
|
|
||||||
Future<Response<dynamic>> money(String token) async {
|
Future<Response<dynamic>> money(String token) async {
|
||||||
Map<String, String> requestBody = <String, String>{'api_token': token};
|
Map<String, String> requestBody = <String, String>{'api_token': token};
|
||||||
var response = await requestFormData('/money', requestBody);
|
var response = await requestFormData('/money', requestBody);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
||||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/close_day_data.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/close_day_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_close_day_dao.dart' as Cd;
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_close_day_dao.dart' as Cd;
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_post_session.dart' as Ps;
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_post_session.dart' as Ps;
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_response_dao.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_response_dao.dart';
|
||||||
|
|
@ -15,6 +15,7 @@ import '../models/aman_dao.dart';
|
||||||
|
|
||||||
class BankService extends BaseService {
|
class BankService extends BaseService {
|
||||||
int sdkVersion = 27;
|
int sdkVersion = 27;
|
||||||
|
String packageName = 'ru.m4bank.softpos.halyk';
|
||||||
final ApiService _api = locator<ApiService>();
|
final ApiService _api = locator<ApiService>();
|
||||||
final MethodChannel _channel = MethodChannel('channel:com.amanKassa/bank');
|
final MethodChannel _channel = MethodChannel('channel:com.amanKassa/bank');
|
||||||
|
|
||||||
|
|
@ -45,7 +46,10 @@ class BankService extends BaseService {
|
||||||
|
|
||||||
Future<Cd.HalykCloseDayDao?> closeDay({ required String token}) async {
|
Future<Cd.HalykCloseDayDao?> closeDay({ required String token}) async {
|
||||||
try {
|
try {
|
||||||
String response = await _channel.invokeMethod("closeDay", <String, dynamic>{'token': token });
|
String response = await _channel.invokeMethod("closeDay", <String, dynamic>{
|
||||||
|
'token': token,
|
||||||
|
'packageName': packageName
|
||||||
|
});
|
||||||
log.i(response);
|
log.i(response);
|
||||||
Cd.HalykCloseDayDao dao = Cd.HalykCloseDayDao.fromMap(json.decode(response))!;
|
Cd.HalykCloseDayDao dao = Cd.HalykCloseDayDao.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
|
|
@ -60,7 +64,11 @@ class BankService extends BaseService {
|
||||||
|
|
||||||
double total = amount * 100;
|
double total = amount * 100;
|
||||||
log.i('total: $total, ${total.toInt()}');
|
log.i('total: $total, ${total.toInt()}');
|
||||||
String response = await _channel.invokeMethod("pay", <String, dynamic>{'amount': total.toInt(), 'token': token });
|
String response = await _channel.invokeMethod("pay", <String, dynamic>{
|
||||||
|
'amount': total.toInt(),
|
||||||
|
'token': token,
|
||||||
|
'packageName': packageName
|
||||||
|
});
|
||||||
log.i(response);
|
log.i(response);
|
||||||
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
|
|
@ -73,7 +81,12 @@ class BankService extends BaseService {
|
||||||
Future<HalykResponse> refund({required double amount, required String token, required int terminalId, required int operDay, required int transNum }) async {
|
Future<HalykResponse> refund({required double amount, required String token, required int terminalId, required int operDay, required int transNum }) async {
|
||||||
try {
|
try {
|
||||||
String response = await _channel.invokeMethod("refund", <String, dynamic>{
|
String response = await _channel.invokeMethod("refund", <String, dynamic>{
|
||||||
'amount': amount.toInt(), 'token': token , 'terminalId': terminalId, 'operDay': operDay, 'transNum': transNum
|
'amount': amount.toInt(),
|
||||||
|
'token': token,
|
||||||
|
'terminalId': terminalId,
|
||||||
|
'operDay': operDay,
|
||||||
|
'transNum': transNum,
|
||||||
|
'packageName': packageName
|
||||||
});
|
});
|
||||||
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
||||||
return dao;
|
return dao;
|
||||||
|
|
@ -86,7 +99,11 @@ class BankService extends BaseService {
|
||||||
Future<HalykResponse> reversal({ required String token, required int terminalId, required int operDay, required int transNum }) async {
|
Future<HalykResponse> reversal({ required String token, required int terminalId, required int operDay, required int transNum }) async {
|
||||||
try {
|
try {
|
||||||
String response = await _channel.invokeMethod("reversal", <String, dynamic>{
|
String response = await _channel.invokeMethod("reversal", <String, dynamic>{
|
||||||
'token': token , 'terminalId': terminalId, 'operDay': operDay, 'transNum': transNum
|
'token': token,
|
||||||
|
'terminalId': terminalId,
|
||||||
|
'operDay': operDay,
|
||||||
|
'transNum': transNum,
|
||||||
|
'packageName': packageName
|
||||||
});
|
});
|
||||||
log.i(response);
|
log.i(response);
|
||||||
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
HalykResponse dao = HalykResponse.fromMap(json.decode(response))!;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:aman_kassa_flutter/core/base/base_service.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/close_day_data.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_close_day_dao.dart' as Cd;
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_post_session.dart' as Ps;
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_response_dao.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/ApiService.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
import '../models/aman_dao.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class ForteService extends BaseService {
|
||||||
|
int sdkVersion = 27;
|
||||||
|
String packageName = 'kz.forte.pos';
|
||||||
|
final ApiService _api = locator<ApiService>();
|
||||||
|
final MethodChannel _channel = MethodChannel('channel:com.amanKassa/bank');
|
||||||
|
|
||||||
|
|
||||||
|
Future<int> version() async {
|
||||||
|
String result;
|
||||||
|
try {
|
||||||
|
result = await _channel.invokeMethod('version');
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e("ForteService", e, stack);
|
||||||
|
result = '0';
|
||||||
|
}
|
||||||
|
log.i(result);
|
||||||
|
return int.parse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Ps.FortePosSession?> renewToken({required String token, required String login, required String password}) async {
|
||||||
|
Ps.FortePosSession? result;
|
||||||
|
try {
|
||||||
|
result = await _api.fortePosToken(token, login, password);
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e("ForteService", e, stack);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<Cd.ForteCloseDayDao?> closeDay({ required String token}) async {
|
||||||
|
try {
|
||||||
|
String response = await _channel.invokeMethod("closeDay", <String, dynamic>{
|
||||||
|
'token': token,
|
||||||
|
'packageName': packageName
|
||||||
|
});
|
||||||
|
log.i(response);
|
||||||
|
Cd.ForteCloseDayDao dao = Cd.ForteCloseDayDao.fromMap(json.decode(response))!;
|
||||||
|
return dao;
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e("ForteService", e, stack);
|
||||||
|
return new Cd.ForteCloseDayDao(result: Cd.ResultBean(description: 'Ошибка при закрытии дня', code: -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ForteResponse> pay({required double amount, required String token}) async {
|
||||||
|
try {
|
||||||
|
|
||||||
|
double total = amount * 100;
|
||||||
|
log.i('total: $total, ${total.toInt()}');
|
||||||
|
String response = await _channel.invokeMethod("pay", <String, dynamic>{
|
||||||
|
'amount': total.toInt(),
|
||||||
|
'token': token,
|
||||||
|
'packageName': packageName
|
||||||
|
});
|
||||||
|
log.i(response);
|
||||||
|
ForteResponse dao = ForteResponse.fromMap(json.decode(response))!;
|
||||||
|
return dao;
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e("ForteService", e, stack);
|
||||||
|
return new ForteResponse(result: ResultBean(description: 'Ошибка оплаты', code: -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ForteResponse> refund({required double amount, required String token, required int terminalId, required int operDay, required int transNum }) async {
|
||||||
|
try {
|
||||||
|
double total = amount * 100;
|
||||||
|
String response = await _channel.invokeMethod("refund", <String, dynamic>{
|
||||||
|
'amount': total,
|
||||||
|
'token': token,
|
||||||
|
'terminalId': terminalId,
|
||||||
|
'operDay': operDay,
|
||||||
|
'transNum': transNum,
|
||||||
|
'packageName': packageName
|
||||||
|
});
|
||||||
|
ForteResponse dao = ForteResponse.fromMap(json.decode(response))!;
|
||||||
|
return dao;
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e("ForteService", e, stack);
|
||||||
|
return new ForteResponse(result: ResultBean(description: 'Ошибка при возврате', code: -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ForteResponse> reversal({ required String token, required int terminalId, required int operDay, required int transNum }) async {
|
||||||
|
try {
|
||||||
|
String response = await _channel.invokeMethod("reversal", <String, dynamic>{
|
||||||
|
'token': token,
|
||||||
|
'terminalId': terminalId,
|
||||||
|
'operDay': operDay,
|
||||||
|
'transNum': transNum,
|
||||||
|
'packageName': packageName
|
||||||
|
});
|
||||||
|
log.i(response);
|
||||||
|
ForteResponse dao = ForteResponse.fromMap(json.decode(response))!;
|
||||||
|
return dao;
|
||||||
|
} catch (e, stack) {
|
||||||
|
log.e("ForteService", e, stack);
|
||||||
|
return new ForteResponse(result: ResultBean(description: 'Ошибка при возврате', code: -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CloseDayData closeDayDataConvert(Cd.TransactionsBean transactions) {
|
||||||
|
final DateFormat formatter = DateFormat('dd.MM.yyyy');
|
||||||
|
final DateTime now = DateTime.now();
|
||||||
|
final String formatted = formatter.format(now);
|
||||||
|
List<Cd.TransactionBean> items = transactions.transaction!;
|
||||||
|
num totalAmount = 0;
|
||||||
|
int totalCount = 0;
|
||||||
|
num paymentAmount = 0;
|
||||||
|
int paymentCount = 0;
|
||||||
|
num refundAmount = 0;
|
||||||
|
int refundCount = 0;
|
||||||
|
num cancelAmount = 0;
|
||||||
|
int cancelCount = 0;
|
||||||
|
|
||||||
|
for(Cd.TransactionBean item in items) {
|
||||||
|
if(item.type == 'PAYMENT') {
|
||||||
|
paymentCount++;
|
||||||
|
paymentAmount += ( item.amount / 100 );
|
||||||
|
totalAmount += ( item.amount / 100 );
|
||||||
|
} else if(item.type == 'REFUND') {
|
||||||
|
refundCount++;
|
||||||
|
refundAmount += ( item.amount / 100 );
|
||||||
|
totalAmount -= ( item.amount / 100 );
|
||||||
|
} else if(item.type == 'REVERSAL') {
|
||||||
|
cancelCount++;
|
||||||
|
cancelAmount += ( item.amount / 100 );
|
||||||
|
totalAmount -= ( item.amount / 100 );
|
||||||
|
}
|
||||||
|
totalCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseDayData closeDayData = new CloseDayData(
|
||||||
|
items: items,
|
||||||
|
title: 'Отчет POS от $formatted',
|
||||||
|
totalAmount: totalAmount, totalCount: totalCount,
|
||||||
|
paymentAmount: paymentAmount, paymentCount: paymentCount,
|
||||||
|
refundAmount: refundAmount, refundCount: refundCount,
|
||||||
|
cancelAmount: cancelAmount, cancelCount: cancelCount,
|
||||||
|
);
|
||||||
|
return closeDayData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import 'package:meta/meta.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:redux_thunk/redux_thunk.dart';
|
import 'package:redux_thunk/redux_thunk.dart';
|
||||||
|
|
||||||
|
import '../../core/models/forte/forte_post_session.dart';
|
||||||
import '../store.dart';
|
import '../store.dart';
|
||||||
|
|
||||||
@immutable
|
@immutable
|
||||||
|
|
@ -13,9 +14,52 @@ class SetBankStateAction {
|
||||||
SetBankStateAction(this.bankState);
|
SetBankStateAction(this.bankState);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkAction<AppState> saveData(String login, String password) {
|
ThunkAction<AppState> saveData(String login, String password, {String? sessionType}) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
store.dispatch(SetBankStateAction(BankState(login: login, password: password)));
|
final currentState = store.state.bankState;
|
||||||
|
|
||||||
|
dynamic session;
|
||||||
|
if (sessionType == 'Halyk') {
|
||||||
|
session = HalykPosSession(
|
||||||
|
login: login,
|
||||||
|
token: currentState?.session != null &&
|
||||||
|
currentState?.session is HalykPosSession
|
||||||
|
? (currentState?.session as HalykPosSession).token
|
||||||
|
: null,
|
||||||
|
serverTime: currentState?.session != null &&
|
||||||
|
currentState?.session is HalykPosSession
|
||||||
|
? (currentState?.session as HalykPosSession).serverTime
|
||||||
|
: null,
|
||||||
|
tokenTimeout: currentState?.session != null &&
|
||||||
|
currentState?.session is HalykPosSession
|
||||||
|
? (currentState?.session as HalykPosSession).tokenTimeout
|
||||||
|
: null,
|
||||||
|
result: currentState?.session != null &&
|
||||||
|
currentState?.session is HalykPosSession
|
||||||
|
? (currentState?.session as HalykPosSession).result
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
} else if (sessionType == 'Forte') {
|
||||||
|
session = FortePosSession(
|
||||||
|
login: login,
|
||||||
|
token: currentState?.session != null &&
|
||||||
|
currentState?.session is FortePosSession
|
||||||
|
? (currentState?.session as FortePosSession).token
|
||||||
|
: null,
|
||||||
|
serverTime: currentState?.session != null &&
|
||||||
|
currentState?.session is FortePosSession
|
||||||
|
? (currentState?.session as FortePosSession).serverTime
|
||||||
|
: null,
|
||||||
|
tokenTimeout: currentState?.session != null &&
|
||||||
|
currentState?.session is FortePosSession
|
||||||
|
? (currentState?.session as FortePosSession).tokenTimeout
|
||||||
|
: null,
|
||||||
|
result: currentState?.session != null &&
|
||||||
|
currentState?.session is FortePosSession
|
||||||
|
? (currentState?.session as FortePosSession).result
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,11 @@ import 'package:aman_kassa_flutter/redux/state/bank_state.dart';
|
||||||
|
|
||||||
bankReducer(BankState prevState, SetBankStateAction action) {
|
bankReducer(BankState prevState, SetBankStateAction action) {
|
||||||
final payload = action.bankState;
|
final payload = action.bankState;
|
||||||
return prevState.copyWith(login: payload.login, password: payload.password, session: payload.session);
|
return prevState.copyWith(
|
||||||
|
login: payload.login ?? prevState.login,
|
||||||
|
password: payload.password ?? prevState.password,
|
||||||
|
session: payload.session ?? prevState.session,
|
||||||
|
sessionType: payload.sessionType ?? prevState.sessionType,
|
||||||
|
loading: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_post_session.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_post_session.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_post_session.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
|
@ -7,10 +8,11 @@ import 'package:meta/meta.dart';
|
||||||
class BankState {
|
class BankState {
|
||||||
final String? login;
|
final String? login;
|
||||||
final String? password;
|
final String? password;
|
||||||
final HalykPosSession? session;
|
final dynamic session;
|
||||||
|
final String? sessionType;
|
||||||
final bool? loading;
|
final bool? loading;
|
||||||
|
|
||||||
BankState({this.login, this.password, this.session,this.loading});
|
BankState({this.login, this.password, this.session,this.loading,this.sessionType});
|
||||||
|
|
||||||
//read hive
|
//read hive
|
||||||
factory BankState.initial(BankState? payload) {
|
factory BankState.initial(BankState? payload) {
|
||||||
|
|
@ -18,7 +20,8 @@ class BankState {
|
||||||
login: payload?.login,
|
login: payload?.login,
|
||||||
password: payload?.password,
|
password: payload?.password,
|
||||||
session: payload?.session,
|
session: payload?.session,
|
||||||
loading: payload?.loading
|
loading: payload?.loading,
|
||||||
|
sessionType: payload?.sessionType,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,25 +31,48 @@ class BankState {
|
||||||
@required password,
|
@required password,
|
||||||
@required session,
|
@required session,
|
||||||
@required loading,
|
@required loading,
|
||||||
|
@required sessionType,
|
||||||
}) {
|
}) {
|
||||||
return BankState(
|
return BankState(
|
||||||
login: login ?? this.login,
|
login: login ?? this.login,
|
||||||
password: password ?? this.password,
|
password: password ?? this.password,
|
||||||
session: session ?? this.session,
|
session: session ?? this.session,
|
||||||
loading: loading ?? this.loading
|
loading: loading ?? this.loading,
|
||||||
|
sessionType: sessionType ?? this.sessionType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BankState? fromJson(dynamic json) {
|
static BankState? fromJson(Map<String, dynamic> json) {
|
||||||
return json != null
|
if (json == null) return null;
|
||||||
? BankState(
|
|
||||||
password: json['password'],
|
// Определяем тип сессии
|
||||||
|
dynamic session;
|
||||||
|
String sessionType = json['sessionType'];
|
||||||
|
if (sessionType == "Halyk") {
|
||||||
|
session = HalykPosSession.fromJson(json['session']);
|
||||||
|
} else if (sessionType == "Forte") {
|
||||||
|
session = FortePosSession.fromJson(json['session']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return BankState(
|
||||||
login: json['login'],
|
login: json['login'],
|
||||||
)
|
password: json['password'],
|
||||||
: null;
|
session: session,
|
||||||
|
sessionType: sessionType,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {"password": password, "login": login};
|
return {
|
||||||
|
"login": login,
|
||||||
|
"password": password,
|
||||||
|
"sessionType": sessionType,
|
||||||
|
"session": session?.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'BankState(login: $login, password: $password, sessionType: $sessionType, session: $session)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const Color fillColor = Color.fromRGBO(248, 248, 248, 1);
|
||||||
const Color primaryColor = Color.fromRGBO(51, 122, 183, 1);
|
const Color primaryColor = Color.fromRGBO(51, 122, 183, 1);
|
||||||
|
|
||||||
const Color halykColor = Color.fromRGBO(0, 118, 59, 1);
|
const Color halykColor = Color.fromRGBO(0, 118, 59, 1);
|
||||||
|
const Color forteColor = Color.fromRGBO(175, 32, 92, 1.0);
|
||||||
|
|
||||||
|
|
||||||
const Color menuColor = Color.fromRGBO(0, 75, 120, 1);
|
const Color menuColor = Color.fromRGBO(0, 75, 120, 1);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class _BankSettingViewState extends State<BankSettingView> {
|
||||||
late TextEditingController _passwordController;
|
late TextEditingController _passwordController;
|
||||||
final NavigatorService _navigatorService = locator<NavigatorService>();
|
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
|
late String _sessionType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -34,6 +35,7 @@ class _BankSettingViewState extends State<BankSettingView> {
|
||||||
_emailController = new TextEditingController(text: state.login);
|
_emailController = new TextEditingController(text: state.login);
|
||||||
_passwordController = new TextEditingController(text: state.password);
|
_passwordController = new TextEditingController(text: state.password);
|
||||||
//permissions();
|
//permissions();
|
||||||
|
_sessionType = 'Halyk';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> permissions() async {
|
// Future<void> permissions() async {
|
||||||
|
|
@ -54,7 +56,11 @@ class _BankSettingViewState extends State<BankSettingView> {
|
||||||
|
|
||||||
void _saveData(BuildContext _context) async {
|
void _saveData(BuildContext _context) async {
|
||||||
FocusScope.of(_context).unfocus();
|
FocusScope.of(_context).unfocus();
|
||||||
await Redux.store!.dispatch(saveData(_emailController.text, _passwordController.text));
|
await Redux.store!.dispatch(saveData(
|
||||||
|
_emailController.text,
|
||||||
|
_passwordController.text,
|
||||||
|
sessionType: _sessionType,
|
||||||
|
));
|
||||||
_dialogService.showDialog(description: 'Данные сохранены');
|
_dialogService.showDialog(description: 'Данные сохранены');
|
||||||
_navigatorService.pop();
|
_navigatorService.pop();
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +69,27 @@ class _BankSettingViewState extends State<BankSettingView> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final BankState? state = Redux.store?.state.bankState;
|
||||||
|
|
||||||
|
// Проверяем, активна ли Forte-сессия
|
||||||
|
if ((state?.login != null && state!.login!.isNotEmpty) ||
|
||||||
|
(state?.password != null && state!.password!.isNotEmpty)) {
|
||||||
|
if (state.sessionType != 'Halyk') {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text('Настройка HalykPos'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Text(
|
||||||
|
'У вас подключен терминал Forte',
|
||||||
|
style: TextStyle(fontSize: 16.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,142 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/aman_dao.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/ForteService.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
||||||
|
import 'package:aman_kassa_flutter/redux/actions/bank_actions.dart';
|
||||||
|
import 'package:aman_kassa_flutter/redux/state/bank_state.dart';
|
||||||
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
|
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import '../../core/services/navigator_service.dart';
|
||||||
|
|
||||||
|
class ForteSettingView extends StatefulWidget {
|
||||||
|
ForteSettingView();
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ForteSettingViewState createState() => _ForteSettingViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ForteSettingViewState extends State<ForteSettingView> {
|
||||||
|
late TextEditingController _emailController;
|
||||||
|
late TextEditingController _passwordController;
|
||||||
|
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
|
late String _sessionType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
BankState state = Redux.store!.state.bankState!;
|
||||||
|
_emailController = new TextEditingController(text: state.login);
|
||||||
|
_passwordController = new TextEditingController(text: state.password);
|
||||||
|
//permissions();
|
||||||
|
_sessionType = 'Forte';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future<void> permissions() async {
|
||||||
|
// try {
|
||||||
|
// await _bankService.permissions();
|
||||||
|
// } on PlatformException {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_emailController.dispose();
|
||||||
|
_passwordController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _saveData(BuildContext _context) async {
|
||||||
|
FocusScope.of(_context).unfocus();
|
||||||
|
await Redux.store!.dispatch(saveData(
|
||||||
|
_emailController.text,
|
||||||
|
_passwordController.text,
|
||||||
|
sessionType: _sessionType
|
||||||
|
));
|
||||||
|
_dialogService.showDialog(description: 'Данные сохранены');
|
||||||
|
_navigatorService.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final BankState? state = Redux.store?.state.bankState;
|
||||||
|
|
||||||
|
// Проверяем, активна ли Halyk-сессия
|
||||||
|
if ((state?.login != null && state!.login!.isNotEmpty) ||
|
||||||
|
(state?.password != null && state!.password!.isNotEmpty)) {
|
||||||
|
if (state.sessionType != 'Forte') {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text('Настройка FortePos'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Text(
|
||||||
|
'У вас подключен терминал Halyk',
|
||||||
|
style: TextStyle(fontSize: 16.0, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text('Настройка FortePos'),
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 14.0),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
verticalSpaceTiny,
|
||||||
|
Text(
|
||||||
|
'Необходимо указать почту/номер и пароль для подключения к системе проведения платежей',
|
||||||
|
style: TextStyle(fontSize: 15.0),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
verticalSpaceTiny,
|
||||||
|
TextField(
|
||||||
|
controller: _emailController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'E-Mail / Номер телефона в формете 77xx ', hintText: "Введите адрес почты/телефон"),
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _passwordController,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Пароль', hintText: "Введите пароль"),
|
||||||
|
),
|
||||||
|
verticalSpaceMedium,
|
||||||
|
RaisedButton(
|
||||||
|
onPressed: () => this._saveData(context),
|
||||||
|
child: Text(
|
||||||
|
'Cохранить',
|
||||||
|
style: TextStyle(color: whiteColor, fontSize: 25.0),
|
||||||
|
),
|
||||||
|
color: primaryColor,
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20.0),
|
||||||
|
),
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:aman_kassa_flutter/core/models/close_day_data.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/close_day_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_close_day_dao.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_close_day_dao.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
import 'package:aman_kassa_flutter/core/models/transaction_item.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/card_data.dart';
|
import 'package:aman_kassa_flutter/core/models/card_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/check_data.dart';
|
import 'package:aman_kassa_flutter/core/models/check_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/close_day_data.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/close_day_data.dart';
|
||||||
import 'package:aman_kassa_flutter/core/route_names.dart';
|
import 'package:aman_kassa_flutter/core/route_names.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/DbService.dart';
|
import 'package:aman_kassa_flutter/core/services/DbService.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ class _PopupMenuState extends State<PopupMenu> {
|
||||||
//if (version >= 24 )
|
//if (version >= 24 )
|
||||||
// const Choice(title: 'Bank', icon: Icons.text_fields, command: 'bank'),
|
// const Choice(title: 'Bank', icon: Icons.text_fields, command: 'bank'),
|
||||||
if (version >= _bankService.sdkVersion )
|
if (version >= _bankService.sdkVersion )
|
||||||
const Choice(title: 'Настройка HalykPos', icon: Icons.phonelink_lock_outlined, command: 'tap2phone'),
|
const Choice(title: 'Настройка HalykPos', icon: Icons.phonelink_lock_outlined, command: 'tap2phone'),
|
||||||
|
const Choice(title: 'Настройка FortePos', icon: Icons.phonelink_lock_outlined, command: 'fortepos'),
|
||||||
const Choice(title: 'Настройки', icon: Icons.settings, command: 'settings'),
|
const Choice(title: 'Настройки', icon: Icons.settings, command: 'settings'),
|
||||||
const Choice(title: 'Принтер', icon: Icons.print, command: 'print'),
|
const Choice(title: 'Принтер', icon: Icons.print, command: 'print'),
|
||||||
const Choice(title: 'Выйти', icon: Icons.exit_to_app, command: 'exit')
|
const Choice(title: 'Выйти', icon: Icons.exit_to_app, command: 'exit')
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,8 @@ class _HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
||||||
_navigatorService.push(BankViewRoute);
|
_navigatorService.push(BankViewRoute);
|
||||||
} else if (choice.command == 'tap2phone') {
|
} else if (choice.command == 'tap2phone') {
|
||||||
_navigatorService.push(BankSettingViewRoute);
|
_navigatorService.push(BankSettingViewRoute);
|
||||||
|
} else if (choice.command == 'fortepos') {
|
||||||
|
_navigatorService.push(ForteSettingViewRoute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@ import 'dart:convert';
|
||||||
import 'package:aman_kassa_flutter/core/entity/Voucher.dart';
|
import 'package:aman_kassa_flutter/core/entity/Voucher.dart';
|
||||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
import 'package:aman_kassa_flutter/core/models/check_image_modal.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/close_day_data.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/close_day_data.dart' as halyk_models;
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/close_day_data.dart' as forte_models;
|
||||||
import 'package:aman_kassa_flutter/core/models/halyk/halyk_close_day_dao.dart';
|
import 'package:aman_kassa_flutter/core/models/halyk/halyk_close_day_dao.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_close_day_dao.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/money.dart';
|
import 'package:aman_kassa_flutter/core/models/money.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/response.dart';
|
import 'package:aman_kassa_flutter/core/models/response.dart';
|
||||||
import 'package:aman_kassa_flutter/core/models/dialog_models.dart';
|
import 'package:aman_kassa_flutter/core/models/dialog_models.dart';
|
||||||
|
|
@ -12,6 +14,7 @@ import 'package:aman_kassa_flutter/core/models/user.dart';
|
||||||
import 'package:aman_kassa_flutter/core/route_names.dart';
|
import 'package:aman_kassa_flutter/core/route_names.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/ApiService.dart';
|
import 'package:aman_kassa_flutter/core/services/ApiService.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/BankService.dart';
|
import 'package:aman_kassa_flutter/core/services/BankService.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/ForteService.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||||
|
|
@ -27,11 +30,14 @@ import 'package:aman_kassa_flutter/widgets/fields/aman_icon_button.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/aman_icon_button_horizontal.dart';
|
import 'package:aman_kassa_flutter/widgets/fields/aman_icon_button_horizontal.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
|
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/loader/Dialogs.dart';
|
import 'package:aman_kassa_flutter/widgets/loader/Dialogs.dart';
|
||||||
import 'package:aman_kassa_flutter/views/payment/halyk_pos_service.dart';
|
import 'package:aman_kassa_flutter/views/payment/halyk_pos_service.dart' as halyk;
|
||||||
|
import 'package:aman_kassa_flutter/views/payment/forte_pos_service.dart' as forte;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
|
|
||||||
|
import '../../../redux/state/bank_state.dart';
|
||||||
|
|
||||||
class AdditionalTab extends StatefulWidget {
|
class AdditionalTab extends StatefulWidget {
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
|
|
@ -45,7 +51,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
ApiService _api = locator<ApiService>();
|
ApiService _api = locator<ApiService>();
|
||||||
NavigatorService _navigator = locator<NavigatorService>();
|
NavigatorService _navigator = locator<NavigatorService>();
|
||||||
DialogService _dialog = locator<DialogService>();
|
DialogService _dialog = locator<DialogService>();
|
||||||
final BankService _bankService = locator<BankService>();
|
dynamic _bankService;
|
||||||
DataService _dataService = locator<DataService>();
|
DataService _dataService = locator<DataService>();
|
||||||
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
|
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
|
||||||
|
|
||||||
|
|
@ -116,7 +122,6 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
ImageShowModel(data: CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: 'X Отчет'));
|
ImageShowModel(data: CheckImageModal(base64Data: check, textData: checkText !=null ? jsonEncode(checkText) : null ), title: 'X Отчет'));
|
||||||
|
|
||||||
String? url = response.body['link'];
|
String? url = response.body['link'];
|
||||||
log.i(url);
|
|
||||||
_dataService.insertVoucher(
|
_dataService.insertVoucher(
|
||||||
user: user,
|
user: user,
|
||||||
name: 'X Отчет',
|
name: 'X Отчет',
|
||||||
|
|
@ -126,8 +131,8 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
} else {
|
} else {
|
||||||
_dialog.showDialog(description: response.body['message']);
|
_dialog.showDialog(description: response.body['message']);
|
||||||
}
|
}
|
||||||
} catch (e, stack) {
|
} catch (e) {
|
||||||
log.e('message', e, stack);
|
print(e);
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
xReportBusy = false;
|
xReportBusy = false;
|
||||||
|
|
@ -229,6 +234,14 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
isClosePosBusy = true;
|
isClosePosBusy = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
BankState? state = Redux.store?.state.bankState;
|
||||||
|
|
||||||
|
if (state?.sessionType == 'Halyk' && state?.session != null) {
|
||||||
|
_bankService = locator<BankService>();
|
||||||
|
} else if (state?.sessionType == 'Forte' && state?.session != null) {
|
||||||
|
_bankService = locator<ForteService>();
|
||||||
|
}
|
||||||
|
|
||||||
int version = await _bankService.version();
|
int version = await _bankService.version();
|
||||||
if (version < _bankService.sdkVersion ) {
|
if (version < _bankService.sdkVersion ) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -237,11 +250,21 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
_dialog.showDialog(description: 'Функция Tap2Phone доступна c Android версии 8.1');
|
_dialog.showDialog(description: 'Функция Tap2Phone доступна c Android версии 8.1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final isForteSessionActive = state?.sessionType == 'Forte';
|
||||||
|
|
||||||
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
await Redux.store!.dispatch(changePinSkipFromSetting(true));
|
||||||
HalykCloseDayDao? closeDayDao = await closeDayHalykPos();
|
|
||||||
|
dynamic closeDayDao;
|
||||||
|
if (isForteSessionActive) {
|
||||||
|
closeDayDao = await forte.closeDayFortePos();
|
||||||
|
} else {
|
||||||
|
closeDayDao = await halyk.closeDayHalykPos();
|
||||||
|
}
|
||||||
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
await Redux.store!.dispatch(changePinSkipFromSetting(false));
|
||||||
log.i(closeDayDao?.toJson());
|
|
||||||
|
forte.log.i(closeDayDao.toJson());
|
||||||
|
halyk.log.i(closeDayDao.toJson());
|
||||||
|
|
||||||
if (closeDayDao?.result?.code != 0) {
|
if (closeDayDao?.result?.code != 0) {
|
||||||
if (closeDayDao!.result?.description != null) {
|
if (closeDayDao!.result?.description != null) {
|
||||||
_dialog.showDialog(description: closeDayDao.result!.description!);
|
_dialog.showDialog(description: closeDayDao.result!.description!);
|
||||||
|
|
@ -252,24 +275,27 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CloseDayData closeDayData = _bankService.closeDayDataConvert(closeDayDao!.transactions!);
|
|
||||||
|
|
||||||
User user = Redux.store!.state.userState!.user!;
|
User user = Redux.store!.state.userState!.user!;
|
||||||
_dataService.insertVoucher(
|
|
||||||
user: user,
|
|
||||||
name: closeDayData.title!,
|
|
||||||
data: jsonEncode(closeDayData.toJson()),
|
|
||||||
total: closeDayData.totalAmount!.toDouble(),
|
|
||||||
type: VoucherTypeCloseDayPosReport);
|
|
||||||
|
|
||||||
// _dialog.showDialog(description: 'Закрытие дня: операция прошла успешно!');
|
if (isForteSessionActive) {
|
||||||
setState(() {
|
final closeDayData = _bankService.closeDayDataConvert(closeDayDao!.transactions!);
|
||||||
isClosePosBusy = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
_navigator.push(CloseDayShowRoute,
|
_dataService.insertVoucher(
|
||||||
arguments: closeDayData);
|
user: user,
|
||||||
|
name: closeDayData.title!,
|
||||||
|
data: jsonEncode(closeDayData.toJson()),
|
||||||
|
total: closeDayData.totalAmount!.toDouble(),
|
||||||
|
type: VoucherTypeCloseDayPosReport);
|
||||||
|
} else {
|
||||||
|
final closeDayData = _bankService.closeDayDataConvert(closeDayDao!.transactions!);
|
||||||
|
|
||||||
|
_dataService.insertVoucher(
|
||||||
|
user: user,
|
||||||
|
name: closeDayData.title!,
|
||||||
|
data: jsonEncode(closeDayData.toJson()),
|
||||||
|
total: closeDayData.totalAmount!.toDouble(),
|
||||||
|
type: VoucherTypeCloseDayPosReport);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,158 @@
|
||||||
|
import 'package:aman_kassa_flutter/core/locator.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/logger.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_close_day_dao.dart'
|
||||||
|
as Cd;
|
||||||
|
import 'package:aman_kassa_flutter/core/models/forte/forte_response_dao.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
||||||
|
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
||||||
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
|
import 'package:logger/logger.dart';
|
||||||
|
import '../../core/models/aman_dao.dart';
|
||||||
|
import '../../core/models/card_data.dart';
|
||||||
|
import '../../core/models/forte/forte_post_session.dart';
|
||||||
|
import '../../core/services/ForteService.dart';
|
||||||
|
import '../../redux/state/bank_state.dart';
|
||||||
|
|
||||||
|
ForteService _bankService = locator<ForteService>();
|
||||||
|
DialogService _dialogService = locator<DialogService>();
|
||||||
|
final DataService _dataService = locator<DataService>();
|
||||||
|
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
|
Logger log = getLogger('PaymentNfcView');
|
||||||
|
|
||||||
|
Future<AmanDao<CardData>> paymentFortePos(double total) async {
|
||||||
|
//Авторизация
|
||||||
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
|
//права доступа
|
||||||
|
FortePosSession? session = await _bankService.renewToken(
|
||||||
|
token: token, login: bankState.login!, password: bankState.password!);
|
||||||
|
if (session == null || session.token == null) {
|
||||||
|
return sessionDeclineDao(session);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Инициализация
|
||||||
|
ForteResponse response =
|
||||||
|
await _bankService.pay(token: session.token!, amount: total);
|
||||||
|
if (response.result?.code == 0) {
|
||||||
|
CardData cardData = new CardData(
|
||||||
|
authorizationCode:
|
||||||
|
response.transaction?.instrumentSpecificData?.authorizationCode,
|
||||||
|
cardholderName:
|
||||||
|
response.transaction?.instrumentSpecificData?.cardholderName,
|
||||||
|
cardNumber: response.transaction?.instrumentSpecificData?.maskedPan,
|
||||||
|
operationDay: response.transaction?.operationDay,
|
||||||
|
transactionNumber: response.transaction?.transactionNumber,
|
||||||
|
terminalId: response.transaction?.terminalId,
|
||||||
|
transactionType: 'payment');
|
||||||
|
return AmanDao<CardData>(
|
||||||
|
msg: response.result?.description, success: true, data: cardData);
|
||||||
|
}
|
||||||
|
return AmanDao<CardData>(
|
||||||
|
msg: response.result?.errorData != null
|
||||||
|
? response.result!.errorData!.description
|
||||||
|
: response.result!.description,
|
||||||
|
success: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
AmanDao<CardData> sessionDeclineDao(FortePosSession? session) {
|
||||||
|
String msg = 'Отказано в доступе к API банка';
|
||||||
|
if(session!=null && session.result?.Response?.Description != null) {
|
||||||
|
msg = '${session.result?.Response?.Description} (${session.result?.Response?.Code}) ';
|
||||||
|
}
|
||||||
|
return AmanDao<CardData>(success: false, msg: msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<AmanDao<CardData>> refundFortePos(
|
||||||
|
CardData refundData, double total) async {
|
||||||
|
//Авторизация
|
||||||
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
|
//права доступа
|
||||||
|
FortePosSession? session = await _bankService.renewToken(
|
||||||
|
token: token, login: bankState.login!, password: bankState.password!);
|
||||||
|
if (session == null || session.token == null) {
|
||||||
|
return sessionDeclineDao(session);
|
||||||
|
}
|
||||||
|
ForteResponse response = await _bankService.refund(
|
||||||
|
token: session.token!,
|
||||||
|
amount: total,
|
||||||
|
operDay: refundData.operationDay!,
|
||||||
|
terminalId: refundData.terminalId!,
|
||||||
|
transNum: refundData.transactionNumber!);
|
||||||
|
if (response.result?.code == 0) {
|
||||||
|
CardData cardData = new CardData(
|
||||||
|
authorizationCode:
|
||||||
|
response.transaction?.instrumentSpecificData?.authorizationCode,
|
||||||
|
cardholderName:
|
||||||
|
response.transaction?.instrumentSpecificData?.cardholderName,
|
||||||
|
cardNumber: response.transaction?.instrumentSpecificData?.maskedPan,
|
||||||
|
operationDay: response.transaction?.operationDay,
|
||||||
|
transactionNumber: response.transaction?.transactionNumber,
|
||||||
|
terminalId: response.transaction?.terminalId,
|
||||||
|
transactionType: 'refund');
|
||||||
|
return AmanDao<CardData>(
|
||||||
|
msg: response.result?.description, success: true, data: cardData);
|
||||||
|
}
|
||||||
|
return AmanDao<CardData>(
|
||||||
|
msg: response.result?.errorData != null
|
||||||
|
? response.result!.errorData!.description
|
||||||
|
: response.result!.description,
|
||||||
|
success: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<AmanDao<CardData>> reversalFortePos(
|
||||||
|
CardData refundData, double total) async {
|
||||||
|
//Авторизация
|
||||||
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
|
//права доступа
|
||||||
|
FortePosSession? session = await _bankService.renewToken(
|
||||||
|
token: token, login: bankState.login ?? '', password: bankState.password ?? '');
|
||||||
|
if (session == null || session.token == null) {
|
||||||
|
return sessionDeclineDao(session);
|
||||||
|
}
|
||||||
|
log.i(refundData.toJson());
|
||||||
|
ForteResponse response = await _bankService.reversal(
|
||||||
|
token: session.token!,
|
||||||
|
operDay: refundData.operationDay!,
|
||||||
|
terminalId: refundData.terminalId!,
|
||||||
|
transNum: refundData.transactionNumber!);
|
||||||
|
if (response.result?.code == 0) {
|
||||||
|
CardData cardData = new CardData(
|
||||||
|
authorizationCode:
|
||||||
|
response.transaction?.instrumentSpecificData?.authorizationCode,
|
||||||
|
cardholderName:
|
||||||
|
response.transaction?.instrumentSpecificData?.cardholderName,
|
||||||
|
cardNumber: response.transaction?.instrumentSpecificData?.maskedPan,
|
||||||
|
operationDay: response.transaction?.operationDay,
|
||||||
|
transactionNumber: response.transaction?.transactionNumber,
|
||||||
|
terminalId: response.transaction?.terminalId,
|
||||||
|
transactionType: 'reversal');
|
||||||
|
return AmanDao<CardData>(
|
||||||
|
msg: response.result?.description, success: true, data: cardData);
|
||||||
|
}
|
||||||
|
return AmanDao<CardData>(
|
||||||
|
msg: response.result?.errorData != null
|
||||||
|
? response.result!.errorData!.description
|
||||||
|
: response.result!.description,
|
||||||
|
success: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Cd.ForteCloseDayDao?> closeDayFortePos() async {
|
||||||
|
//Авторизация
|
||||||
|
String token = Redux.store!.state.userState!.user!.token!;
|
||||||
|
BankState bankState = Redux.store!.state.bankState!;
|
||||||
|
//права доступа
|
||||||
|
FortePosSession? session = await _bankService.renewToken(
|
||||||
|
token: token, login: bankState.login ?? '', password: bankState.password ?? '');
|
||||||
|
if (session== null || session.token == null) {
|
||||||
|
return new Cd.ForteCloseDayDao(
|
||||||
|
result: Cd.ResultBean(
|
||||||
|
description: 'Отказано в доступе к API банка', code: -1));
|
||||||
|
}
|
||||||
|
//Инициализация
|
||||||
|
Cd.ForteCloseDayDao? response =
|
||||||
|
await _bankService.closeDay(token: session.token!);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue