Commit 109adcce authored by Izol's avatar Izol

fixing errror code #!

parent 28446cca
...@@ -31,15 +31,15 @@ ...@@ -31,15 +31,15 @@
<option name="name" value="maven2" /> <option name="name" value="maven2" />
<option name="url" value="https://jitpack.io" /> <option name="url" value="https://jitpack.io" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://mobile-repo.mdd.co.id/artifactory/android-library/" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="maven3" /> <option name="id" value="maven3" />
<option name="name" value="maven3" /> <option name="name" value="maven3" />
<option name="url" value="https://plugins.gradle.org/m2/" /> <option name="url" value="https://plugins.gradle.org/m2/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://mobile-repo.mdd.co.id:8081/artifactory/android-library/" />
</remote-repository>
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -179,14 +179,14 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT ...@@ -179,14 +179,14 @@ class MainActivity : MethodChannel.MethodCallHandler, FlutterActivity(), MifareT
} }
override fun onErrorOperation(reason: String?, errorCode: String) { override fun onErrorOperation(reason: String?, errorCode: String) {
Log.d("onErrorOperation", reason.toString()) val errorMessage = "$error: $reason"
Log.d("onErrorOperation", errorMessage)
Log.d("ini pesan errorCode", errorCode) Log.d("ini pesan errorCode", errorCode)
if (errorCode == "103F") {
result?.success(reason) if (errorCode == "103F" || errorCode == "0005") {
} else if (errorCode == "0005") { result?.success(errorMessage)
result?.success(reason)
} else { } else {
result?.success(reason) result?.success(errorMessage)
} }
} }
......
sdk.dir=/Users/macbookpro/Library/Android/sdk sdk.dir=/Users/macbookpro/Library/Android/sdk
flutter.sdk=/Users/macbookpro/Developer/flutter flutter.sdk=/Users/macbookpro/Developer/flutter
flutter.buildMode=debug flutter.buildMode=debug
flutter.versionName=SS.21.WWW flutter.versionName=1.0.0
flutter.versionCode=14 flutter.versionCode=1
\ No newline at end of file \ No newline at end of file
...@@ -97,6 +97,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -97,6 +97,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
bool isPaymentProcessed = false; bool isPaymentProcessed = false;
double _targetDuration = 3; // Durasi yang dituju (dalam detik) double _targetDuration = 3; // Durasi yang dituju (dalam detik)
double _maxDurationPage = 3; // Durasi maksimum (dalam detik) double _maxDurationPage = 3; // Durasi maksimum (dalam detik)
bool isPaymentSuccessful = false;
String latestTransaction = "";
late Timer timerPageHome; late Timer timerPageHome;
var infoCard, var infoCard,
...@@ -456,6 +458,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -456,6 +458,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
paymentNotes, paymentNotes,
metodeBayar, metodeBayar,
status; status;
isPaymentSuccessful = false;
info = await StartService.topupBalanceCard(cardNumber, int.parse(amount)); info = await StartService.topupBalanceCard(cardNumber, int.parse(amount));
if (info == null) { if (info == null) {
...@@ -491,6 +494,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -491,6 +494,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
paymentMethod, paymentMethod,
paymentProvider, paymentProvider,
paymentNotes); paymentNotes);
countMax = 0;
checkCountZero = false;
timer?.cancel();
isShowingDialog = true;
dataQris = null;
print('topUpConfirm result: $result'); print('topUpConfirm result: $result');
String readerDate, String readerDate,
...@@ -585,6 +595,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -585,6 +595,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
checkCountZero = false; checkCountZero = false;
timer?.cancel(); timer?.cancel();
isShowingDialog = true; isShowingDialog = true;
_showTap(); _showTap();
tapDial(); tapDial();
}); });
...@@ -602,6 +613,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -602,6 +613,7 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
status, status,
); );
isHitApi = false; isHitApi = false;
dataQris = null;
} else { } else {
print('topup gagal'); print('topup gagal');
isShowingDialog = true; isShowingDialog = true;
...@@ -628,12 +640,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -628,12 +640,8 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
.toString() .toString()
.toLowerCase() .toLowerCase()
.contains('settlement')) { .contains('settlement')) {
Navigator.pop(context);
//TODO: getcard
tapBalance();
showPop(approvalCode);
dataQris = null;
result = true; result = true;
isPaymentSuccessful = true;
} else { } else {
result = false; result = false;
if (!isBackgroundServices) { if (!isBackgroundServices) {
...@@ -1054,87 +1062,32 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1054,87 +1062,32 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
Future.delayed(const Duration(milliseconds: 500), () async { Future.delayed(const Duration(milliseconds: 500), () async {
// await StartService.initLibrary(); // await StartService.initLibrary();
var isTap = await StartService.getCard(); var isTap = await StartService.getCard();
try { try {
var infoMap = jsonDecode(isTap); var infoMap = jsonDecode(isTap);
_getInfoBeforeTopup(isTap); _getInfoBeforeTopup(isTap);
} catch (e) { } catch (e) {
String errorMessage = "";
String dialogTitle = "Coba Lagi!";
String dialogDesc = "Try Again!";
if (isTap == "Card Not Found") { if (isTap == "Card Not Found") {
print("Card Not Found"); errorMessage = "Card Not Found";
await StartService.initLibrary(); dialogTitle = "Pastikan Wristband Anda Tertempel Di Reader!";
AwesomeDialog( dialogDesc = "Make sure your wristband is attached to the reader!";
context: context, } else if (isTap == "Error Get Card Type") {
dialogType: DialogType.info, errorMessage = "Error Get Card Type";
animType: AnimType.rightSlide, } else if (isTap == "CardInfoError: 5001") {
dismissOnTouchOutside: false, errorMessage = "CardInfoError: 5001";
headerAnimationLoop: true, } else if (isTap == "ERROR_INVALID_CARD(0x0005)") {
title: 'Pastikan Wristband Anda Tertempel Di Reader!', errorMessage = "Error Invalid Card";
titleTextStyle: blackTextStyle.copyWith( } else if (isTap == "ERROR_GET_TICKET_QUOTA(0x0204)") {
fontSize: 20, errorMessage = "Error Get Ticket Quota";
fontWeight: bold, } else {
), errorMessage = "Error $isTap";
desc: "Make sure your wristband is attached to the reader!", }
descTextStyle: greyTextStyle.copyWith(
fontSize: 18, print(errorMessage);
fontWeight: light,
),
btnOkOnPress: () {
countMax = 0;
tapBalance();
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Error Get Card Type"){
print("Error Get Card Type");
await StartService.initLibrary();
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Coba Lagi!',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Try Again!",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkOnPress: () {
countMax = 0;
tapBalance();
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "CardInfoError: 5001"){
print("CardInfoError: 5001");
await StartService.initLibrary();
AwesomeDialog(
context: context,
dialogType: DialogType.info,
animType: AnimType.rightSlide,
dismissOnTouchOutside: false,
headerAnimationLoop: true,
title: 'Coba Lagi!',
titleTextStyle: blackTextStyle.copyWith(
fontSize: 20,
fontWeight: bold,
),
desc: "Try Again!",
descTextStyle: greyTextStyle.copyWith(
fontSize: 18,
fontWeight: light,
),
btnOkOnPress: () {
countMax = 0;
tapBalance();
},
btnOkColor: Colors.blue,
).show();
} else if (isTap == "Get TicketList Error 5001"){
print("Get TicketList Error 5001");
await StartService.initLibrary(); await StartService.initLibrary();
AwesomeDialog( AwesomeDialog(
context: context, context: context,
...@@ -1142,12 +1095,12 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1142,12 +1095,12 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
animType: AnimType.rightSlide, animType: AnimType.rightSlide,
dismissOnTouchOutside: false, dismissOnTouchOutside: false,
headerAnimationLoop: true, headerAnimationLoop: true,
title: 'Coba Lagi!', title: dialogTitle,
titleTextStyle: blackTextStyle.copyWith( titleTextStyle: blackTextStyle.copyWith(
fontSize: 20, fontSize: 20,
fontWeight: bold, fontWeight: bold,
), ),
desc: "Try Again!", desc: dialogDesc,
descTextStyle: greyTextStyle.copyWith( descTextStyle: greyTextStyle.copyWith(
fontSize: 18, fontSize: 18,
fontWeight: light, fontWeight: light,
...@@ -1158,13 +1111,46 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -1158,13 +1111,46 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
}, },
btnOkColor: Colors.blue, btnOkColor: Colors.blue,
).show(); ).show();
} else{
print("Error $isTap");
}
} }
}); });
} }
// ERROR_GET_TICKET_LIST(0x0203),!
// ERROR_CARD_INFO(0x0202),!
// ERROR_GET_CARD_TYPE(0x0207), !
//
// NO_ERROR(0x0000),
// ERROR_INVALID_CARD(0x0005),
// ERROR_GET_TICKET_QUOTA(0x0204),
// ERROR_GET_REG_DB(0x0205),
// ERROR_POST_PERSO(0x0206),
// ERROR_TOPUP_TICKET(0x0208),
// ERROR_TOPUP_BALANCE(0x0209),
// ERROR_REDEEM_TICKET(0x020A),
// ERROR_DEDUCT_BALANCE(0x020B),
// ERROR_REFUND_CARD(0x020C),
// ERROR_REFUND_DEPOSIT_BALANCE_CARD(0x020D),
// ERROR_MULTIBINDING(0x020E),
// ERROR_HOST_VALIDATION_FAILED(0x0401),
// ERROR_CARD_NOT_FOUND(0xFFD0),
// ERROR_UNKNOWN(0xFFFF),
//
// ERROR_INSUFFICIENT_FUND(0x1003),
// ERROR_INSUFFICIENT_FUND1(0x100B),
// ERROR_CARD_EXPIRED(0x100F),
// ERROR_TICKET_NOT_FOUND(0x1010),
// ERROR_TICKET_EXPIRED(0x1011),
// ERROR_HOST_VALIDATION(0x1012),
// ERROR_DAILY_VALIDATION(0x1013),
// ERROR_CRC_ERROR(0x1027),
//
// ERROR_MIFARE_AUTH(0x5001),
// ERROR_WRONG_CARD_TYPE(0x5002),
// ERROR_MIFARE_READ(0x5005),
// ERROR_MIFARE_WRITE(0x5006),
// ERROR_BROKEN_CARD(0x5009),
// ERROR_MIFARE_SUSPECT_EXP_DATE(0x5009),
Future<void> _showTap() { Future<void> _showTap() {
return showDialog<void>( return showDialog<void>(
...@@ -2067,7 +2053,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2067,7 +2053,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
SizedBox( SizedBox(
height: 5, height: 5,
), ),
// Container Button Batalakan, Saya Sudah Bayar Dan TimeOut
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
...@@ -2079,10 +2064,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2079,10 +2064,13 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() => isProcessCheck = true); setState(() => isProcessCheck = true);
try { try {
bool result = await _cekStatus(); bool result = await _cekStatus();
setState((){
if (result) { if (result) {
print("pembayaran berhasil dilakukan"); print("pembayaran berhasil dilakukan");
Navigator.pop(context);
//TODO: getcard
tapBalance();
showPop(approvalCode); showPop(approvalCode);
dataQris = null;
} else { } else {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
...@@ -2104,7 +2092,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2104,7 +2092,6 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
tapDial(); tapDial();
}); });
} }
});
} catch (e) { } catch (e) {
print("Error: $e"); print("Error: $e");
setState(() => isProcessCheck = false); setState(() => isProcessCheck = false);
...@@ -2162,15 +2149,18 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2162,15 +2149,18 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
// Button Saya sudah Bayar di Showqris // Button Saya sudah Bayar di Showqris
TextButton( TextButton(
onPressed: () async { onPressed: () async {
if (isProcessCheck) return; // Tambahkan pengecekan jika proses sedang berjalan if (isProcessCheck) return;
setState(() => isProcessCheck = true); setState(() => isProcessCheck = true);
try { try {
bool result = await _cekStatus(); bool result = await _cekStatus();
setState(() { if (result && isPaymentSuccessful) {
if (result) {
print("pembayaran berhasil dilakukan"); print("pembayaran berhasil dilakukan");
isPaymentSuccessful = true;
Navigator.pop(context); Navigator.pop(context);
//TODO: getcard
tapBalance();
showPop(approvalCode); showPop(approvalCode);
dataQris = null;
} else { } else {
AwesomeDialog( AwesomeDialog(
context: context, context: context,
...@@ -2186,10 +2176,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback { ...@@ -2186,10 +2176,11 @@ class _HomePageState extends State<HomePage> implements AlertDialogCallback {
setState(() => isProcessCheck = false); setState(() => isProcessCheck = false);
}); });
} }
});
} catch (e) { } catch (e) {
print("Error: $e"); print("Error: $e");
setState(() => isProcessCheck = false); setState(() => isProcessCheck = false);
} finally {
setState(() => isProcessCheck = false);
} }
}, },
child: (isProcessCheck) child: (isProcessCheck)
......
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