getPaymentLaunchUrl function
Future<Map<String, dynamic>>
getPaymentLaunchUrl(
{ - required String clientId,
- required String clientSecret,
- required String email,
- required String mobileNumber,
- required String orderId,
- required double amount,
- required String currencyCode,
- required String transactionId,
- required String transactionType,
})
Implementation
Future<Map<String, dynamic>> getPaymentLaunchUrl({
required String clientId,
required String clientSecret,
required String email,
required String mobileNumber,
required String orderId,
required double amount,
required String currencyCode,
required String transactionId,
required String transactionType,
}) async {
final String baseUrl = Environment.getBaseUrl();
final String apiUrl = '$baseUrl$gatewayLoginUrl';
final Map<String, String> headers = {
"Accept": "application/json",
"Content-Type": "application/json",
};
final Map<String, dynamic> postData = {
"clientId": clientId,
"clientSecret": clientSecret,
"clientDetails": {"originatedBy": "something"},
"clientUserDetails": {"email": email, "mobileNumber": mobileNumber},
"orderDetails": {
"orderId": orderId,
"amount": amount,
"currencyCode": currencyCode
},
"transactionDetails": {
"transactionId": transactionId,
"transactionType": transactionType
}
};
try {
Get.showLoader();
final response = await http.post(
Uri.parse(apiUrl),
headers: headers,
body: json.encode(postData),
);
if (response.statusCode == 200) {
Get.closeLoader();
final Map<String, dynamic> data = json.decode(response.body);
return data;
} else {
Get.closeLoader();
throw Exception('Failed to post data');
}
} catch (e) {
Get.closeLoader();
throw Exception('Error: $e');
}
}