sadadPayTransactionV6 static method
Implementation
static Future<Map?> sadadPayTransactionV6(
{required String ipAddress,
required List productDetails,
required String token,
required String otp,
required int userId,
required String orderId,
required String issandboxmode,
required double amount, required String sadadId}) async {
final url = Uri.parse(
ApiEndPoint.sadadPayTransationV6,
);
Map<String, String> header = {'Content-Type': 'application/json'};
final body = json.encode({
"amount": amount,
"sadadId":sadadId,
"token": token,
"orderId": orderId,
"ipAddress": ipAddress,
"productDetails": productDetails,
"userId": userId,
"otp": otp,
"issandboxmode" : issandboxmode,
});
var result = await http.post(
url,
headers: header,
body: body
);
if (result.statusCode == 200) {
var response = jsonDecode(result.body);
return response;
} else {
final Map<String, dynamic> jsonData = json.decode(result.body);
ErrorResponse errorResponse = ErrorResponse.fromJson(jsonData);
// Extract the error message
final errorMessage = errorResponse.error.message;
print('Error Message: $errorMessage');
// Return the error details as a map
return {
'statusCode': errorResponse.error.statusCode,
'name': errorResponse.error.name,
'message': errorMessage,
};
}
return null;
}