sendPayment method
Sends a payment to the specified email.
Implementation
Future<Payment> sendPayment({
required String paymentId,
required String emailTo,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/octet-stream',
'Accept': 'application/json',
};
Map<String, String> params = {
"minorversion": minorVersion.toString(),
"sendTo": emailTo
};
Uri endpoint = Uri.https(
baseUrl, "/v3/company/$realmId/payment/$paymentId/send", params);
//print (endpoint.toString());
var response = await
http.post(endpoint, headers: headers);
if (response.statusCode == 200) {
//print (jsonDecode(response.body));
return Payment.fromJson(jsonDecode(response.body)["Payment"]);
}
else {
throw PaymentException(statusCode: response.statusCode, message: response.body);
}
}