acceptDispute method

Future<Dispute> acceptDispute({
  1. required String disputeId,
  2. String? authToken,
})

Accepts the loss on a dispute.

Square returns the disputed amount to the cardholder and updates the dispute state to ACCEPTED.

Square debits the disputed amount from the seller’s Square account. If the Square account does not have sufficient funds, Square debits the associated bank account.

Implementation

Future<Dispute> acceptDispute({
  required String disputeId,
  String? authToken,
}) async {

  authToken ??= authenticationService.getCachedToken()?.accessToken;

  Map<String, String> headers = {
    "Authorization": "Bearer ${authToken ?? ""}",
    'Content-Type': 'application/json; charset=UTF-8',
    'Accept': 'application/json',

  };

  Uri endpoint = Uri.https(
      baseUrl, "/v2/disputes/$disputeId/accept");

  //print (endpoint.toString());

  var response = await
  http.post(endpoint, headers: headers);

  if (response.statusCode == 200) {
    print (jsonDecode(response.body));
    return DisputeResponse.fromJson(jsonDecode(response.body)).dispute!;
  }
  else {
    print (response.body);
    throw PaymentException(statusCode: response.statusCode, message: DisputeResponse.fromJson(jsonDecode(response.body)).errors?[0].detail?.toString());
  }
}