fetchMultipleRefund method

Future<Response<RazorpayPaymentRefundsResponse>> fetchMultipleRefund({
  1. required String paymentId,
  2. RazorpayPaginationOptions? params,
  3. void callback(
    1. RazorpayApiException?,
    2. Response<RazorpayPaymentRefundsResponse>?
    )?,
})

Fetch multiple refunds for a payment

@param paymentId - The unique identifier of the payment. @param params - Pagination options.

Implementation

Future<Response<RazorpayPaymentRefundsResponse>> fetchMultipleRefund({
  required String paymentId,
  RazorpayPaginationOptions? params,
  void Function(
    RazorpayApiException?,
    Response<RazorpayPaymentRefundsResponse>?,
  )? callback,
}) async {
  if (paymentId.isEmpty) {
    throw ArgumentError(ID_REQUIRED_MSG);
  }

  var from = params?.from;
  var to = params?.to;
  final count = params?.count ?? 10;
  final skip = params?.skip ?? 0;

  if (from != null) {
    from = normalizeDate(from);
  }
  if (to != null) {
    to = normalizeDate(to);
  }

  final queryParams = {
    'from': from,
    'to': to,
    'count': count,
    'skip': skip,
    ...?params?.toJson(),
  };
  queryParams.removeWhere((key, value) => value == null);

  return api.get<RazorpayPaymentRefundsResponse>(
    {
      'url': '$BASE_URL/$paymentId/refunds',
      'data': queryParams,
    },
    fromJsonFactory: RazorpayPaymentRefundsResponse.fromJson,
    callback: callback,
  );
}