toMap method
toMap
return map object
Implementation
Map<String, dynamic> toMap() {
String _encodedItem = "";
if (this.items?.isNotEmpty == true) {
if (this.amount != this.totalPrice) {
ABAPayment.logger
.error("amount $amount is not equal totalPrice $totalPrice");
}
var itemText = [...this.items!.map((e) => e.toMap()).toList()];
_encodedItem = base64Encode(json.encode(itemText).runes.toList());
// _encodedItem = "W3sibmFtZSI6InRlc3QiLCJxdWFudGl0eSI6MSwicHJpY2UiOjZ9XQ==";
ABAPayment.logger.info("itemText $itemText");
ABAPayment.logger.info("_encodedItem $_encodedItem");
}
var _currency = "USD";
var _type = "purchase";
String _hash = ABAClientHelper(merchant).getHash(
reqTime: reqTime,
tranID: tranID!,
amount: "$amount",
items: _encodedItem,
shipping: "$shipping",
firstName: firstname,
lastName: lastname,
email: email,
phone: phone,
type: _type,
paymentOption: paymentOption!.toText,
currency: _currency,
);
ABAPayment.logger.info("req_time $reqTime");
ABAPayment.logger.info("tran_id $tranID");
ABAPayment.logger.info("_hash $_hash");
ABAPayment.logger.info("amount $amount");
var map = {
"req_time": reqTime,
"tran_id": tranID,
"amount": "$amount",
"items": "$_encodedItem",
"hash": "$_hash",
"firstname": "$firstname",
"lastname": "$lastname",
"phone": "$phone",
"email": "$email",
"return_url": returnUrl,
"continue_success_url": continueSuccessUrl ?? "",
"return_params": returnParams ?? "",
// "return_params": {"tran_id": tranID, "status": 0},
// "phone_country_code": phoneCountryCode ?? "855",
// "PreAuth": preAuth,
"payment_option": "${paymentOption!.toText}",
"shipping": "$shipping",
"currency": "$_currency",
"merchant_id": "${merchant!.merchantID}",
"type": _type,
};
return map;
}