fetch method
Future<Response<RazorpayToken> >
fetch({
- required String tokenId,
- void callback(
- RazorpayApiException?,
- Response<
RazorpayToken> ?
Fetch card properties of an existing token (Token HQ)
@param tokenId - The ID of the token to fetch.
Implementation
Future<Response<RazorpayToken>> fetch({
required String tokenId,
void Function(RazorpayApiException?, Response<RazorpayToken>?)? callback,
}) async {
if (tokenId.isEmpty) {
throw ArgumentError('tokenId is required');
}
// Note: JS uses POST for fetch, which is unusual. Following JS implementation.
return api.post<RazorpayToken>(
{
'url': '$BASE_URL/fetch',
'data': {'id': tokenId}, // Pass ID in the body
},
fromJsonFactory: RazorpayToken.fromJson,
callback: callback,
);
}