Class: Bakong::Khqr::MerchantCode::TransactionAmount

Inherits:
TagLengthString show all
Defined in:
lib/bakong/khqr/merchant_code/transaction_amount.rb

Instance Attribute Summary

Attributes inherited from TagLengthString

#length, #tag, #value

Instance Method Summary collapse

Methods inherited from TagLengthString

#to_s

Constructor Details

#initialize(tag, value) ⇒ TransactionAmount

Returns a new instance of TransactionAmount.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bakong/khqr/merchant_code/transaction_amount.rb', line 12

def initialize(tag, value)
  string_value = value.to_s
  if string_value.length > EMV[:INVALID_LENGTH][:AMOUNT] ||
     string_value.include?("-") ||
     value.nil? ||
     string_value == ""
    raise Error.from(ERROR_CODES[:TRANSACTION_AMOUNT_INVALID])
  end

  super
end