ipizza 0.7.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -1
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +28 -24
  6. data/Guardfile +2 -2
  7. data/README.markdown +15 -7
  8. data/Rakefile +1 -1
  9. data/ipizza.gemspec +12 -11
  10. data/lib/ipizza/authentication.rb +15 -0
  11. data/lib/ipizza/authentication_request.rb +1 -1
  12. data/lib/ipizza/authentication_response.rb +22 -9
  13. data/lib/ipizza/config.rb +13 -13
  14. data/lib/ipizza/payment.rb +4 -4
  15. data/lib/ipizza/payment_request.rb +1 -1
  16. data/lib/ipizza/payment_response.rb +15 -7
  17. data/lib/ipizza/provider/base.rb +90 -0
  18. data/lib/ipizza/provider/krediidipank.rb +1 -47
  19. data/lib/ipizza/provider/lhv.rb +4 -0
  20. data/lib/ipizza/provider/luminor.rb +4 -0
  21. data/lib/ipizza/provider/nordea/authentication_request.rb +2 -2
  22. data/lib/ipizza/provider/nordea/authentication_response.rb +7 -3
  23. data/lib/ipizza/provider/nordea/payment_request.rb +2 -2
  24. data/lib/ipizza/provider/nordea/payment_response.rb +4 -4
  25. data/lib/ipizza/provider/nordea.rb +1 -74
  26. data/lib/ipizza/provider/sampo.rb +1 -46
  27. data/lib/ipizza/provider/seb.rb +1 -78
  28. data/lib/ipizza/provider/swedbank.rb +1 -66
  29. data/lib/ipizza/provider.rb +9 -15
  30. data/lib/ipizza/request.rb +9 -2
  31. data/lib/ipizza/response.rb +7 -9
  32. data/lib/ipizza/util.rb +18 -11
  33. data/lib/ipizza/version.rb +2 -2
  34. data/lib/ipizza.rb +4 -0
  35. data/spec/certificates/pangalink_danske_bank_cert.pem +22 -0
  36. data/spec/certificates/pangalink_danske_bank_key.pem +27 -0
  37. data/spec/certificates/pangalink_danske_user_key.pem +27 -0
  38. data/spec/certificates/pangalink_krediidipank_bank_cert.pem +22 -0
  39. data/spec/certificates/pangalink_krediidipank_bank_key.pem +27 -0
  40. data/spec/certificates/pangalink_krediidipank_user_key.pem +27 -0
  41. data/spec/certificates/pangalink_lhv_bank_cert.pem +22 -0
  42. data/spec/certificates/pangalink_lhv_bank_key.pem +27 -0
  43. data/spec/certificates/pangalink_lhv_user_key.pem +27 -0
  44. data/spec/certificates/pangalink_luminor_bank.cert.pem +18 -0
  45. data/spec/certificates/pangalink_luminor_bank_cert.pem +17 -0
  46. data/spec/certificates/pangalink_seb_bank_cert.pem +16 -0
  47. data/spec/certificates/pangalink_seb_bank_key.pem +15 -0
  48. data/spec/certificates/pangalink_seb_user_key.pem +15 -0
  49. data/spec/certificates/pangalink_swedbank_bank_cert.pem +22 -0
  50. data/spec/certificates/pangalink_swedbank_bank_key.pem +27 -0
  51. data/spec/certificates/pangalink_swedbank_user_key.pem +27 -0
  52. data/spec/config/config.yml +50 -6
  53. data/spec/config/plain_config.yml +3 -3
  54. data/spec/ipizza/authentication_response_spec.rb +11 -9
  55. data/spec/ipizza/config_spec.rb +9 -10
  56. data/spec/ipizza/provider/krediidipank_spec.rb +89 -0
  57. data/spec/ipizza/provider/lhv_spec.rb +89 -0
  58. data/spec/ipizza/provider/luminor_spec.rb +89 -0
  59. data/spec/ipizza/provider/nordea/authentication_response_spec.rb +3 -3
  60. data/spec/ipizza/provider/sampo_spec.rb +85 -0
  61. data/spec/ipizza/provider/seb_spec.rb +60 -30
  62. data/spec/ipizza/provider/swedbank_spec.rb +63 -34
  63. data/spec/ipizza/provider_spec.rb +25 -5
  64. data/spec/ipizza/util_spec.rb +5 -1
  65. data/spec/spec_helper.rb +1 -1
  66. data/spec/support/pizza.rb +1 -1
  67. metadata +121 -104
  68. data/spec/certificates/bank.crt +0 -21
  69. data/spec/certificates/bank.csr +0 -17
  70. data/spec/certificates/bank.key +0 -27
  71. data/spec/certificates/bank.pub +0 -1
  72. data/spec/certificates/dealer.key +0 -30
  73. data/spec/certificates/dealer.pub +0 -1
  74. data/spec/certificates/seb_test_priv.pem +0 -16
  75. data/spec/certificates/seb_test_pub.crt +0 -20
  76. data/spec/certificates/seb_test_pub.pem +0 -20
  77. data/spec/certificates/swedbank_production.pem +0 -48
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 160c73db6da0b92bb8d59f3478ae2836a8efdfe57cbfe174a0715559a980273a
4
+ data.tar.gz: 40486a43f105c5ee73fb7d3f4e827124f7bff5cb8fb1bfa93c2fca677c06f9c7
5
+ SHA512:
6
+ metadata.gz: 173c0fd63f8e5c43c099a9871005db2bc83272455eb56c10c9c01fabb4a2ab2c42925d490f9608332aca2916ef172ef81bc204ae9f211d9a357a3a4989581f43
7
+ data.tar.gz: b702c29a1c3ccf89a46a10828c3911ab9d7d9880d43e79387ff4e5cd6284aabe83dcb81c28f65c19f484550f018c2fb93261b0e7a7939ed04c587a76a00ed2be
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .DS_Store
2
- pkg
2
+ pkg
3
+ .ruby-gemset
4
+ .ruby-version
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## v2.0.0
2
+
3
+ * Added support for iPizza services (`1011`, `1012`, `4011` and `4012`). Read more form [Estonian Banking Association webpage](http://pangaliit.ee/et/arveldused/pangalingi-spetsifikatsioon)
4
+ * Changed MAC calculation in case of UTF-8 encoding to support new iPizza protocol.
5
+ * Added supported encodings to Provider model (`UTF-8` (default), `ISO-8859-1` and `WINDOWS-1257`).
6
+ * Added 'transaction_time' attribute to `Ipizza::Payment` object (parsed value of the `VK_T_DATETIME` field).
7
+ * Removed support for iPizza services (`1001`, `1002`, `4001` and `4002`).
8
+ * Added new provider: LHV Bank.
9
+ * Authentication request response method `authentication_info` returns now `Ipizza::Authentication` object instead of string.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
  gemspec
data/Gemfile.lock CHANGED
@@ -1,38 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ipizza (0.7.1)
4
+ ipizza (2.0.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- coderay (1.0.8)
10
- diff-lcs (1.1.2)
11
- guard (1.6.1)
9
+ coderay (1.1.0)
10
+ diff-lcs (1.1.3)
11
+ formatador (0.2.5)
12
+ guard (1.7.0)
13
+ formatador (>= 0.2.4)
12
14
  listen (>= 0.6.0)
13
15
  lumberjack (>= 1.0.2)
14
16
  pry (>= 0.9.10)
15
17
  thor (>= 0.14.6)
16
- guard-rspec (1.1.0)
18
+ guard-rspec (1.2.1)
17
19
  guard (>= 1.1)
18
- listen (0.7.1)
19
- lumberjack (1.0.2)
20
- method_source (0.8.1)
21
- pry (0.9.10)
22
- coderay (~> 1.0.5)
23
- method_source (~> 0.8)
24
- slop (~> 3.3.1)
25
- rb-fsevent (0.9.1)
26
- rspec (2.6.0)
27
- rspec-core (~> 2.6.0)
28
- rspec-expectations (~> 2.6.0)
29
- rspec-mocks (~> 2.6.0)
30
- rspec-core (2.6.2)
31
- rspec-expectations (2.6.0)
32
- diff-lcs (~> 1.1.2)
33
- rspec-mocks (2.6.0)
34
- slop (3.3.3)
35
- thor (0.16.0)
20
+ listen (0.7.3)
21
+ lumberjack (1.0.9)
22
+ method_source (0.8.2)
23
+ pry (0.10.1)
24
+ coderay (~> 1.1.0)
25
+ method_source (~> 0.8.1)
26
+ slop (~> 3.4)
27
+ rake (10.3.1)
28
+ rb-fsevent (0.9.4)
29
+ rspec (2.9.0)
30
+ rspec-core (~> 2.9.0)
31
+ rspec-expectations (~> 2.9.0)
32
+ rspec-mocks (~> 2.9.0)
33
+ rspec-core (2.9.0)
34
+ rspec-expectations (2.9.1)
35
+ diff-lcs (~> 1.1.3)
36
+ rspec-mocks (2.9.0)
37
+ slop (3.6.0)
38
+ thor (0.19.1)
36
39
 
37
40
  PLATFORMS
38
41
  ruby
@@ -40,5 +43,6 @@ PLATFORMS
40
43
  DEPENDENCIES
41
44
  guard-rspec
42
45
  ipizza!
46
+ rake
43
47
  rb-fsevent
44
- rspec (~> 2.6.0)
48
+ rspec (~> 2.9.0)
data/Guardfile CHANGED
@@ -1,5 +1,5 @@
1
- guard 'rspec', :version => 2, :cli => "--color", :bundler => true, :all_on_start => false, :all_after_pass => false, :keep_failed => true, :notification => false do
2
- watch('spec/spec_helper.rb') { "spec" }
1
+ guard 'rspec', version: 2, cli: '--color', bundler: true, all_on_start: false, all_after_pass: false, keep_failed: true, notification: false do
2
+ watch('spec/spec_helper.rb') { 'spec' }
3
3
  watch(%r{^spec/.+_spec\.rb})
4
4
  watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
5
5
  end
data/README.markdown CHANGED
@@ -1,11 +1,19 @@
1
1
  Implements iPizza protocol to communicate with Estonian Banks.
2
2
 
3
+ Gem implements support for iPizza services (`1011`, `1012`, `4011` and `4012`) that are supported by members of the Estonian Banking Association [since October 2014](http://pangaliit.ee/et/arveldused/pangalingi-spetsifikatsioon).
4
+
5
+ If you need to use this gem with old iPizza services implementations (`1001`, `1002`, `4001` and `4002`), use 1.0.0 version of this gem (NB! support for these services will end on 31 December 2015).
6
+
3
7
  # Usage
4
8
 
5
9
  Add gem dependency in your `Gemfile` and install the gem:
6
10
 
7
11
  gem 'ipizza'
8
12
 
13
+ ## Ruby 1.8 support
14
+
15
+ Since ipizza gem version 1.0.0, Ruby 1.8 support has been dropped. If you need to use this gem with older versions of Ruby, use 0.7.1 version of this gem.
16
+
9
17
  # Configuration
10
18
 
11
19
  Configuration can be made in two different ways, using `Ipizza::Config.configure` block or loading configuration properties from YAML file.
@@ -42,9 +50,7 @@ At any time, configuration can be modified with `Ipizza::Config.configure` block
42
50
  # relatively to YAML file
43
51
  file_cert: ./certificates/bank_public.crt
44
52
  snd_id: dealer
45
- encoding: ISO-8859-4
46
-
47
- Please note that currently only ISO-8859-4 encoding is supported with Swedbank. UTF-8 works well with other payment providers.
53
+ encoding: UTF-8
48
54
 
49
55
  ## Payment requests
50
56
 
@@ -71,14 +77,16 @@ Please note that currently only ISO-8859-4 encoding is supported with Swedbank.
71
77
 
72
78
  This library currently works with four Estonian Banks. Here are their respective interface specifications:
73
79
 
74
- * [Swedbank](https://www.swedbank.ee/static/pdf/business/d2d/paymentcollection/info_banklink_techspec_est.pdf)
80
+ * [Swedbank](https://www.swedbank.ee/business/cash/ecommerce/banklink/description?language=EST)
75
81
  * [SEB](http://www.seb.ee/ari/maksete-kogumine/maksete-kogumine-internetis/tehniline-spetsifikatsioon)
76
- * [Sampo](http://www.sampopank.ee/et/14732.html)
77
- * [Krediidipank](http://www.krediidipank.ee/business/settlements/bank-link/tehniline_kirjeldus.pdf)
78
- * [Nordea](http://www.nordea.ee/Teenused+ärikliendile/E-lahendused/787802.html)
82
+ * [Danske Bank](http://www.danskebank.ee/et/14732.html)
83
+ * [Krediidipank](http://www.krediidipank.ee/business/settlements/bank-link/index.html)
84
+ * [LHV Bank](https://www.lhv.ee/pangateenused/pangalink/)
85
+ * [Nordea](http://www.nordea.ee/Teenused+%C3%A4rikliendile/Igap%C3%A4evapangandus/Maksete+kogumine/E-makse/1562142.html) (*uses SOLO protocol*)
79
86
 
80
87
  # Helpful links
81
88
 
89
+ * [pangalink.net](https://pangalink.net/et/info)
82
90
  * [Repository](http://github.com/priithaamer/ipizza)
83
91
  * [Issue tracker](http://github.com/priithaamer/ipizza/issues)
84
92
 
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Bundler::GemHelper.install_tasks
7
7
 
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
- task :default => :spec
10
+ task default: :spec
data/ipizza.gemspec CHANGED
@@ -1,23 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "ipizza/version"
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'ipizza/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "ipizza"
6
+ s.name = 'ipizza'
7
7
  s.version = Ipizza::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Priit Haamer"]
10
- s.email = ["priit@fraktal.ee"]
11
- s.homepage = "http://github.com/priithaamer/ipizza"
12
- s.summary = %q{Implements iPizza protocol to communicate with Estonian Banks}
13
- s.description = %q{Simplifies generating payment requests and parsing responses from banks when using iPizza protocol.}
14
-
15
- s.add_development_dependency 'rspec', '~> 2.6.0'
9
+ s.authors = ['Priit Haamer', 'Tanel Jakobsoo']
10
+ s.email = ['priit@voog.com', 'tanel@voog.com']
11
+ s.homepage = 'https://github.com/Voog/ipizza'
12
+ s.summary = 'Implements iPizza protocol to communicate with Estonian Banks'
13
+ s.description = 'Simplifies generating payment requests and parsing responses from banks when using iPizza protocol.'
14
+
15
+ s.add_development_dependency 'rspec', '~> 2.9.0'
16
16
  s.add_development_dependency 'guard-rspec'
17
17
  s.add_development_dependency 'rb-fsevent'
18
+ s.add_development_dependency 'rake'
18
19
 
19
20
  s.files = `git ls-files`.split("\n")
20
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
22
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
- s.require_paths = ["lib"]
23
+ s.require_paths = ['lib']
23
24
  end
@@ -0,0 +1,15 @@
1
+ module Ipizza
2
+ class Authentication
3
+
4
+ attr_accessor :provider, :user, :message_time, :sender_id, :receiver_id, :user_name, :user_id, :country, :other, :authentication_identifier, :request_identifier
5
+
6
+ def initialize(attribs = {})
7
+ attribs.each do |key, value|
8
+ if self.respond_to?("#{key.to_s}=".to_sym)
9
+ v = key.to_sym == :message_time && value.is_a?(String) ? Time.parse(value) : value
10
+ self.send("#{key.to_s}=".to_sym, v)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,4 +1,4 @@
1
1
  module Ipizza
2
2
  class AuthenticationRequest < Ipizza::Request
3
3
  end
4
- end
4
+ end
@@ -2,23 +2,36 @@ module Ipizza
2
2
  class AuthenticationResponse < Ipizza::Response
3
3
 
4
4
  def success?
5
- return ['3002'].include?(@params['VK_SERVICE'])
5
+ %w(3012 3013).include?(@params['VK_SERVICE'])
6
6
  end
7
7
 
8
8
  def valid?
9
- return @valid
10
- end
11
-
12
- def authentication_info
13
- @params['VK_INFO']
9
+ @valid
14
10
  end
15
11
 
16
12
  def info_social_security_id
17
- /ISIK:([^;.]+)/i.match(@params['VK_INFO'])[1] if @params['VK_INFO']
13
+ authentication_info.user_id
18
14
  end
19
15
 
20
16
  def info_name
21
- /NIMI:([^;.]+)/.match(@params['VK_INFO'])[1] if @params['VK_INFO']
17
+ authentication_info.user_name
18
+ end
19
+
20
+ def authentication_info
21
+ @authentication_info ||= Ipizza::Authentication.new(
22
+ provider: @params['VK_SND_ID'],
23
+ user: @params['VK_USER'],
24
+ message_time: @params['VK_DATETIME'],
25
+ sender_id: @params['VK_SND_ID'],
26
+ receiver_id: @params['VK_REC_ID'],
27
+ user_name: @params['VK_USER_NAME'],
28
+ user_id: @params['VK_USER_ID'],
29
+ country: @params['VK_COUNTRY'],
30
+ other: @params['VK_OTHER'],
31
+ authentication_identifier: @params['VK_TOKEN'],
32
+ request_identifier: @params['VK_RID'],
33
+ nonce: @params['VK_NONCE']
34
+ )
22
35
  end
23
36
  end
24
- end
37
+ end
data/lib/ipizza/config.rb CHANGED
@@ -8,10 +8,10 @@ module Ipizza
8
8
 
9
9
  def load_from_file(yaml_path)
10
10
  @certs_root = File.dirname(yaml_path)
11
-
11
+
12
12
  load_from_hash(YAML::load_file(yaml_path))
13
13
  end
14
-
14
+
15
15
  def load_from_hash(config)
16
16
  config.each do |bank, params|
17
17
  params.each do |param, value|
@@ -21,19 +21,19 @@ module Ipizza
21
21
  end
22
22
  end
23
23
  end
24
-
24
+
25
25
  def configure
26
26
  yield self
27
27
  end
28
-
28
+
29
29
  def method_missing(m, *args)
30
- if /^(swedbank|seb|sampo|krediidipank|nordea)_(.*)=$/ =~ m.to_s
30
+ if /^(lhv|swedbank|seb|sampo|krediidipank|nordea|luminor)_(.*)=$/ =~ m.to_s
31
31
  clz = Ipizza::Provider.const_get($1.capitalize)
32
32
  key = $2
33
33
  value = args.first
34
-
34
+
35
35
  value = load_certificate(value) if /^file_(cert|key)/ =~ key
36
-
36
+
37
37
  if clz.respond_to?(:"#{key}=")
38
38
  return clz.send(:"#{key}=", *[value])
39
39
  end
@@ -41,23 +41,23 @@ module Ipizza
41
41
 
42
42
  super
43
43
  end
44
-
44
+
45
45
  private
46
-
46
+
47
47
  def load_certificate(file_path)
48
- if File.exists?(file_path)
48
+ if File.exist?(file_path)
49
49
  file_path
50
50
  else
51
51
  file_path = File.expand_path(File.join(certs_root, file_path))
52
52
  end
53
-
54
- if File.exists?(file_path)
53
+
54
+ if File.exist?(file_path)
55
55
  file_path
56
56
  else
57
57
  raise "Could not load certificate from file '#{file_path}'"
58
58
  end
59
59
  end
60
-
60
+
61
61
  end
62
62
  end
63
63
  end
@@ -1,15 +1,15 @@
1
1
  module Ipizza
2
2
  class Payment
3
3
 
4
- attr_accessor :stamp, :amount, :currency, :refnum, :receiver_account, :receiver_name, :sender_account, :sender_name, :message, :transaction_id
4
+ attr_accessor :provider, :stamp, :amount, :currency, :refnum, :receiver_account, :receiver_name, :sender_account, :sender_name, :message, :transaction_id, :transaction_time
5
5
 
6
6
  def initialize(attribs = {})
7
7
  attribs.each do |key, value|
8
8
  if self.respond_to?("#{key.to_s}=".to_sym)
9
- self.send("#{key.to_s}=".to_sym, value)
9
+ v = key.to_sym == :transaction_time && value.is_a?(String) ? Time.parse(value) : value
10
+ self.send("#{key.to_s}=".to_sym, v)
10
11
  end
11
12
  end
12
13
  end
13
-
14
14
  end
15
- end
15
+ end
@@ -1,4 +1,4 @@
1
1
  module Ipizza
2
2
  class PaymentRequest < Ipizza::Request
3
3
  end
4
- end
4
+ end
@@ -1,23 +1,31 @@
1
1
  class Ipizza::PaymentResponse < Ipizza::Response
2
2
 
3
3
  def success?
4
- return ['1101'].include?(@params['VK_SERVICE'])
4
+ %w(1111).include?(@params['VK_SERVICE'])
5
5
  end
6
6
 
7
7
  def valid?
8
- return @valid
8
+ @valid
9
9
  end
10
10
 
11
11
  def automatic_message?
12
- @params['VK_AUTO'] and @params['VK_AUTO'] == 'Y'
12
+ @params['VK_AUTO'] == 'Y'
13
13
  end
14
14
 
15
15
  def payment_info
16
16
  @payment_info ||= Ipizza::Payment.new(
17
- :stamp => @params['VK_STAMP'], :amount => @params['VK_AMOUNT'], :currency => @params['VK_CURR'],
18
- :refnum => @params['VK_REF'], :message => @params['VK_MSG'], :transaction_id => @params['VK_T_NO'],
19
- :receiver_account => @params['VK_REC_ACC'], :receiver_name => @params['VK_REC_NAME'],
20
- :sender_account => @params['VK_SND_ACC'], :sender_name => @params['VK_SND_NAME']
17
+ provider: @params['VK_SND_ID'],
18
+ stamp: @params['VK_STAMP'],
19
+ amount: @params['VK_AMOUNT'],
20
+ currency: @params['VK_CURR'],
21
+ refnum: @params['VK_REF'],
22
+ message: @params['VK_MSG'],
23
+ transaction_id: @params['VK_T_NO'],
24
+ receiver_account: @params['VK_REC_ACC'],
25
+ receiver_name: @params['VK_REC_NAME'],
26
+ sender_account: @params['VK_SND_ACC'],
27
+ sender_name: @params['VK_SND_NAME'],
28
+ transaction_time: @params['VK_T_DATETIME']
21
29
  )
22
30
  end
23
31
  end
@@ -0,0 +1,90 @@
1
+ module Ipizza::Provider
2
+ class Base
3
+
4
+ SUPPORTED_ENCODINGS = %w(UTF-8 ISO-8859-1 WINDOWS-1257)
5
+
6
+ class << self
7
+ attr_accessor :service_url, :return_url, :cancel_url, :file_key, :key_secret, :file_cert, :snd_id, :rec_id, :rec_acc, :rec_name, :encoding, :lang
8
+ end
9
+
10
+ def payment_request(payment, service_no = 1012)
11
+ req = Ipizza::PaymentRequest.new
12
+ req.service_url = self.class.service_url
13
+ req.sign_params = {
14
+ 'VK_SERVICE' => service_no,
15
+ 'VK_VERSION' => '008',
16
+ 'VK_SND_ID' => self.class.snd_id,
17
+ 'VK_STAMP' => payment.stamp,
18
+ 'VK_AMOUNT' => sprintf('%.2f', payment.amount),
19
+ 'VK_CURR' => payment.currency,
20
+ 'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
21
+ 'VK_MSG' => payment.message,
22
+ 'VK_RETURN' => self.class.return_url,
23
+ 'VK_CANCEL' => self.class.cancel_url,
24
+ 'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
25
+ }
26
+
27
+ if service_no.to_s == '1011'
28
+ req.sign_params['VK_ACC'] = self.class.rec_acc
29
+ req.sign_params['VK_NAME'] = self.class.rec_name
30
+ end
31
+
32
+ req.extra_params = {
33
+ 'VK_ENCODING' => get_encoding(self.class.encoding),
34
+ 'VK_LANG' => self.class.lang
35
+ }
36
+
37
+ req.sign(self.class.file_key, self.class.key_secret, Ipizza::Request::PARAM_ORDER[service_no.to_s])
38
+ req
39
+ end
40
+
41
+ def payment_response(params)
42
+ response = Ipizza::PaymentResponse.new(params)
43
+ response.verify(self.class.file_cert)
44
+ response
45
+ end
46
+
47
+ def authentication_request(service_no = 4011, param = {})
48
+ req = Ipizza::AuthenticationRequest.new
49
+ req.service_url = self.class.service_url
50
+ req.sign_params = {
51
+ 'VK_SERVICE' => service_no,
52
+ 'VK_VERSION' => '008',
53
+ 'VK_SND_ID' => self.class.snd_id,
54
+ 'VK_RETURN' => self.class.return_url,
55
+ 'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
56
+ 'VK_RID' => param[:vk_rid]
57
+ }
58
+
59
+ case service_no.to_s
60
+ when '4011'
61
+ req.sign_params['VK_REPLY'] = '3012'
62
+ when '4012'
63
+ req.sign_params.merge(
64
+ 'VK_REC_ID' => self.class.rec_id,
65
+ 'VK_NONCE' => param[:vk_nonce]
66
+ )
67
+ end
68
+
69
+ req.extra_params = {
70
+ 'VK_ENCODING' => get_encoding(self.class.encoding),
71
+ 'VK_LANG' => self.class.lang
72
+ }
73
+
74
+ req.sign(self.class.file_key, self.class.key_secret, Ipizza::Request::PARAM_ORDER[service_no.to_s])
75
+ req
76
+ end
77
+
78
+ def authentication_response(params)
79
+ response = Ipizza::AuthenticationResponse.new(params)
80
+ response.verify(self.class.file_cert)
81
+ response
82
+ end
83
+
84
+ private
85
+
86
+ def get_encoding(val)
87
+ SUPPORTED_ENCODINGS.include?(val.to_s.upcase) ? val.to_s.upcase : 'UTF-8'
88
+ end
89
+ end
90
+ end