voidTransaction method
Processes a void of a charge request that times out. It cannot be used to void a charge that has already been settled. Provide the request_id of the original charge as a query parameter.
Implementation
Future<Charge> voidTransaction({
required String requestId,
required String chargeRequestId,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Request-ID": requestId,
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json',
//'Accept': 'application/json',
};
Uri endpoint = Uri.https(
baseUrl, "/quickbooks/v4/payments/txn-requests/$chargeRequestId/void");
//print(endpoint.toString());
var response = await http.post(endpoint, headers: headers);
if (response.statusCode == 200 || response.statusCode == 201) {
return Charge.fromJson(jsonDecode(response.body));
} else {
throw ChargeException(
statusCode: response.statusCode, message: response.body);
}
}