ipizza 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +16 -14
  6. data/Guardfile +2 -2
  7. data/README.markdown +11 -7
  8. data/Rakefile +1 -1
  9. data/ipizza.gemspec +9 -9
  10. data/lib/ipizza.rb +3 -0
  11. data/lib/ipizza/authentication.rb +15 -0
  12. data/lib/ipizza/authentication_request.rb +1 -1
  13. data/lib/ipizza/authentication_response.rb +22 -9
  14. data/lib/ipizza/config.rb +3 -3
  15. data/lib/ipizza/payment.rb +4 -4
  16. data/lib/ipizza/payment_request.rb +1 -1
  17. data/lib/ipizza/payment_response.rb +15 -7
  18. data/lib/ipizza/provider.rb +8 -12
  19. data/lib/ipizza/provider/base.rb +90 -0
  20. data/lib/ipizza/provider/krediidipank.rb +1 -47
  21. data/lib/ipizza/provider/lhv.rb +4 -0
  22. data/lib/ipizza/provider/nordea/authentication_request.rb +2 -2
  23. data/lib/ipizza/provider/nordea/authentication_response.rb +7 -3
  24. data/lib/ipizza/provider/nordea/payment_request.rb +2 -2
  25. data/lib/ipizza/provider/nordea/payment_response.rb +4 -4
  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/request.rb +9 -2
  30. data/lib/ipizza/response.rb +7 -9
  31. data/lib/ipizza/util.rb +9 -5
  32. data/lib/ipizza/version.rb +2 -2
  33. data/spec/certificates/pangalink_danske_bank_cert.pem +22 -0
  34. data/spec/certificates/pangalink_danske_bank_key.pem +27 -0
  35. data/spec/certificates/pangalink_danske_user_key.pem +27 -0
  36. data/spec/certificates/pangalink_krediidipank_bank_cert.pem +22 -0
  37. data/spec/certificates/pangalink_krediidipank_bank_key.pem +27 -0
  38. data/spec/certificates/pangalink_krediidipank_user_key.pem +27 -0
  39. data/spec/certificates/pangalink_lhv_bank_cert.pem +22 -0
  40. data/spec/certificates/pangalink_lhv_bank_key.pem +27 -0
  41. data/spec/certificates/pangalink_lhv_user_key.pem +27 -0
  42. data/spec/certificates/pangalink_seb_bank_cert.pem +16 -0
  43. data/spec/certificates/pangalink_seb_bank_key.pem +15 -0
  44. data/spec/certificates/pangalink_seb_user_key.pem +15 -0
  45. data/spec/certificates/pangalink_swedbank_bank_cert.pem +22 -0
  46. data/spec/certificates/pangalink_swedbank_bank_key.pem +27 -0
  47. data/spec/certificates/pangalink_swedbank_user_key.pem +27 -0
  48. data/spec/config/config.yml +39 -6
  49. data/spec/config/plain_config.yml +3 -3
  50. data/spec/ipizza/authentication_response_spec.rb +11 -9
  51. data/spec/ipizza/config_spec.rb +9 -10
  52. data/spec/ipizza/provider/krediidipank_spec.rb +89 -0
  53. data/spec/ipizza/provider/lhv_spec.rb +89 -0
  54. data/spec/ipizza/provider/nordea/authentication_response_spec.rb +3 -3
  55. data/spec/ipizza/provider/sampo_spec.rb +85 -0
  56. data/spec/ipizza/provider/seb_spec.rb +60 -30
  57. data/spec/ipizza/provider/swedbank_spec.rb +63 -34
  58. data/spec/ipizza/provider_spec.rb +9 -1
  59. data/spec/ipizza/util_spec.rb +5 -1
  60. data/spec/spec_helper.rb +1 -1
  61. data/spec/support/pizza.rb +1 -1
  62. metadata +45 -25
  63. data/spec/certificates/bank.crt +0 -21
  64. data/spec/certificates/bank.csr +0 -17
  65. data/spec/certificates/bank.key +0 -27
  66. data/spec/certificates/bank.pub +0 -1
  67. data/spec/certificates/dealer.key +0 -30
  68. data/spec/certificates/dealer.pub +0 -1
  69. data/spec/certificates/seb_test_priv.pem +0 -16
  70. data/spec/certificates/seb_test_pub.crt +0 -20
  71. data/spec/certificates/seb_test_pub.pem +0 -20
  72. data/spec/certificates/swedbank_production.pem +0 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b744dc05a11b37b526674e00c463d796432a4377
4
- data.tar.gz: da0592a825d8c37ee6d7296f31fdf7fa08b185dd
3
+ metadata.gz: 0d8d1718b8729dfa5e26d38c5bd91e6a3dc572e7
4
+ data.tar.gz: 4dde7b36c532ea40fca0a4d9ea982bc828d0c90a
5
5
  SHA512:
6
- metadata.gz: 236a522ff6096ce20b54926eb2856a7c88a945f2d98d205a91fef524c1f8d649422547c7dc13665b9372d9eab12ac9ed3b3f2099a1fd229835e6a3f716ddc593
7
- data.tar.gz: 29775311abb40b01f940ac05ca945d2bbd3c7ab65d7a3fcc109f8f3c8bfb8215cc83d9eaf9e1a2807b9599ecd9498459466138871adbd39a81bfda97d64c7cbe
6
+ metadata.gz: 15b005e53850f6188f4721058da6db647015ac65e34be2707eb686dbcf953501e648a283a60d01b02b5b8cbc29838e7d5193f37442051cb741a88692f057802e
7
+ data.tar.gz: 0c3ef956c1fa6611cd25971aadd8a4b96c4527a78e256bbec019e93f3a635c3bfe838181c573386eb5f767f5795c16b0415c900c1eedc9b12a51528763e7c98c
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .DS_Store
2
- pkg
2
+ pkg
3
+ .ruby-gemset
4
+ .ruby-version
@@ -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
@@ -1,29 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ipizza (1.0.0)
4
+ ipizza (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- coderay (1.0.8)
9
+ coderay (1.1.0)
10
10
  diff-lcs (1.1.3)
11
- guard (1.6.1)
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)
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)
25
27
  rake (10.3.1)
26
- rb-fsevent (0.9.1)
28
+ rb-fsevent (0.9.4)
27
29
  rspec (2.9.0)
28
30
  rspec-core (~> 2.9.0)
29
31
  rspec-expectations (~> 2.9.0)
@@ -32,8 +34,8 @@ GEM
32
34
  rspec-expectations (2.9.1)
33
35
  diff-lcs (~> 1.1.3)
34
36
  rspec-mocks (2.9.0)
35
- slop (3.3.3)
36
- thor (0.16.0)
37
+ slop (3.6.0)
38
+ thor (0.19.1)
37
39
 
38
40
  PLATFORMS
39
41
  ruby
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
@@ -1,5 +1,9 @@
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:
@@ -46,9 +50,7 @@ At any time, configuration can be modified with `Ipizza::Config.configure` block
46
50
  # relatively to YAML file
47
51
  file_cert: ./certificates/bank_public.crt
48
52
  snd_id: dealer
49
- encoding: ISO-8859-4
50
-
51
- 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
52
54
 
53
55
  ## Payment requests
54
56
 
@@ -75,14 +77,16 @@ Please note that currently only ISO-8859-4 encoding is supported with Swedbank.
75
77
 
76
78
  This library currently works with four Estonian Banks. Here are their respective interface specifications:
77
79
 
78
- * [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)
79
81
  * [SEB](http://www.seb.ee/ari/maksete-kogumine/maksete-kogumine-internetis/tehniline-spetsifikatsioon)
80
- * [Sampo](http://www.sampopank.ee/et/14732.html)
81
- * [Krediidipank](http://www.krediidipank.ee/business/settlements/bank-link/tehniline_kirjeldus.pdf)
82
- * [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*)
83
86
 
84
87
  # Helpful links
85
88
 
89
+ * [pangalink.net](https://pangalink.net/et/info)
86
90
  * [Repository](http://github.com/priithaamer/ipizza)
87
91
  * [Issue tracker](http://github.com/priithaamer/ipizza/issues)
88
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
@@ -1,16 +1,16 @@
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.}
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
14
 
15
15
  s.add_development_dependency 'rspec', '~> 2.9.0'
16
16
  s.add_development_dependency 'guard-rspec'
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
22
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.require_paths = ["lib"]
23
+ s.require_paths = ['lib']
24
24
  end
@@ -5,9 +5,12 @@ require 'ipizza/request'
5
5
  require 'ipizza/response'
6
6
  require 'ipizza/payment_request'
7
7
  require 'ipizza/payment_response'
8
+ require 'ipizza/authentication'
8
9
  require 'ipizza/authentication_request'
9
10
  require 'ipizza/authentication_response'
10
11
  require 'ipizza/provider'
12
+ require 'ipizza/provider/base'
13
+ require 'ipizza/provider/lhv'
11
14
  require 'ipizza/provider/swedbank'
12
15
  require 'ipizza/provider/seb'
13
16
  require 'ipizza/provider/sampo'
@@ -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
@@ -27,7 +27,7 @@ module Ipizza
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)_(.*)=$/ =~ m.to_s
31
31
  clz = Ipizza::Provider.const_get($1.capitalize)
32
32
  key = $2
33
33
  value = args.first
@@ -45,13 +45,13 @@ module Ipizza
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
53
 
54
- if File.exists?(file_path)
54
+ if File.exist?(file_path)
55
55
  file_path
56
56
  else
57
57
  raise "Could not load certificate from file '#{file_path}'"
@@ -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
@@ -4,24 +4,20 @@ module Ipizza
4
4
  class << self
5
5
  def get(provider_name)
6
6
  case provider_name.downcase
7
- when 'swedbank'
7
+ when 'lhv'
8
+ Ipizza::Provider::Lhv.new
9
+ when 'swedbank', 'hp'
8
10
  Ipizza::Provider::Swedbank.new
9
- when 'hp'
10
- Ipizza::Provider::Swedbank.new
11
- when 'eyp'
12
- Ipizza::Provider::Seb.new
13
- when 'seb'
11
+ when 'eyp', 'seb'
14
12
  Ipizza::Provider::Seb.new
15
- when 'sampo'
13
+ when 'sampo', 'sampopank', 'danske'
16
14
  Ipizza::Provider::Sampo.new
17
- when 'sampopank'
18
- Ipizza::Provider::Sampo.new
19
- when 'krep'
20
- Ipizza::Provider::Krediidipank.new
21
- when 'krediidipank'
15
+ when 'krep', 'krediidipank'
22
16
  Ipizza::Provider::Krediidipank.new
23
17
  when 'nordea'
24
18
  Ipizza::Provider::Nordea.new
19
+ else
20
+ Ipizza::Provider::Base.new
25
21
  end
26
22
  end
27
23
  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, self.class.encoding)
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