Toast.makeText CardPaymentCallbackHandler

currency method BankNfcPlugins
backend_nfc
Serik.Uvaissov 2020-08-23 16:48:56 +06:00
parent 34dc1cb8a2
commit e06d192dcb
6 changed files with 74 additions and 10 deletions

View File

@ -242,7 +242,7 @@ public class CardPaymentHandlerImpl implements CardPaymentCallbackHandler<Result
dao.setSuccess(false);
dao.setMsg(String.format("%s", errorHandler.getFinalDescription()));
this.result.success(gson.toJson(dao));
Toast.makeText(plugin.getActivity(), String.format("onError: %s, description: %s", ((AllError) errorHandler).name(), errorHandler.getFinalDescription()), Toast.LENGTH_LONG).show();
//Toast.makeText(plugin.getActivity(), String.format("onError: %s, description: %s", ((AllError) errorHandler).name(), errorHandler.getFinalDescription()), Toast.LENGTH_LONG).show();
});
}
}

View File

@ -34,6 +34,8 @@ import ru.m4bank.mpos.service.authorization.network.AuthorizationResponse;
import ru.m4bank.mpos.service.commons.data.ConfigurationSettings;
import ru.m4bank.mpos.service.commons.data.NetworkConfiguration;
import ru.m4bank.mpos.service.commons.data.TerminalConfiguration;
import ru.m4bank.mpos.service.data.dynamic.CurrencyDataHolder;
import ru.m4bank.mpos.service.data.dynamic.objects.Currency;
import ru.m4bank.mpos.service.data.dynamic.objects.GetOperationType;
import ru.m4bank.mpos.service.hardware.external.cardreaderlib.data.enums.TransactionTypeConv;
import ru.m4bank.mpos.service.network.Format;
@ -76,6 +78,9 @@ public class BankNfcPlugins implements MethodCallHandler {
case "connection":
connection(result);
break;
case "currency":
currency(result);
break;
case "auth":
authentication(call, result);
break;
@ -189,6 +194,43 @@ public class BankNfcPlugins implements MethodCallHandler {
.checkConnection(
new ConnectionCheckHandlerImpl(this.activity, result));
}
private void currency(Result result) {
CurrencyDataHolder dataHolder = clientInterface.getConfigurationManager()
.getCurrencyDataHolder();
Currency currentCurrency = dataHolder.getCurrency();
if(currentCurrency!=null){
System.out.println(currentCurrency.getName());
System.out.println(currentCurrency.getCurrency3DigitCode());
} else {
System.out.println("currentCurrency is null");
}
System.out.println("===========================");
if(currentCurrency == null || !"398".equalsIgnoreCase(currentCurrency.getCurrency3DigitCode()) ){
List<Currency> currencies = dataHolder.getCurrencyList();
boolean changed = false;
for(Currency currency : currencies ){
System.out.println(currency.getName());
System.out.println(currency.getLetterCode());
System.out.println(currency.getCurrency3DigitCode());
if("398".equalsIgnoreCase(currency.getCurrency3DigitCode())){
dataHolder.setCurrency(currency);
changed = true;
break;
}
}
AmanDao<String> dao = new AmanDao<>();
dao.setSuccess(changed);
dao.setMsg("current currency " + (currentCurrency!=null ? currentCurrency.getLetterCode() : "NULL"));
result.success(gson.toJson(dao));
} else {
AmanDao<String> dao = new AmanDao<>();
dao.setSuccess(true);
dao.setMsg("exist");
result.success(gson.toJson(dao));
}
}
private void authentication(MethodCall call, Result result) {
String login = call.argument("login");

View File

@ -58,6 +58,18 @@ class BankService extends BaseService {
}
}
Future<bool> currency() async {
try {
String response = await _channel.invokeMethod("currency");
AmanDao dao = AmanDao.fromJson(json.decode(response));
log.i('${dao.success} - ${dao.msg}');
return dao.success;
} catch (e, stack) {
log.e("BankService", e, stack);
return false;
}
}
Future<bool> permissions() async {
try {
String response = await _channel.invokeMethod("permissions");

View File

@ -23,8 +23,6 @@ class _BankSettingViewState extends State<BankSettingView> {
TextEditingController _passwordController;
final BankService _bankService = locator<BankService>();
final DialogService _dialogService = locator<DialogService>();
String _platformImei = 'Unknown';
String _bankImei = 'Unknown';
@override
void initState() {
@ -32,10 +30,10 @@ class _BankSettingViewState extends State<BankSettingView> {
BankState state = Redux.store.state.bankState;
_emailController = new TextEditingController(text: state.login);
_passwordController = new TextEditingController(text: state.password);
initBankImeiState();
permissions();
}
Future<void> initBankImeiState() async {
Future<void> permissions() async {
try {
await _bankService.permissions();
} on PlatformException {
@ -74,8 +72,6 @@ class _BankSettingViewState extends State<BankSettingView> {
style: TextStyle(fontSize: 15.0),
textAlign: TextAlign.center,
),
Text('Ваш IMEI-код:$_platformImei'),
Text('Ваш IMEI-код:$_bankImei'),
verticalSpaceTiny,
TextField(
controller: _emailController,
@ -85,6 +81,7 @@ class _BankSettingViewState extends State<BankSettingView> {
),
TextField(
controller: _passwordController,
obscureText: true,
decoration: InputDecoration(
labelText: 'Пароль', hintText: "Введите пароль"),
),

View File

@ -30,8 +30,8 @@ class _PopupMenuState extends State<PopupMenu> {
List<Choice> _choices = <Choice>[
const Choice(title: 'Информация о ККМ', icon: Icons.info_outline, command: 'infokkm'),
if (version >= 24 )
const Choice(title: 'Bank', icon: Icons.text_fields, command: 'bank'),
//if (version >= 24 )
// const Choice(title: 'Bank', icon: Icons.text_fields, command: 'bank'),
if (version >= 24 )
const Choice(title: 'Настройка Tap2Phone', icon: MdiIcons.nfc, command: 'tap2phone'),
const Choice(title: 'Выйти', icon: Icons.exit_to_app, command: 'exit')

View File

@ -64,7 +64,7 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
}
void start() async {
//Инициализация
//права доступа
bool success = await _bankService.permissions();
log.i(success);
if (!success) {
@ -82,6 +82,9 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
});
return;
}
//Проверка связи
bool connected = await _bankService.connect();
log.i(connected);
@ -107,6 +110,16 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
return;
}
// //валюта
// bool currency = await _bankService.currency();
// log.i(currency);
// if (!currency) {
// setState(() {
// status = 4;
// });
// return;
// }
pay();
}