fetch method

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

Fetch a payment

@param paymentId - The unique identifier of the payment. @param params - Check doc for required params (expand)

Implementation

Future<Response<RazorpayPayment>> fetch({
  required String paymentId,
  List<String>? expand, // Use List<String> for expand
  void Function(RazorpayApiException?, Response<RazorpayPayment>?)? callback,
}) async {
  if (paymentId.isEmpty) {
    throw ArgumentError(ID_REQUIRED_MSG);
  }

  final queryParams = {
    if (expand != null) 'expand[]': expand,
  };

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