Commit 07b8f4fd authored by Gandha Ryanto's avatar Gandha Ryanto

Merge remote-tracking branch 'origin/simplyfy-v2' into simplyfy-v2

parents 0716d907 01335cd2
......@@ -301,51 +301,6 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
)
print("model ${Build.MODEL}")
// if (Build.MODEL == "T2s" || Build.MODEL == "T2Mini" || Build.MODEL == "T2mini") {
if (Build.MODEL == "T2s" || Build.MODEL == "T2Mini") {
var text = """
[C]${companyName}
[C]${companyAddress}
[C]${companyPhone}
[C]--------------------------------
[L]xTanggal : ${sdf.format(timeNow)}
[L]xNo Transaksi : ${approvalCode}
[L] No Kartu : ${ticket.cardNumber.toString()}
[L]Masa Berlaku : ${sdf.format(cardExpiry)}"""
if(status == "Berhasil"){
text += """
[L]Saldo Awal : Rp${formatDecimalToPrice(prevBalance.toDouble()).toString()}
[L]Isi Saldo : Rp${formatDecimalToPrice(denom.toDouble()).toString()}
[L]Saldo Akhir : Rp${formatDecimalToPrice(ticket.balance!!.toDouble()).toString()}
[L]Biaya Layanan : Rp${formatDecimalToPrice(serviceCharge.toDouble()).toString()}
[L]Jumlah Bayar : Rp${formatDecimalToPrice(serviceChargeAmount.toDouble()).toString()}
[L]Metode Bayar : ${metodeBayar}
[L]Status : ${status}
[C]--------------------------------
[C]Top Up Berhasil
[C]powered by dolanapp.com
"""
} else {
text += """
[L]Saldo : Rp${formatDecimalToPrice(prevBalance.toDouble()).toString()}
[L]Biaya Layanan : Rp${formatDecimalToPrice(serviceCharge.toDouble()).toString()}
[L]Jumlah Bayar : Rp${formatDecimalToPrice(serviceChargeAmount.toDouble()).toString()}
[L]Metode Bayar : ${metodeBayar}
[L]Status : ${status}
[C]--------------------------------
[C]Top Up Gagal
[C]powered by dolanapp.com
"""
}
text = text.trimIndent()
_mifareTicketing?.generateReceiptTopup(
null,
text,
bitmapIcon,
paperWidth = 57F,
isBluetooth = true
)
}
else {
var receiptLayout = ReceiptBuilder(570)
.setMarginTop(30)
.setMarginLeft(30)
......@@ -389,7 +344,7 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
.addBlankSpace(10)
.addText("Masa Berlaku...............: " + sdf.format(cardExpiry))
.addBlankSpace(10)
if (status == "Berhasil"){
if (status == "Isi Saldo Berhasil"){
receiptLayout.addText("Saldo Awal...................: Rp" + formatDecimalToPrice(prevBalance.toDouble()).toString())
.addBlankSpace(10)
.addText("Isi Saldo.........................: Rp" + formatDecimalToPrice(denom.toDouble()))
......@@ -438,7 +393,7 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
}
val finalReceiptLayout: ReceiptBuilder = receiptLayout
_mifareTicketing?.generateReceiptTopup(finalReceiptLayout, "", null, paperWidth = 570F, isBluetooth = false)
}
}
}
......@@ -494,6 +494,17 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
print("lastBalance $lastBalance");
print("prevBalance $prevBalance");
String ticketJson, companyName, companyPhone, denom;
companyName = PreferencesHelper.getString('outletname');
companyPhone = PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString('multioutletaddress');
denom = amountController!.text.replaceAll(",", "");
String sca =
PreferencesHelper.getString("multioutletservicechargeamount");
String sc = PreferencesHelper.getString("multioutletservicecharge");
// String metodeBayar = PreferencesHelper.getString("provider");
// String status = "Berhasil";
if (int.parse(lastBalance) > int.parse(prevBalance!)) {
countMax = 0;
var result = await StartService.topUpConfirm(
......@@ -562,16 +573,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
DatabaseHelper.insertTransaction(wristbandInfo);
print("ini pesan tersimpan berhasil ke database$wristbandInfo");
String ticketJson, companyName, companyPhone, denom;
companyName = PreferencesHelper.getString('outletname');
companyPhone = PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString('multioutletaddress');
denom = amountController!.text.replaceAll(",", "");
String sca =
PreferencesHelper.getString("multioutletservicechargeamount");
String sc = PreferencesHelper.getString("multioutletservicecharge");
String metodeBayar = PreferencesHelper.getString("provider");
String status = "Berhasil";
_getInfoBalance(info);
......@@ -616,14 +617,48 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
sca! + sc!,
(int.parse(amount) + int.parse(sca) + int.parse(sc)).toString(),
denom.replaceAll(",", ""),
metodeBayar,
status,
PreferencesHelper.getString("provider"),
"Isi Saldo Berhasil",
);
isHitApi = false;
} else {
}
else {
print('topup gagal');
AwesomeDialog(
context: context,
autoHide: Duration(seconds: 10),
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: "Transaksi isi ulang anda tidak berhasil\nsimpan bukti pembayaran untuk di tunjukkan kepada petugas",
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:
"Your top up transaction was not successful\nSave proof of payment to show to the officer",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) {
});
isShowingDialog = true;
dataQris == null;
StartService.print(
prevInfoCard,
companyName.split("-")[0],
companyAddress,
companyPhone,
approvalCode,
lastBalance!,
sca! + sc!,
(int.parse(amount) + int.parse(sca) + int.parse(sc))
.toString(),
denom.replaceAll(",", ""),
PreferencesHelper.getString("provider"),
"isi saldo tidak berhasil",
);
}
return "";
}
......@@ -700,87 +735,81 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
tapBalance();
} else {
AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title:
'Transaksi anda gagal ! dikarenakan tidak menempelkan wristband sebelumnya',
desc:
"Your transaction failed ! because didn't attach the previous card!",
btnOkOnPress: () {
String companyName, companyPhone, metodeBayar;
companyName =
PreferencesHelper.getString('outletname');
companyName =
PreferencesHelper.getString('outletname');
companyPhone =
PreferencesHelper.getString('companyphone');
companyAddress = PreferencesHelper.getString(
'multioutletaddress');
lastBalance = infoMap['balance'].toString();
metodeBayar = "link-aja";
String sca = PreferencesHelper.getString(
"multioutletservicechargeamount");
String sc = PreferencesHelper.getString(
"multioutletservicecharge");
_getInfoBalance(info);
AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
autoHide: Duration(seconds: 10),
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title:
'Transaksi isi ulang anda tidak berhasil\nsimpan bukti pembayaran untuk di tunjukkan kepada petugas',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:
"Your top up transaction was not successful\nSave proof of payment to show to the officer",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) {
Navigator.of(context).pop();
countMax = 0;
setState(() => isProcessCheck = false);
checkCountZero = false;
timer?.cancel();
isShowingDialog = true;
trxId = "";
reffNo = "";
_showTap();
tapDial();
});
StartService.print(
prevInfoCard,
companyName.split("-")[0],
companyAddress,
companyPhone,
approvalCode,
lastBalance!,
sca! + sc!,
(int.parse(amount) +
int.parse(sca) +
int.parse(sc))
.toString(),
'0',
PreferencesHelper.getString("provider"),
'Gagal',
);
// Navigator.pop(context);
},
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red)
.show();
context: context,
dismissOnTouchOutside: false,
autoHide: Duration(seconds: 5),
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title:
'Transaksi anda gagal ! dikarenakan tidak menempelkan wristband sebelumnya',
desc:
"Your transaction failed ! because didn't attach the previous card!",
).show().then((value) {
String companyName, companyPhone, metodeBayar;
companyName = PreferencesHelper.getString('outletname');
companyName = PreferencesHelper.getString('outletname');
companyPhone =
PreferencesHelper.getString('companyphone');
companyAddress =
PreferencesHelper.getString('multioutletaddress');
lastBalance = infoMap['balance'].toString();
metodeBayar = "link-aja";
String sca = PreferencesHelper.getString(
"multioutletservicechargeamount");
String sc = PreferencesHelper.getString(
"multioutletservicecharge");
_getInfoBalance(info);
AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
autoHide: Duration(seconds: 10),
dialogType: DialogType.error,
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title:
'Transaksi isi ulang anda tidak berhasil\nsimpan bukti pembayaran untuk di tunjukkan kepada petugas',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:
"Your top up transaction was not successful\nSave proof of payment to show to the officer",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) {
Navigator.of(context).pop();
countMax = 0;
setState(() => isProcessCheck = false);
checkCountZero = false;
timer?.cancel();
isShowingDialog = true;
trxId = "";
reffNo = "";
_showTap();
tapDial();
});
StartService.print(
prevInfoCard,
companyName.split("-")[0],
companyAddress,
companyPhone,
approvalCode,
lastBalance!,
sca! + sc!,
(int.parse(amount) + int.parse(sca) + int.parse(sc))
.toString(),
'0',
PreferencesHelper.getString("provider"),
'Gagal Wristband Berbeda',
);
// Navigator.pop(context);
});
}
},
btnOkIcon: Icons.cancel,
......@@ -1156,7 +1185,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Error Get Card Type") {
}
else if (isTap == "Error Get Card Type") {
print("Error Get Card Type");
await StartService.initLibrary();
AwesomeDialog(
......@@ -1181,7 +1211,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "CardInfoError: 5001") {
}
else if (isTap == "CardInfoError: 5001") {
print("CardInfoError: 5001");
await StartService.initLibrary();
AwesomeDialog(
......@@ -1206,7 +1237,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Get TicketList Error 5001") {
}
else if (isTap == "Get TicketList Error 5001") {
print("Get TicketList Error 5001");
await StartService.initLibrary();
AwesomeDialog(
......@@ -1231,8 +1263,33 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
},
btnOkColor: Colors.blue,
).show();
} else {
print("Error $isTap");
}
else {
print("Error Saat Topup Balance $isTap");
await StartService.initLibrary();
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: "Terjadi Kesalahan Saat Isi Saldo",
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:"An Error Occurred When Topup Balance",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkText: "Coba lagi",
btnOkColor: Colors.blue,
btnOkOnPress: (){
countMax = 0 ;
tapBalance();
}
).show();
}
}
});
......@@ -1720,7 +1777,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
if (timer != null)
timer?.cancel();
tapIdle();
if (mounted) {
setState(() {
amountController!.text =
......@@ -1760,7 +1816,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
if (timer != null)
timer?.cancel();
tapIdle();
if (mounted) {
setState(() {
amountController!.text =
......@@ -2180,146 +2235,150 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
child: FutureBuilder(
future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Container(); // Placeholder widget while waiting
} else {
return TextButton(
onPressed: isProcessCheck
? null
: () async {
print("Click-button-cancel");
setState(() {
isProcessCheck = true;
});
try {
bool value = await _cekStatus();
if (value) {
isProcessGet = false;
print("pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
await AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.warning,
autoHide: Duration(seconds: 3),
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title: 'Anda telah membatalkan transaksi',
desc: "You have canceled the transaction",
).show().then((value) {
Navigator.of(context).pop();
timer?.cancel();
dataQris = null;
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
});
}
} catch (e) {
// Handle any errors that occur during _cekStatus()
} finally {
setState(() => isProcessCheck = false);
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Container(); // Placeholder widget while waiting
} else {
return TextButton(
onPressed: isProcessCheck
? null
: () async {
print("Click-button-cancel");
setState(() {
isProcessCheck = true;
});
try {
bool value = await _cekStatus();
if (value) {
isProcessGet = false;
print(
"pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
await AwesomeDialog(
context: context,
dismissOnTouchOutside: false,
dialogType: DialogType.warning,
autoHide: Duration(seconds: 3),
animType: AnimType.rightSlide,
headerAnimationLoop: true,
title:
'Anda telah membatalkan transaksi',
desc:
"You have canceled the transaction",
).show().then((value) {
Navigator.of(context).pop();
timer?.cancel();
dataQris = null;
checkCountZero = false;
isShowingDialog = true;
_showTap();
tapDial();
});
}
} catch (e) {
// Handle any errors that occur during _cekStatus()
} finally {
setState(
() => isProcessCheck = false);
}
},
child: ButtonQris(
iconUrl: 'assets/cancel.png',
title: 'batalkan',
subtitle: 'cancel',
),
);
}
},
child: ButtonQris(
iconUrl: 'assets/cancel.png',
title: 'batalkan',
subtitle: 'cancel',
),
);
}
},
)),
Visibility(
visible: isShowingButton,
maintainState: true,
child: FutureBuilder(
future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot){
if (snapshot.connectionState == ConnectionState.waiting){
return Container();
} else {
return TextButton(
onPressed: isProcessCheck
? null
: () async {
AwesomeDialog(
context: context,
dialogType:
DialogType.info,
animType:
AnimType.rightSlide,
dismissOnTouchOutside:
false,
autoHide:
Duration(seconds: 2),
headerAnimationLoop: true,
title:
'Mohon Tunggu Sebentar ...',
titleTextStyle:
blackTextStyle
.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc:
"Please wait a moment ...",
descTextStyle:
greyTextStyle
.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) async {
print("Click-button-saya-sudah-bayar");
if (isProcessCheck) return;
setState(() => isProcessCheck = true);
try {
bool result = await _cekStatus();
if (result) {
isProcessGet = false;
}
setState(() {
if (result) {
isProcessCheck = true;
print("pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
isProcessCheck = false;
future: Future.delayed(Duration(seconds: 5)),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Container();
} else {
return TextButton(
onPressed: isProcessCheck
? null
: () async {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
autoHide: Duration(seconds:2),
autoHide: Duration(seconds: 2),
headerAnimationLoop: true,
title: 'Belum Terbayar !',
desc: "Not paid yet !",
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red,
).show();
}
});
} catch (e) {
print("Error: $e");
setState(() => isProcessCheck = false);
}
});
},
child: ButtonQris(
iconUrl: 'assets/check-mark.png',
title: 'Saya Sudah Bayar',
subtitle: 'i have already paid',
),
);
}
}
),
title: 'Mohon Tunggu Sebentar ...',
titleTextStyle:
blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Please wait a moment ...",
descTextStyle:
greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
).show().then((value) async {
print(
"Click-button-saya-sudah-bayar");
if (isProcessCheck) return;
setState(
() => isProcessCheck = true);
try {
bool result = await _cekStatus();
if (result) {
isProcessGet = false;
}
setState(() {
if (result) {
isProcessCheck = true;
print(
"pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
isProcessCheck = false;
AwesomeDialog(
context: context,
dialogType:
DialogType.error,
animType:
AnimType.rightSlide,
dismissOnTouchOutside:
false,
autoHide:
Duration(seconds: 2),
headerAnimationLoop: true,
title: 'Belum Terbayar !',
desc: "Not paid yet !",
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red,
).show();
}
});
} catch (e) {
print("Error: $e");
setState(
() => isProcessCheck = false);
}
});
},
child: ButtonQris(
iconUrl: 'assets/check-mark.png',
title: 'Saya Sudah Bayar',
subtitle: 'i have already paid',
),
);
}
}),
),
// Time DI Menu Qris
Column(
......@@ -2358,8 +2417,10 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
animType: AnimType.rightSlide,
autoHide: Duration(seconds: 2),
headerAnimationLoop: true,
title: 'Waktu pembayaran anda sudah habis !',
desc: "Your payment time has expired !",
title:
'Waktu pembayaran anda sudah habis !',
desc:
"Your payment time has expired !",
btnOkIcon: Icons.cancel,
btnOkColor: Colors.red)
.show()
......@@ -2372,7 +2433,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() {
if (result) {
isProcessGet = false;
print("pembayaran berhasil dilakukan");
print(
"pembayaran berhasil dilakukan");
Navigator.pop(context);
showPop(approvalCode);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment