GenerateCreditCardTransectionID static method
Future
GenerateCreditCardTransectionID({
- required String card_type,
- required String token,
- required String cardsixdigit,
- required String mobileNumber,
- required double txnAmount,
- required List<
Map> productDetail, - required bool is_american_express,
- required int is_cybersourse_mastercard,
- required String credit_card_bankpage_type,
- required String hash,
- required String orderId,
- required UserMetaPreference userMetaPreference,
- required int is_cybersourse_visa,
Implementation
static Future<dynamic> GenerateCreditCardTransectionID({required String card_type,
required String token,
required String cardsixdigit,
required String mobileNumber,
required double txnAmount,
required List<Map> productDetail,
required bool is_american_express,
required int is_cybersourse_mastercard,
required String credit_card_bankpage_type,
required String hash,
required String orderId,
required UserMetaPreference userMetaPreference,
required int is_cybersourse_visa}) async {
final url = Uri.parse(
ApiEndPoint.generateTransaction,
);
int TypeOfCard = 0;
if (card_type == "Visa") {
TypeOfCard = 1;
} else if (card_type == "Mastercard") {
TypeOfCard = 2;
} else if (card_type == "Amex") {
TypeOfCard = 3;
}
String cardID = "0";
if (card_type == "Amex" && is_american_express) {
cardID = "0";
} else if (credit_card_bankpage_type == "3") {
if (card_type == "Mastercard" &&
(userMetaPreference.isallowedtocybersourcemastercard == 0 || is_cybersourse_mastercard == 0)) {
cardID = "2";
credit_card_bankpage_type = "2";
} else if (card_type == "Visa" &&
(userMetaPreference.isallowedtocybersourcevisa == 0 || is_cybersourse_visa == 0)) {
cardID = "2";
credit_card_bankpage_type = "2";
} else {
cardID = credit_card_bankpage_type;
}
} else {
cardID = credit_card_bankpage_type;
}
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.CreditCard_TransactionMode_ID,
"transactionstatusId": AppConstant.TransectionInProgress,
"sourceofTxn": AppConstant.TransectionSource,
"transaction_summary": transaction_summary,
"cardschemeid": TypeOfCard,
"creditcardpaymentmodeid": int.parse(cardID),
"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}));
//var result = await http.post(url, headers: header, body: jsonEncode(body));
// Body.tostring()
// crypt()
// Buffer.from(cipherText).toString('base64')
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;
}
}