bankPayment method
dynamic
bankPayment()
Implementation
bankPayment(
BuildContext context,
String id,
String cartId,
String bankName,
String branchName,
String refNbr,
String amount,
String date,
String accNbr,
int receiptId) async {
Helper.progressDialog(context, "Please wait..");
// printLogs(dio);
String requestTime = "";
String responseTime = "";
dio
.post(
'${ApiConstant.posBaseUrl}pos-payment-service-svc/payment-collection/carts/$cartId',
data: json.encode({
"modeList": [
{
"id": id,
"collection": [
[
{
"amount": false,
"configs": {},
"fieldMappingKey": "bankName",
"fieldType": "DROPDOWN",
"formatAmount": false,
"id": "1",
"label": "pos.common.payment.mode.bankName",
"value": bankName,
},
{
"amount": true,
"configs": {},
"fieldMappingKey": "bankAmount",
"fieldType": "INPUT",
"formatAmount": true,
"id": "8",
"label": "pos.common.payment.mode.amount",
"value": amount,
},
{
"amount": false,
"configs": {},
"fieldMappingKey": "smartBankName",
"fieldType": "DROPDOWN",
"formatAmount": false,
"id": "24",
"label": "pos.common.payment.mode.bank.seller.name",
"value": bankName,
},
{
"amount": false,
"configs": {},
"fieldMappingKey": "smartBankAccount",
"fieldType": "DROPDOWN",
"formatAmount": false,
"id": "25",
"label": "pos.common.payment.mode.bank.seller.account",
"value": accNbr,
},
{
"amount": false,
"configs": {},
"fieldMappingKey": "bankOtcDepositAmount",
"fieldType": "INPUT",
"formatAmount": true,
"id": "35",
"label": "pos.common.payment.mode.depositAmount",
"value": amount,
},
{
"amount": false,
"configs": {},
"fieldMappingKey": "date",
"fieldType": "DATE_PICKER",
"formatAmount": false,
"id": "22",
"label": "pos.common.payment.mode.bank.date",
"value": date,
},
{
"amount": false,
"configs": {},
"fieldMappingKey": "branch",
"fieldType": "DROPDOWN",
"formatAmount": false,
"id": "4",
"label": "pos.common.payment.mode.bank.branch",
"value": branchName,
},
{
"amount": false,
"configs": {},
"fieldMappingKey": "transactionReferenceNumber",
"fieldType": "INPUT",
"formatAmount": false,
"id": "5",
"label": "pos.common.payment.mode.bank.refNo",
"value": refNbr
},
]
]
}
],
"currency": "USD"
}),
options: Options(
headers: {
'x-request-txn-id': UDID.uDID,
'x-trace-id': UDID.uDIDTraceId,
'X-User-Id': SecureStorageService.readSecureData(
SecureStorageService.xUserId,
),
'X-User-Name': SecureStorageService.readSecureData(
SecureStorageService.xUserName,
),
'Authorization': "Bearer ${SecureStorageService.readSecureData(
SecureStorageService.accessToken,
)}",
},
),
)
.then((response) {
Get.back();
UDID.setTraceId(response.headers.map[Constants.traceIdKey]?[0] ?? "");
Helper.logEvent(
"RESPONSE_EVENT",
success: true,
endPoint: "pos-payment-service-svc/payment-collection/carts/$cartId",
responseDate: responseTime,
screenName: "stockOrderCart",
requestDate: requestTime,
transactionId: cartId,
);
if (response.data != null) {
ConditionalLogs().customLog('paymentCollect${response.data}');
PaymentCollection model = PaymentCollection();
Map<String, dynamic> creditData = response.data;
model = PaymentCollection.fromJson(creditData);
if (model.status == 'POS200') {
orderCreation(
context,
model.data!.paymentCollectionByModeList![0].cartId!,
model.data!.transactionId!,
storage.read("transactionType") ?? "SELL_IN",
isBank: true,
);
} else {
Helper.messageDialog(
Get.context!,
model.errors?[0]?["errorItem"]["errorCode"] ??
localization.translate("tryAgain"),
model.errors?[0]?["errorItem"]["errorMessage"] ??
localization.translate("somethingWentWrong"),
);
}
}
}).catchError((error) {
ConditionalLogs().customLog("$error");
if (error is DioException) {
UDID.setTraceId(
error.response?.headers.map[Constants.traceIdKey]?[0] ?? "",
);
Helper.logEvent(
"ERROR_EVENT",
failure: true,
requestDate: requestTime,
endPoint: "pos-payment-service-svc/payment-collection/carts/$cartId",
responseDate: DateTime.now().toString(),
screenName: "stockOrder",
transactionId: cartId,
error: error,
isFinal: true,
);
}
Get.back();
MainController mainController = Get.put(MainController());
mainController.showErrorPopup();
});
}