fetch method

Future<Response<RazorpayRefund>> fetch({
  1. required String refundId,
  2. String? paymentId,
  3. void callback(
    1. RazorpayApiException?,
    2. Response<RazorpayRefund>?
    )?,
})

Fetch a refund given Refund ID (optionally within payment context)

@param refundId - The unique identifier of the refund. @param paymentId - Optional: The unique identifier of the payment.

Implementation

Future<Response<RazorpayRefund>> fetch({
  required String refundId,
  String? paymentId, // Optional payment context
  void Function(RazorpayApiException?, Response<RazorpayRefund>?)? callback,
}) async {
  if (refundId.isEmpty) {
    throw ArgumentError('`refund_id` is mandatory');
  }

  var url = '/refunds/$refundId';
  if (paymentId != null && paymentId.isNotEmpty) {
    url = '/payments/$paymentId$url'; // Prepend payment path
  }

  return api.get<RazorpayRefund>(
    {'url': url},
    fromJsonFactory: RazorpayRefund.fromJson,
    callback: callback,
  );
}