createRefund method
Future<Map>
createRefund(
- String token,
- String? amount,
- Map<
String, dynamic> ? metadata, - String? paymentAttemptId,
- String? paymentIntentId,
- String? reason,
- String requestId,
override
Implementation
@override
Future<Map> createRefund(
String token,
String? amount,
Map<String, dynamic>? metadata,
String? paymentAttemptId,
String? paymentIntentId,
String? reason,
String requestId) async {
final baseUrl = await getBaseUrl;
var url = Uri.parse("$baseUrl/api/v1/pa/refunds/create");
Map<String, dynamic> bodyData = {
"request_id": requestId,
};
if (amount != null) {
bodyData.addAll({"amount": amount});
}
if (metadata != null) {
bodyData.addAll({"metadata": metadata});
}
if (paymentAttemptId != null) {
bodyData.addAll({"payment_attempt_id": paymentAttemptId});
}
if (paymentIntentId != null) {
bodyData.addAll({"payment_intent_id": paymentIntentId});
}
if (reason != null) {
bodyData.addAll({"reason": reason});
}
var jsonBody = jsonEncode(bodyData);
var response = await http.post(
url,
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer $token"
},
body: jsonBody,
);
var data = jsonDecode(response.body);
return data;
}