createPaymentMethod method
Future<Map>
createPaymentMethod(
- String token,
- Map<
String, dynamic> ? applepay, - Map<
String, dynamic> ? card, - Map<
String, dynamic> ? googlepay, - String customerId,
- Map<
String, dynamic> ? metadata, - String requestId,
- String type,
override
Implementation
@override
Future<Map> createPaymentMethod(
String token,
Map<String, dynamic>? applepay,
Map<String, dynamic>? card,
Map<String, dynamic>? googlepay,
String customerId,
Map<String, dynamic>? metadata,
String requestId,
String type) async {
final baseUrl = await getBaseUrl;
var url = Uri.parse("$baseUrl/api/v1/pa/payment_methods/create");
Map<String, dynamic> bodyData = {
"customer_id": customerId,
"request_id": requestId,
"type": type
};
if (applepay != null) {
bodyData.addAll({"applepay": applepay});
}
if (card != null) {
bodyData.addAll({"card": card});
}
if (googlepay != null) {
bodyData.addAll({"googlepay": googlepay});
}
if (metadata != null) {
bodyData.addAll({"metadata": metadata});
}
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;
}