createPaymentConsent method
Future<Map>
createPaymentConsent(
- String token,
- String? connectedAccountId,
- String customerId,
- String? merchantTriggerReason,
- Map<
String, dynamic> ? metadata, - String nextTriggerReason,
- Map<
String, dynamic> ? paymentMethod, - String requestId,
- bool? requiresCVC,
override
Implementation
@override
Future<Map> createPaymentConsent(
String token,
String? connectedAccountId,
String customerId,
String? merchantTriggerReason,
Map<String, dynamic>? metadata,
String nextTriggerReason,
Map<String, dynamic>? paymentMethod,
String requestId,
bool? requiresCVC) async {
final baseUrl = await getBaseUrl;
var url = Uri.parse("$baseUrl/api/v1/pa/payment_consents/create");
Map<String, dynamic> bodyData = {
"customer_id": customerId,
"next_triggered_by": nextTriggerReason,
"request_id": requestId
};
if (connectedAccountId != null) {
bodyData.addAll({"connected_account_id": connectedAccountId});
}
if (merchantTriggerReason != null) {
bodyData.addAll({"merchant_trigger_reason": merchantTriggerReason});
}
if (metadata != null) {
bodyData.addAll({"metadata": metadata});
}
if (paymentMethod != null) {
bodyData.addAll({"payment_method": paymentMethod});
}
if (requiresCVC != null) {
bodyData.addAll({"requires_cvc": requiresCVC});
}
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;
}