GenerateDebitCardTransactionID static method

Future GenerateDebitCardTransactionID({
  1. required String token,
  2. required String mobileNumber,
  3. required double txnAmount,
  4. required List<Map> productDetail,
  5. required String hash,
  6. required String orderId,
  7. required UserMetaPreference userMetaPreference,
})

Implementation

static Future<dynamic> GenerateDebitCardTransactionID(
    {required String token,
    required String mobileNumber,
    required double txnAmount,
    required List<Map> productDetail,
    required String hash,
      required String orderId,
required UserMetaPreference userMetaPreference}) async {
  final url = Uri.parse(
    ApiEndPoint.generateTransaction,
  );

  Map<String, String> header = {'Content-Type': 'application/json', "Authorization": token};
  Map transaction_summary = {
    "MOBILE_NO": mobileNumber,
    "TXN_AMOUNT": txnAmount,
    "PRODUCT_DETAILS": productDetail,
  };
  Map body = {
    "amount": txnAmount,
    "transactionentityId": AppConstant.transection_SDK_ID,
    "transactionmodeId": AppConstant.DebitCard_TransactionMode_ID,
    "transactionstatusId": AppConstant.TransectionInProgress,
    "sourceofTxn": AppConstant.TransectionSource,
    "transaction_summary": transaction_summary,
    "encryted": true,
    "orderId": orderId,
  };

  print(url);
  String jsonString = jsonEncode(body);
  // var temp = CryptLib.instance.encryptPlainTextWithRandomIV(jsonString, "XDRvx?#Py^5V@3jC");
  // String encodedString = base64.encode(utf8.encode(temp)).trim();

  var temp = CryptLib.instance.encryptPlainTextWithRandomIV(jsonString, "XDRvx?#Py^5V@3jC");
  String tempEncoded = base64.encode(utf8.encode(temp)).trim();
  var result = await http.post(url, headers: header, body: jsonEncode({"securedata": tempEncoded}));

  if (result.statusCode == 200) {
    var response = jsonDecode(result.body);
    TransactionIdDetailsModel transactionIdDetailsModel = TransactionIdDetailsModel.fromJson(response);
    print('notification count:::${response}');
    return transactionIdDetailsModel;
  } else {
    var response = jsonDecode(result.body);
    String message = response['error']['message'];
    return message;
  }
}