debitech 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82279dd06b05d239c43e6ff2190190fa8ffd654b
4
+ data.tar.gz: 9dd2575228951cce994151aab74f883af3a64f62
5
+ SHA512:
6
+ metadata.gz: e9343f83273a827349186aa6b63187eaf54674c5be823c19ad9968bc891979a1d50b0945a14de5fb1749962a71a4547bbf728696f64bb7efd93f5ccf3d6b9ccc
7
+ data.tar.gz: e2a9dd971b861a830d0322f88734e304b07e2a6ec2518b71c1280987ce400e02edd0651cb1e29dcaa417c9108f69e78f48ca8cc063df3f9295e6a41d684ff926
data/lib/debitech/mac.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'digest/sha1'
1
+ require "digest/sha1"
2
2
 
3
3
  module Debitech
4
4
  class Mac
@@ -1,5 +1,5 @@
1
- require 'debitech_soap'
2
- require 'debitech/mac'
1
+ require "debitech_soap"
2
+ require "debitech/mac"
3
3
 
4
4
  module Debitech
5
5
  class ServerApi
@@ -1,4 +1,4 @@
1
1
  module Debitech
2
2
  # try to follow http://semver.org/
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
@@ -1,5 +1,5 @@
1
- require 'digest/sha1'
2
- require 'debitech/mac'
1
+ require "digest/sha1"
2
+ require "debitech/mac"
3
3
 
4
4
  module Debitech
5
5
  class WebApi
@@ -15,7 +15,7 @@ module Debitech
15
15
  end
16
16
 
17
17
  def form_action
18
- "https://secure.incab.se/verify/bin/#{@opts[:merchant]}/index"
18
+ "https://securedt.dibspayment.com/verify/bin/#{@opts[:merchant]}/index"
19
19
  end
20
20
 
21
21
  def valid_response?(mac, sum, reply, verify_id)
@@ -1,4 +1,4 @@
1
- require 'debitech'
1
+ require "debitech"
2
2
 
3
3
  describe Debitech::ServerApi, "charge" do
4
4
  let(:unique_reference) {
@@ -16,34 +16,42 @@ describe Debitech::ServerApi, "charge" do
16
16
  :soap_opts => {
17
17
  :merchant => "store",
18
18
  :username => "api_user",
19
- :password => "api_password"
19
+ :password => "api_password",
20
20
  }
21
21
  }
22
22
 
23
- DebitechSoap::API.should_receive(:new).with({ :merchant => "store", :username => "api_user", :password => "api_password" }).
24
- and_return(soap_api = mock)
25
- soap_api.should_receive(:subscribe_and_settle).with(:verifyID => 1234567,
26
- :data => "001:payment:1:10000:",
27
- :ip => "127.0.0.1",
28
- :extra => "&method=cc.cekab&currency=SEK&MAC=1931EE498A77F6B12B2C2D2EC8599719EF9CE419&referenceNo=some_unique_ref")
23
+ soap_api = double
24
+ allow(DebitechSoap::API).to receive(:new).
25
+ with({ :merchant => "store", :username => "api_user", :password => "api_password" }).
26
+ and_return(soap_api)
27
+ expect(soap_api).to receive(:subscribe_and_settle).with(
28
+ :verifyID => 1234567,
29
+ :data => "001:payment:1:10000:",
30
+ :ip => "127.0.0.1",
31
+ :extra => "&method=cc.cekab&currency=SEK&MAC=1931EE498A77F6B12B2C2D2EC8599719EF9CE419&referenceNo=some_unique_ref",
32
+ )
29
33
 
30
34
  server_api = Debitech::ServerApi.new(settings)
31
35
  server_api.charge(transaction.merge(:amount => 10000))
32
36
  end
33
37
 
34
38
  it "should convert the amount to a integer to avoid 500 errors" do
35
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
36
- soap_api.should_receive(:subscribe_and_settle).with(:verifyID => 1234567,
37
- :data => "001:payment:1:2235:",
38
- :ip => "127.0.0.1",
39
- :extra => "&method=&currency=SEK&MAC=78B1144270B1A74A55539FAEB81BB49EC39B90DF&referenceNo=some_unique_ref")
39
+ soap_api = double
40
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
41
+ expect(soap_api).to receive(:subscribe_and_settle).with(
42
+ :verifyID => 1234567,
43
+ :data => "001:payment:1:2235:",
44
+ :ip => "127.0.0.1",
45
+ :extra => "&method=&currency=SEK&MAC=78B1144270B1A74A55539FAEB81BB49EC39B90DF&referenceNo=some_unique_ref",
46
+ )
40
47
 
41
48
  server_api = Debitech::ServerApi.new({})
42
49
  server_api.charge(transaction.merge(:amount => 2235.0))
43
50
  end
44
51
 
45
52
  it "should raise an error if the amount has a fraction" do
46
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
53
+ soap_api = double
54
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
47
55
  server_api = Debitech::ServerApi.new({})
48
56
  expect {
49
57
  server_api.charge(transaction.merge(:amount => 2235.55))
@@ -51,7 +59,8 @@ describe Debitech::ServerApi, "charge" do
51
59
  end
52
60
 
53
61
  it "should raise an error if the unique_reference is nil" do
54
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
62
+ soap_api = double
63
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
55
64
  server_api = Debitech::ServerApi.new({})
56
65
  expect {
57
66
  server_api.charge(transaction.merge(:unique_reference => nil))
@@ -59,7 +68,8 @@ describe Debitech::ServerApi, "charge" do
59
68
  end
60
69
 
61
70
  it "should raise an error if the unique_reference is less than 4 characters" do
62
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
71
+ soap_api = double
72
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
63
73
  server_api = Debitech::ServerApi.new({})
64
74
  expect {
65
75
  server_api.charge(transaction.merge(:unique_reference => "1234"))
@@ -67,16 +77,19 @@ describe Debitech::ServerApi, "charge" do
67
77
  end
68
78
 
69
79
  it "should be valid with a 5 character unique_reference" do
70
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
71
- soap_api.stub!(:subscribe_and_settle)
80
+ soap_api = double
81
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
82
+ allow(soap_api).to receive(:subscribe_and_settle)
72
83
  server_api = Debitech::ServerApi.new({})
73
84
  server_api.charge(transaction.merge(:unique_reference => "12345"))
74
85
  end
75
86
 
76
87
  [ 100, 101, 150, 199 ].each do |result_code|
77
88
  it "should return success for result_code #{result_code}" do
78
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
79
- soap_api.stub!(:subscribe_and_settle).and_return(response = mock(:result_code => result_code))
89
+ soap_api = double
90
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
91
+ response = double(:result_code => result_code)
92
+ allow(soap_api).to receive(:subscribe_and_settle).and_return(response)
80
93
 
81
94
  server_api = Debitech::ServerApi.new({})
82
95
  result = server_api.charge(unique_reference)
@@ -89,8 +102,10 @@ describe Debitech::ServerApi, "charge" do
89
102
 
90
103
  [ 200, 250, 300, 400 ].each do |result_code|
91
104
  it "should not be successful for result_code #{result_code}" do
92
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
93
- soap_api.stub!(:subscribe_and_settle).and_return(response = mock(:result_code => result_code))
105
+ soap_api = double
106
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
107
+ response = double(:result_code => result_code)
108
+ allow(soap_api).to receive(:subscribe_and_settle).and_return(response)
94
109
 
95
110
  server_api = Debitech::ServerApi.new({})
96
111
  result = server_api.charge(unique_reference)
@@ -102,8 +117,10 @@ describe Debitech::ServerApi, "charge" do
102
117
  end
103
118
 
104
119
  it "should return pending and not be successful for 403" do
105
- DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
106
- soap_api.stub!(:subscribe_and_settle).and_return(response = mock(:result_code => 403))
120
+ soap_api = double
121
+ allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
122
+ response = double(:result_code => 403)
123
+ allow(soap_api).to receive(:subscribe_and_settle).and_return(response)
107
124
  server_api = Debitech::ServerApi.new({})
108
125
  result = server_api.charge(unique_reference)
109
126
 
@@ -1,5 +1,5 @@
1
- require 'ostruct'
2
- require 'debitech'
1
+ require "ostruct"
2
+ require "debitech"
3
3
 
4
4
  describe Debitech::WebApi do
5
5
  let(:secret_key) {
@@ -26,7 +26,8 @@ describe Debitech::WebApi do
26
26
 
27
27
  describe "form_action" do
28
28
  it "return the url based on shop" do
29
- expect(Debitech::WebApi.new({ :merchant => "shop" }).form_action).to include "https://secure.incab.se/verify/bin/shop/index"
29
+ api = Debitech::WebApi.new({ :merchant => "myshop" })
30
+ expect(api.form_action).to include "https://securedt.dibspayment.com/verify/bin/myshop/index"
30
31
  end
31
32
  end
32
33
 
@@ -34,14 +35,14 @@ describe Debitech::WebApi do
34
35
  context "given reply is 'A' for approved" do
35
36
  it "is true" do
36
37
  api = Debitech::WebApi.new
37
- expect(api.approved_reply?("A")).to be_true
38
+ expect(api.approved_reply?("A")).to be true
38
39
  end
39
40
  end
40
41
 
41
42
  context "given reply is 'D' for denied" do
42
43
  it "is false" do
43
44
  api = Debitech::WebApi.new
44
- expect(api.approved_reply?("D")).to be_false
45
+ expect(api.approved_reply?("D")).to be false
45
46
  end
46
47
  end
47
48
  end
@@ -49,22 +50,22 @@ describe Debitech::WebApi do
49
50
  describe "valid_response?" do
50
51
  it "validate that the response hashes down to the mac value" do
51
52
  api = Debitech::WebApi.new(secret_key)
52
- expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be_true
53
+ expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be true
53
54
  end
54
55
 
55
56
  it "is not true if any of the values are wrong" do
56
57
  api = Debitech::WebApi.new(secret_key)
57
- expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234568")).to be_false
58
+ expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234568")).to be false
58
59
  end
59
60
 
60
61
  it "is not true if the secretkey is different" do
61
62
  api = Debitech::WebApi.new({ :secret_key => "secretkey2" })
62
- expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be_false
63
+ expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be false
63
64
  end
64
65
 
65
66
  it "handle if verify_id is an int" do
66
67
  api = Debitech::WebApi.new(secret_key)
67
- expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", 1234567)).to be_true
68
+ expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", 1234567)).to be true
68
69
  end
69
70
  end
70
71
  end
metadata CHANGED
@@ -1,49 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debitech
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joakim Kolsjö
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: debitech_soap
16
- requirement: &70154789689380 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70154789689380
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rake
27
- requirement: &70154789688920 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70154789688920
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rspec
38
- requirement: &70154789688500 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70154789688500
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  description: Library for doing payments using DebiTech (DIBS)
48
56
  email:
49
57
  - joakim@barsoom.se
@@ -51,9 +59,9 @@ executables: []
51
59
  extensions: []
52
60
  extra_rdoc_files: []
53
61
  files:
54
- - .gitignore
55
- - .rvmrc
56
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".rvmrc"
64
+ - ".travis.yml"
57
65
  - Gemfile
58
66
  - README.md
59
67
  - Rakefile
@@ -67,29 +75,25 @@ files:
67
75
  - spec/debitech/web_api_spec.rb
68
76
  homepage: https://github.com/barsoom/debitech
69
77
  licenses: []
78
+ metadata: {}
70
79
  post_install_message:
71
80
  rdoc_options: []
72
81
  require_paths:
73
82
  - lib
74
83
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
84
  requirements:
77
- - - ! '>='
85
+ - - ">="
78
86
  - !ruby/object:Gem::Version
79
87
  version: 1.8.7
80
88
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
89
  requirements:
83
- - - ! '>='
90
+ - - ">="
84
91
  - !ruby/object:Gem::Version
85
92
  version: '0'
86
- segments:
87
- - 0
88
- hash: 1595935195943276561
89
93
  requirements: []
90
94
  rubyforge_project:
91
- rubygems_version: 1.8.5
95
+ rubygems_version: 2.4.8
92
96
  signing_key:
93
- specification_version: 3
97
+ specification_version: 4
94
98
  summary: Library for doing payments using DebiTech (DIBS)
95
99
  test_files: []