create method

Future<RazorpayItem> create({
  1. required RazorpayItemCreateRequestBody params,
})

Create an Item

@param params - Check doc for required params

Implementation

Future<RazorpayItem> create({
  required RazorpayItemCreateRequestBody params,
}) 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,
  ).then((value) => value.data!);
}