Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constant symbol #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/rspayd/czech_payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CzechPayment < Payment
# vs - Variabilní symbol.
# ss - Specifický symbol.

attr_reader :accountPrefix, :accountNumber, :bankCode, :vs, :ss
attr_reader :accountPrefix, :accountNumber, :bankCode, :vs, :ss, :ks

def initialize(options)
options = Hash[options.map { |(k, v)| [k.to_sym, v] }]
Expand All @@ -29,6 +29,7 @@ def initialize(options)

@vs = options[:vs]
@ss = options[:ss]
@ks = options[:ks]

super
end
Expand All @@ -46,6 +47,7 @@ def to_s
out = [ super ]
out << "*X-VS:#{vs}" if vs
out << "*X-SS:#{ss}" if ss
out << "*X-KS:#{ks}" if ks
out.join
end
end
Expand Down
14 changes: 14 additions & 0 deletions test/czech_payment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ def test_sample_payment
assert_equal 'SPD*1.0*ACC:CZ5855000000001265098001*AM:480.50*CC:CZK*RF:7004139146*DT:20120524*MSG:PLATBA ZA ZBOZI*X-SS:1234567890', result
end

def test_czech_payment_with_constant_symbol
result = Rspayd::CzechPayment.generate_string(
:accountNumber => '810883001',
:bankCode => '5500',
:amount => 430.00,
:vs => '31030001',
:ks => '1234567890',
:message => 'Platba za domenu'
)

assert_equal 'SPD*1.0*ACC:CZ9555000000000810883001*AM:430.00*CC:CZK*MSG:PLATBA ZA DOMENU*X-VS:31030001*X-KS:1234567890', result
end


def test_iban_checksum_prepend
result = Rspayd::CzechPayment.new(
:accountNumber => '2950281886',
Expand Down