validateRequest static method

void validateRequest(
  1. UpiPaymentRequest request
)

Implementation

static void validateRequest(UpiPaymentRequest request) {
  validateUpiId(request.upiId);
  if (request.amount <= 0) {
    throw const UpiSdkException(
      'Amount must be greater than zero.',
      code: 'invalid_amount',
    );
  }
  if (request.name.trim().isEmpty) {
    throw const UpiSdkException(
      'Payee name cannot be empty.',
      code: 'invalid_name',
    );
  }
  if ((request.note ?? '').length > 80) {
    throw const UpiSdkException(
      'Note is too long. Keep note length under 80 characters.',
      code: 'invalid_note',
    );
  }
  if (request.currency.trim().toUpperCase() != 'INR') {
    throw const UpiSdkException(
      'Only INR currency is currently supported by this SDK.',
      code: 'invalid_currency',
    );
  }
}