create method
Future<Response<RazorpayItem> >
create({
- required RazorpayItemCreateRequestBody params,
- void callback(
- RazorpayApiException?,
- Response<
RazorpayItem> ?
Create an Item
@param params - Check doc for required params
Implementation
Future<Response<RazorpayItem>> create({
required RazorpayItemCreateRequestBody params,
void Function(RazorpayApiException?, Response<RazorpayItem>?)? callback,
}) async {
// Input validation (amount is required in the model)
// JS check: if (!params.amount) throw Error('`amount` is mandatory')
// This is handled by the required field in the Dart model.
// Ensure currency defaults if not provided (handled by model default or here)
final data = params.toJson();
if (!data.containsKey('currency') || data['currency'] == null) {
data['currency'] = 'INR';
}
return api.post<RazorpayItem>(
{
'url': '/items',
'data': data,
},
fromJsonFactory: RazorpayItem.fromJson,
callback: callback,
);
}