fetch method
Future<Response<RazorpayRefund> >
fetch({
- required String refundId,
- String? paymentId,
- void callback(
- RazorpayApiException?,
- 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,
);
}