sadadPayTransactions static method

Future<Map?> sadadPayTransactions({
  1. required String ipAddress,
  2. required List productDetails,
  3. required String token,
  4. required String sadadId,
  5. required int userId,
  6. required String orderId,
  7. required double amount,
})

Implementation

static Future<Map?> sadadPayTransactions(
    {required String ipAddress,
    required List productDetails,
    required String token,
    required String sadadId,
    required int userId,
      required String orderId,
    required double amount}) async {
  final url = Uri.parse(
    ApiEndPoint.sadadPayTransaction,
  );
  // Pay Via Sadad
  // ------------------------
  // Authorization (senderid token >> getting from login)
  // sadadid (token generated from index.php)
  // pay via others
  // -----------------------------------
  //    Authorization (token generated from index.php)

  Map<String, String> header = {'Content-Type': 'application/json', "Authorization": sadadId, "sadadId": token};
  Map<String, dynamic> body = {
    "createdby": userId,
    "modifiedby": userId,
    "amount": amount,
    "senderId": userId,
    "transactionstatusId": 3,
    "transactionmodeId": 3,
    "transactionentityId": 9,
    "transaction_summary": productDetails,
    "txnip": ipAddress,
    "orderId": orderId,
  };

  // var result = await http.post(
  //   url,
  //   headers: header,
  //   body: json.encode(body),
  // );
  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);
    return response;
  }
  return null;
}