rspayd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/lib/rspayd/version.rb +3 -0
- data/lib/rspayd.rb +52 -0
- data/rspayd.gemspec +17 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jiří Kubíček, KRAXNET s.r.o.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Rspayd
|
2
|
+
|
3
|
+
SPAYD (Short Payment Descriptor) is a format used by CBA (Česká bankovní asociace) for QR Payment (QR Platba). This gem generates payment info in SPAYD format.
|
4
|
+
|
5
|
+
Great for use with ruby QR code gem [rqrcode](http://whomwah.github.com/rqrcode/).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'rspayd'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rspayd
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
>> Rspayd::CzechPayment.generate_string(
|
24
|
+
:accountNumber=>'810883001',
|
25
|
+
:bankCode => '5500',
|
26
|
+
:amount => 430.00,
|
27
|
+
:vs=>"31030001",
|
28
|
+
:message => "Platba za domenu"
|
29
|
+
)
|
30
|
+
=> SPD*1.0*IBAN:CZ9555000000000810883001*AM:430.00*CC:CZK*X-VS:31030001*MSG:PLATBA ZA DOMENU
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
This gem implements only the basic SPLAY subset needed for simple payment in Czech Republic. Feel free to extend this gem based on your needs and send pull requests.
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/rspayd.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "rspayd/version"
|
2
|
+
|
3
|
+
module Rspayd
|
4
|
+
class CzechPayment
|
5
|
+
|
6
|
+
# accountPrefix - Předčíslí čísla účtu, na který se mají poslat prostředky.
|
7
|
+
# accountNumber - Číslo účtu, na který se mají poslat prostředky.
|
8
|
+
# bankCode - Kód banky účtu, na který se mají poslat prostředky.
|
9
|
+
# amount - Částka platby.
|
10
|
+
# currency - Měna platby.
|
11
|
+
# vs - Variabilní symbol.
|
12
|
+
# message - Zpráva pro příjemce
|
13
|
+
|
14
|
+
attr_reader :accountPrefix, :accountNumber, :bankCode, :amount, :currency, :vs, :message
|
15
|
+
|
16
|
+
def initialize(options)
|
17
|
+
options = Hash[options.map{|(k,v)| [k.to_sym,v]}]
|
18
|
+
@accountPrefix = options[:accountPrefix] || ''
|
19
|
+
@accountNumber = options[:accountNumber]
|
20
|
+
@bankCode = options[:bankCode]
|
21
|
+
@amount = options[:amount]
|
22
|
+
@currency = options[:currency] || 'CZK'
|
23
|
+
@vs = options[:vs]
|
24
|
+
@message = options[:message]
|
25
|
+
end
|
26
|
+
|
27
|
+
# generates czech IBAN from accountPrefix, accountNumber and bankCode
|
28
|
+
def iban
|
29
|
+
base = "#{bankCode}#{accountPrefix.rjust(6,'0')}#{accountNumber.rjust(10,'0')}"
|
30
|
+
checksum = 98 - ("#{base}123500".to_i % 97)
|
31
|
+
"CZ#{checksum}#{base}"
|
32
|
+
end
|
33
|
+
|
34
|
+
# SPLAY string for payment
|
35
|
+
def to_s
|
36
|
+
out = []
|
37
|
+
out << "SPD*1.0"
|
38
|
+
out << "*ACC:#{iban}"
|
39
|
+
out << "*AM:#{'%.2f' % amount}" if amount
|
40
|
+
out << "*CC:#{currency}" if currency
|
41
|
+
out << "*X-VS:#{vs}" if vs
|
42
|
+
out << "*MSG:#{message.upcase}" if message
|
43
|
+
out.join
|
44
|
+
end
|
45
|
+
|
46
|
+
# generates SPLAY string for payment
|
47
|
+
def self.generate_string(options)
|
48
|
+
new(options).to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/rspayd.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rspayd/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jiří Kubíček"]
|
6
|
+
gem.email = ["jiri.kubicek@kraxnet.cz"]
|
7
|
+
gem.description = %q{Gem for generating spayd content}
|
8
|
+
gem.summary = %q{SPAYD (Short Payment Descriptor) is a format used by CBA (Česká bankovní asociace) for QR Payment (QR Platba). This gem generates payment info in SPAYD format.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rspayd"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Rspayd::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspayd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- !binary |
|
14
|
+
SmnFmcOtIEt1YsOtxI1law==
|
15
|
+
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
|
20
|
+
date: 2013-01-17 00:00:00 Z
|
21
|
+
dependencies: []
|
22
|
+
|
23
|
+
description: Gem for generating spayd content
|
24
|
+
email:
|
25
|
+
- jiri.kubicek@kraxnet.cz
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/rspayd.rb
|
39
|
+
- lib/rspayd/version.rb
|
40
|
+
- rspayd.gemspec
|
41
|
+
homepage: ""
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.17
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: "SPAYD (Short Payment Descriptor) is a format used by CBA (\xC4\x8Cesk\xC3\xA1 bankovn\xC3\xAD asociace) for QR Payment (QR Platba). This gem generates payment info in SPAYD format."
|
74
|
+
test_files: []
|
75
|
+
|
76
|
+
has_rdoc:
|