postPayment method
Implementation
Future<String?> postPayment(BuildContext context) async {
if (selectedPaymentTypeGroupIndex.value == 999) {
showSnackbar(
title: "Informasi",
body: "Silakan Pilih Pembayaran.",
);
return null;
} else if (tfIdBillingController.text == "") {
showSnackbar(
title: "Informasi",
body:
"Silakan Masukkan ${listPaymentTypeGroup[selectedPaymentTypeGroupIndex.value].label}",
);
return null;
}
PaymentTypeGroup data =
listPaymentTypeGroup[selectedPaymentTypeGroupIndex.value];
var total = 0;
if (data.isManualInput == "1" || data.isManualInput == "2") {
if (tfTotalController.text == "") {
showSnackbar(
title: "Informasi",
body: "Silakan Masukkan Nominal.",
);
return null;
} else {
var totalText = "";
var splits = tfTotalController.text.split('.');
for (var split in splits) {
totalText = "$totalText$split";
}
total = int.parse(totalText);
}
}
if (selectedPaymentMethodIndex.value == 999) {
showSnackbar(
title: "Informasi",
body: "Silakan Pilih Metode Pembayaran.",
);
return null;
}
loadingPayment.value = true;
// await service.cancelRequest();
var result = await service.payment({
"id_billing": tfIdBillingController.text,
"payment_type": data.code,
"payment_method":
data.bankCategory?[selectedPaymentMethodIndex.value].methodId,
"trx_amount": total,
"payment_category":
data.bankCategory?[selectedPaymentMethodIndex.value].code,
"platform_type": "MOBILE",
'partner_id': await Preferences().getUdid(),
});
loadingPayment.value = false;
if (result.code == 200) {
// Get.to(() => VirtualAccountScreen(clientRefnum: result.data?.clientRefnum ?? ''), arguments:result.data?.clientRefnum );
// Get.toNamed(
// Strings.virtualAccountRoute,
// arguments: result.data?.clientRefnum,
// );
return result.data?.clientRefnum;
} else if ((result.code ?? 0) >= 400 && (result.code ?? 0) < 500) {
sheetError(
context: Get.context!,
typeError: 400,
msg: result.message,
);
} else {
sheetError(
context: Get.context!,
typeError: 500,
msg: result.message,
);
}
return null;
}