toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final data = <String, dynamic>{
    'key': key,
    'txnid': txnid,
    'amount': amount,
    'productinfo': productinfo,
    'firstname': firstname,
    'phone': phone,
    'email': email,
    'surl': surl,
    'furl': furl,
    'hash': hash,
  };

  // Add optional parameters only if they are not null
  if (udf1 != null) data['udf1'] = udf1;
  if (udf2 != null) data['udf2'] = udf2;
  if (udf3 != null) data['udf3'] = udf3;
  if (udf4 != null) data['udf4'] = udf4;
  if (udf5 != null) data['udf5'] = udf5;
  if (udf6 != null) data['udf6'] = udf6;
  if (udf7 != null) data['udf7'] = udf7;
  if (address1 != null) data['address1'] = address1;
  if (address2 != null) data['address2'] = address2;
  if (city != null) data['city'] = city;
  if (state != null) data['state'] = state;
  if (country != null) data['country'] = country;
  if (zipcode != null) data['zipcode'] = zipcode;
  if (showPaymentMode != null) data['show_payment_mode'] = showPaymentMode;
  if (splitPayments != null) data['split_payments'] = splitPayments;
  if (requestFlow != null) data['request_flow'] = requestFlow;
  if (subMerchantId != null) data['sub_merchant_id'] = subMerchantId;
  if (paymentCategory != null) data['payment_category'] = paymentCategory;
  if (accountNo != null) data['account_no'] = accountNo;
  if (ifsc != null) data['ifsc'] = ifsc;

  return data;
}