debitech 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 80a1113ae193781f0000c1c5ce7d5dff6d4a8ef7
4
- data.tar.gz: f129e8f59589dc5a53d1d16d51030599f3926e34
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjQ0NGNhYjM4MjljY2NlNTJjOWY5MGFkZDc1NmJhM2JlYzg3MjBiNA==
5
+ data.tar.gz: !binary |-
6
+ Y2Y5NDc3NmQyOTIwODI3YzgzOTYwNzk1OGNiMzVhZDc4NmY2MzdhMA==
5
7
  SHA512:
6
- metadata.gz: f747691d6e2a953583edc59bd4e1f6189ab5d93aa2c4772357687d94b83c7c552590fd959f12a54ed395644f67a4e962deddc75f63fd1149ed2068eaff54a477
7
- data.tar.gz: 46d07f8d33c8ccd8ad81822074cc029886acbac904bcec55161d9b2e0580692c882fec6e21a986efcdc8045e846c07364122c1b94c5915de607dc257037d88f6
8
+ metadata.gz: !binary |-
9
+ MWY1YmQ5MTlhODEwYmExMGEyOGE1MTBkZDJjMDU3MTJmNjdiOWY4ODQzMmI5
10
+ YWIwN2IwNTlmZjU3Y2VmNDU4MThhNTBiZGQzN2Q0ZWI5YjVkOTkxNzJhZDA1
11
+ YmJlNDUxNmY2YTg2MzIwOTBjNDE0ZjcwNmQxMzZhNWNjYjVjOGE=
12
+ data.tar.gz: !binary |-
13
+ MjM3YThkZTM0ZjY2NDQ4YTBhMWE5NzcyMjJkNGZmNjAyMmFlOGFiY2RkMzg4
14
+ YmEzN2FhYmUzYWYzZDI3ZjhmZTFkOThkODFlMGZiZGJlNWMxY2YxMzBiMjVk
15
+ MTk4OGJiZDY5ZTgyODg4ZTQxMzQ1OTE2MzE4YWQ2ZDFlNzVhZDk=
@@ -1,4 +1,4 @@
1
1
  module Debitech
2
2
  # try to follow http://semver.org/
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
@@ -13,7 +13,7 @@ module Debitech
13
13
 
14
14
  # you probably want to encode these when posting to dibs, for example HTMLEntities.new.encode(v, :named) (gem: htmlentities)
15
15
  def form_fields(more_custom_fields = {})
16
- # Overriding via the initializer may be more convenient for per-env stuff like "method"".
16
+ # Overriding via the initializer may be more convenient for per-env stuff like "method".
17
17
  # Overriding via the method argument may be more convenient for per-request stuff like multiple pageSets.
18
18
  all_fields_except_mac = custom_fields.merge(more_custom_fields)
19
19
  mac = request_mac(all_fields_except_mac)
@@ -24,8 +24,10 @@ module Debitech
24
24
  "https://securedt.dibspayment.com/verify/bin/#{@merchant}/index"
25
25
  end
26
26
 
27
- def valid_response?(mac, sum, reply, verify_id, currency = custom_fields[:currency])
28
- response_mac(sum, reply, verify_id, currency) == mac.upcase.split("=").last
27
+ # If the currency was passed into form_fields (and thus isn't known on an instance level),
28
+ # you will need to pass it in explicitly here.
29
+ def valid_response?(mac, sum, reply, verify_id, currency = custom_fields[:currency], reference_number = nil)
30
+ response_mac(sum, reply, verify_id, currency, reference_number) == mac.upcase.split("=").last
29
31
  end
30
32
 
31
33
  def approved_reply?(reply)
@@ -62,8 +64,14 @@ module Debitech
62
64
  Mac.build [ fields[:data], fields[:currency], fields[:method], @secret_key ]
63
65
  end
64
66
 
65
- def response_mac(sum, reply, verify_id, currency)
66
- Mac.build [ sum, currency, reply, verify_id, @secret_key ]
67
+ def response_mac(sum, reply, verify_id, currency, reference_number)
68
+ # Reference number is optional, but if it's passed in when making the payment it
69
+ # needs to be part of the response_mac calculation to verify the payment result.
70
+ if reference_number
71
+ Mac.build [ sum, currency, reply, verify_id, reference_number, @secret_key ]
72
+ else
73
+ Mac.build [ sum, currency, reply, verify_id, @secret_key ]
74
+ end
67
75
  end
68
76
  end
69
77
  end
@@ -76,7 +76,7 @@ describe Debitech::WebApi do
76
76
  expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be false
77
77
  end
78
78
 
79
- it "handle if verify_id is an int" do
79
+ it "handles if verify_id is an int" do
80
80
  api = Debitech::WebApi.new(secret_key)
81
81
  expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", 1234567)).to be true
82
82
  end
@@ -86,5 +86,10 @@ describe Debitech::WebApi do
86
86
  expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", 1234567, "SEK")).to be true
87
87
  expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", 1234567, "EUR")).to be false
88
88
  end
89
+
90
+ it "handles MAC based on reference_number" do
91
+ api = Debitech::WebApi.new(secret_key)
92
+ expect(api.valid_response?("MAC=AB4698D21798C6F3A1EA25CD67590A072211123D", "1,00", "A", "1234567", "SEK", "ref-123")).to be true
93
+ end
89
94
  end
90
95
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debitech
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Kolsjö
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-26 00:00:00.000000000 Z
11
+ date: 2017-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debitech_soap
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Library for doing payments using DebiTech (DIBS)
@@ -59,9 +59,9 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".gitignore"
63
- - ".rvmrc"
64
- - ".travis.yml"
62
+ - .gitignore
63
+ - .rvmrc
64
+ - .travis.yml
65
65
  - Gemfile
66
66
  - README.md
67
67
  - Rakefile
@@ -82,17 +82,17 @@ require_paths:
82
82
  - lib
83
83
  required_ruby_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - ">="
85
+ - - ! '>='
86
86
  - !ruby/object:Gem::Version
87
87
  version: 1.8.7
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ">="
90
+ - - ! '>='
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.4.8
95
+ rubygems_version: 2.5.1
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: Library for doing payments using DebiTech (DIBS)