debitech 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +1 -1
- data/.travis.yml +9 -0
- data/README.md +109 -6
- data/Rakefile +1 -1
- data/debitech.gemspec +20 -16
- data/lib/debitech/server_api.rb +1 -1
- data/lib/debitech/version.rb +2 -1
- data/lib/debitech/web_api.rb +7 -6
- data/lib/debitech.rb +3 -3
- data/spec/debitech/server_api_spec.rb +46 -37
- data/spec/debitech/web_api_spec.rb +52 -47
- metadata +14 -33
- data/LICENSE +0 -22
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm ruby-1.9.3
|
1
|
+
rvm use --create ruby-1.9.3@debitech
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
# Debitech
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/barsoom/debitech.png?branch=master)](https://travis-ci.org/barsoom/debitech)
|
4
|
+
|
3
5
|
This is a DebiTech payment library extracted from production code.
|
4
6
|
|
5
|
-
You can use this to do subscription payments without needing to handle any
|
6
|
-
|
7
|
+
You can use this to do subscription payments without needing to handle any credit card information yourself.
|
8
|
+
|
9
|
+
If you want something more low level, check the [debitech_soap](https://github.com/joakimk/debitech_soap) gem, which this library uses for API access.
|
10
|
+
|
11
|
+
Setting up payments using DebiTech (one of the two payment systems run by DIBS) is not trivial,
|
12
|
+
but it seems there are not many good options in Sweden yet. Atleast using this you don't need to
|
13
|
+
figure out things like how to validate responses or how to not double charge, etc.
|
7
14
|
|
8
15
|
Todo:
|
9
16
|
|
10
|
-
*
|
11
|
-
* Gotchas about the debitech API
|
17
|
+
* Example app
|
12
18
|
* Page set templates (the pages that are shown at DIBS to input credit card info)
|
13
19
|
* Rake tasks to update page sets
|
14
20
|
|
@@ -26,9 +32,78 @@ Or install it yourself as:
|
|
26
32
|
|
27
33
|
$ gem install debitech
|
28
34
|
|
29
|
-
## Usage
|
35
|
+
## Usage: Preparation
|
36
|
+
|
37
|
+
Get the API docs in DIBS manager, setup the account.
|
38
|
+
|
39
|
+
TODO: Someone could send a pull request with more docs here on how to setup a new
|
40
|
+
account, what to consider and what you should ask the support for.
|
41
|
+
|
42
|
+
## Usage: Adding a credit card
|
43
|
+
|
44
|
+
# MAC: Secret key shared by your app and DIBS, get it from the DIBS manager
|
45
|
+
# METHOD: Something like cc.cekab, check the docs or ask support.
|
46
|
+
debitech_web_config = {
|
47
|
+
:merchant => "ACCOUNT_NAME",
|
48
|
+
:secret_key => "MAC",
|
49
|
+
:fields => { :method => "METHOD" }
|
50
|
+
}
|
51
|
+
|
52
|
+
# In the view: form to redirect the user to DIBS
|
53
|
+
<% api = Debitech::WebApi.new(debitech_web_config) %>
|
54
|
+
<form accept-charset="iso-8859-1" action="<%= api.form_action %>" method="post">
|
55
|
+
<% api.form_fields.each do |name, value| %>
|
56
|
+
<input name="<%= name %>" type="hidden" value="<%= value %>">
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
<!-- send translation strings, redirect back urls, etc here -->
|
60
|
+
<input name="redirect_back_url" type="hidden" value="https://yourapp/credit_cards">
|
61
|
+
</form>
|
62
|
+
|
63
|
+
# When you get the response back (TODO: add example templates)
|
64
|
+
api.valid_response?(mac, sum, reply, verify_id) # is the response from DIBS?
|
65
|
+
api.approved_reply?(reply) # was the card added successfully?
|
66
|
+
|
67
|
+
# Store verify_id as your reference to the card.
|
68
|
+
|
69
|
+
## Usage: Charging a credit card
|
70
|
+
|
71
|
+
Configuration:
|
30
72
|
|
31
|
-
|
73
|
+
# METHOD, MAC, ACCOUNT_NAME: Just like with the Web Api.
|
74
|
+
# API_USER, API_PASSWORD: A API user you can create in DIBS manager.
|
75
|
+
debitech_server_config = {
|
76
|
+
:method => "METHOD",
|
77
|
+
:secret_key => "MAC",
|
78
|
+
:soap_opts => {
|
79
|
+
:merchant => "ACCOUNT_NAME",
|
80
|
+
:username => "API_USER",
|
81
|
+
:password => "API_PASSWORD"
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
First try to get "valid_credentials?" to return true using [debitech_soap](https://github.com/joakimk/debitech_soap). If it does not work, try to regenerate the password for the API user. Some characters are not possible with the SOAP library.
|
86
|
+
|
87
|
+
Charging a credit card:
|
88
|
+
|
89
|
+
debitech = Debitech::ServerApi.new(debitech_server_config)
|
90
|
+
|
91
|
+
# VERIFY_ID: The id you get back when registering a card.
|
92
|
+
# AMOUNT: The amount to charge, must be in cents (1 SEK = 100).
|
93
|
+
# IP: The ip, can be "127.0.0.1", but the request ip is probably more useful.
|
94
|
+
# UNIQUE_REFERENCE: A unique reference, you want this to be something like invoice-NUM, so that you can search for it
|
95
|
+
# in DIBS manager with "invoice*". This is required so that you don't charge more than once for a
|
96
|
+
# single payment by accident. Must be atleast 5 characters long.
|
97
|
+
|
98
|
+
debitech.charge(:verify_id => verify_id,
|
99
|
+
:amount => AMOUNT,
|
100
|
+
:unique_reference => "UNIQUE_REFERENCE",
|
101
|
+
:currency => "SEK",
|
102
|
+
:ip => "IP")
|
103
|
+
|
104
|
+
This returns a Debitech::ServerApi::ChargeResult, check [server_api.rb](https://github.com/barsoom/debitech/blob/master/lib/debitech/server_api.rb).
|
105
|
+
|
106
|
+
In case it's "pending?", you can try again later with the same unique reference. The status is probably due to some temporary timeout or error between DIBS and the bank systems.
|
32
107
|
|
33
108
|
## Contributing
|
34
109
|
|
@@ -37,3 +112,31 @@ TODO: Write usage instructions here
|
|
37
112
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
38
113
|
4. Push to the branch (`git push origin my-new-feature`)
|
39
114
|
5. Create new Pull Request
|
115
|
+
|
116
|
+
## Credits and license
|
117
|
+
|
118
|
+
By [Joakim Kolsjö](https://github.com/joakimk) for [Barsoom](http://barsoom.se) under the MIT license.
|
119
|
+
|
120
|
+
Contributors:
|
121
|
+
|
122
|
+
* [Tobias Bohwalli](https://github.com/futhr)
|
123
|
+
|
124
|
+
> Copyright (c) 2013 Barsoom AB
|
125
|
+
>
|
126
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
127
|
+
> of this software and associated documentation files (the "Software"), to deal
|
128
|
+
> in the Software without restriction, including without limitation the rights
|
129
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
130
|
+
> copies of the Software, and to permit persons to whom the Software is
|
131
|
+
> furnished to do so, subject to the following conditions:
|
132
|
+
>
|
133
|
+
> The above copyright notice and this permission notice shall be included in
|
134
|
+
> all copies or substantial portions of the Software.
|
135
|
+
>
|
136
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
137
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
138
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
139
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
140
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
141
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
142
|
+
> THE SOFTWARE.
|
data/Rakefile
CHANGED
data/debitech.gemspec
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require File.expand_path('../lib/debitech/version', __FILE__)
|
3
3
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.authors = ["Joakim Kolsjö"]
|
7
|
+
s.email = ["joakim@barsoom.se"]
|
8
|
+
s.description = %q{Library for doing payments using DebiTech (DIBS)}
|
9
|
+
s.summary = %q{Library for doing payments using DebiTech (DIBS)}
|
10
|
+
s.homepage = "https://github.com/barsoom/debitech"
|
11
|
+
s.name = "debitech"
|
12
|
+
s.version = Debitech::VERSION
|
13
|
+
|
14
|
+
s.required_ruby_version = ">= 1.8.7"
|
15
|
+
|
16
|
+
s.add_dependency "debitech_soap"
|
17
|
+
|
18
|
+
s.add_development_dependency "rake"
|
19
|
+
s.add_development_dependency "rspec"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
23
|
+
s.require_paths = ["lib"]
|
20
24
|
end
|
data/lib/debitech/server_api.rb
CHANGED
@@ -22,7 +22,7 @@ module Debitech
|
|
22
22
|
end
|
23
23
|
|
24
24
|
class ValidUniqueReferenceRequired < StandardError; end
|
25
|
-
|
25
|
+
|
26
26
|
# Don't know about the upper bound, but we need it to be atleast 5 characters to be
|
27
27
|
# able to search for it in DIBS Manager.
|
28
28
|
LEAST_NUMBER_OF_CHARACTERS_IN_UNIQUE_ID = 5
|
data/lib/debitech/version.rb
CHANGED
data/lib/debitech/web_api.rb
CHANGED
@@ -9,6 +9,7 @@ module Debitech
|
|
9
9
|
@opts = opts
|
10
10
|
end
|
11
11
|
|
12
|
+
# you probably want to encode these when posting to dibs, for example HTMLEntities.new.encode(v, :named) (gem: htmlentities)
|
12
13
|
def form_fields
|
13
14
|
base_fields.merge(:MAC => request_mac)
|
14
15
|
end
|
@@ -30,12 +31,12 @@ module Debitech
|
|
30
31
|
def base_fields
|
31
32
|
{
|
32
33
|
:currency => "SEK",
|
33
|
-
:method =>
|
34
|
-
:amount =>
|
35
|
-
:authOnly =>
|
36
|
-
:pageSet =>
|
37
|
-
:data =>
|
38
|
-
:uses3dsecure =>
|
34
|
+
:method => "cc.test",
|
35
|
+
:amount => "100",
|
36
|
+
:authOnly => "true",
|
37
|
+
:pageSet => "creditcard",
|
38
|
+
:data => "001:auth:1:100:",
|
39
|
+
:uses3dsecure => "false",
|
39
40
|
:billingFirstName => "First name",
|
40
41
|
:billingLastName => "Last name",
|
41
42
|
:billingAddress => "Address",
|
data/lib/debitech.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'debitech/version'
|
2
|
+
require 'debitech/server_api'
|
3
|
+
require 'debitech/web_api'
|
@@ -1,104 +1,113 @@
|
|
1
1
|
require 'debitech'
|
2
2
|
|
3
3
|
describe Debitech::ServerApi, "charge" do
|
4
|
+
let(:unique_reference) {
|
5
|
+
{ :unique_reference => "some_unique_ref" }
|
6
|
+
}
|
7
|
+
|
8
|
+
let(:transaction) {
|
9
|
+
{ :verify_id => 1234567, :amount => 2235, :currency => "SEK", :ip => "127.0.0.1" }.merge(unique_reference)
|
10
|
+
}
|
4
11
|
|
5
12
|
it "should perform a subscribe_and_settle call" do
|
6
|
-
settings = {
|
13
|
+
settings = {
|
7
14
|
:secret_key => "112756FC8C60C5603C58DA6E0A4844ACFDB60525",
|
8
15
|
:method => "cc.cekab",
|
9
|
-
:soap_opts => {
|
16
|
+
:soap_opts => {
|
17
|
+
:merchant => "store",
|
18
|
+
:username => "api_user",
|
19
|
+
:password => "api_password"
|
20
|
+
}
|
21
|
+
}
|
10
22
|
|
11
23
|
DebitechSoap::API.should_receive(:new).with({ :merchant => "store", :username => "api_user", :password => "api_password" }).
|
12
|
-
and_return(soap_api = mock)
|
24
|
+
and_return(soap_api = mock)
|
13
25
|
soap_api.should_receive(:subscribe_and_settle).with(:verifyID => 1234567,
|
14
26
|
:data => "001:payment:1:10000:",
|
15
27
|
:ip => "127.0.0.1",
|
16
28
|
:extra => "&method=cc.cekab¤cy=SEK&MAC=1931EE498A77F6B12B2C2D2EC8599719EF9CE419&referenceNo=some_unique_ref")
|
17
29
|
|
18
30
|
server_api = Debitech::ServerApi.new(settings)
|
19
|
-
server_api.charge(:
|
31
|
+
server_api.charge(transaction.merge(:amount => 10000))
|
20
32
|
end
|
21
33
|
|
22
34
|
it "should convert the amount to a integer to avoid 500 errors" do
|
23
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
35
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
24
36
|
soap_api.should_receive(:subscribe_and_settle).with(:verifyID => 1234567,
|
25
37
|
:data => "001:payment:1:2235:",
|
26
38
|
:ip => "127.0.0.1",
|
27
39
|
:extra => "&method=¤cy=SEK&MAC=78B1144270B1A74A55539FAEB81BB49EC39B90DF&referenceNo=some_unique_ref")
|
28
40
|
|
29
41
|
server_api = Debitech::ServerApi.new({})
|
30
|
-
server_api.charge(:
|
42
|
+
server_api.charge(transaction.merge(:amount => 2235.0))
|
31
43
|
end
|
32
44
|
|
33
45
|
it "should raise an error if the amount has a fraction" do
|
34
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
46
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
35
47
|
server_api = Debitech::ServerApi.new({})
|
36
|
-
|
37
|
-
server_api.charge(:
|
38
|
-
}.
|
48
|
+
expect {
|
49
|
+
server_api.charge(transaction.merge(:amount => 2235.55))
|
50
|
+
}.to raise_error("The amount (2235.55) contains fractions (for example 10.44 instead of 10), amount should specified in cents.")
|
39
51
|
end
|
40
52
|
|
41
53
|
it "should raise an error if the unique_reference is nil" do
|
42
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
54
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
43
55
|
server_api = Debitech::ServerApi.new({})
|
44
|
-
|
45
|
-
server_api.charge(:
|
46
|
-
}.
|
56
|
+
expect {
|
57
|
+
server_api.charge(transaction.merge(:unique_reference => nil))
|
58
|
+
}.to raise_error(Debitech::ServerApi::ValidUniqueReferenceRequired)
|
47
59
|
end
|
48
60
|
|
49
61
|
it "should raise an error if the unique_reference is less than 4 characters" do
|
50
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
62
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
51
63
|
server_api = Debitech::ServerApi.new({})
|
52
|
-
|
53
|
-
server_api.charge(:
|
54
|
-
|
55
|
-
}.should raise_error(Debitech::ServerApi::ValidUniqueReferenceRequired)
|
64
|
+
expect {
|
65
|
+
server_api.charge(transaction.merge(:unique_reference => "1234"))
|
66
|
+
}.to raise_error(Debitech::ServerApi::ValidUniqueReferenceRequired)
|
56
67
|
end
|
57
68
|
|
58
69
|
it "should be valid with a 5 character unique_reference" do
|
59
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
70
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
60
71
|
soap_api.stub!(:subscribe_and_settle)
|
61
72
|
server_api = Debitech::ServerApi.new({})
|
62
|
-
server_api.charge(:
|
63
|
-
:unique_reference => "12345", :ip => "127.0.0.1")
|
73
|
+
server_api.charge(transaction.merge(:unique_reference => "12345"))
|
64
74
|
end
|
65
75
|
|
66
76
|
[ 100, 101, 150, 199 ].each do |result_code|
|
67
77
|
it "should return success for result_code #{result_code}" do
|
68
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
78
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
69
79
|
soap_api.stub!(:subscribe_and_settle).and_return(response = mock(:result_code => result_code))
|
70
80
|
|
71
81
|
server_api = Debitech::ServerApi.new({})
|
72
|
-
result = server_api.charge(
|
82
|
+
result = server_api.charge(unique_reference)
|
73
83
|
|
74
|
-
result.
|
75
|
-
result.
|
76
|
-
result.response.result_code.
|
84
|
+
expect(result).to be_success
|
85
|
+
expect(result).not_to be_pending
|
86
|
+
expect(result.response.result_code).to eql result_code
|
77
87
|
end
|
78
88
|
end
|
79
89
|
|
80
90
|
[ 200, 250, 300, 400 ].each do |result_code|
|
81
91
|
it "should not be successful for result_code #{result_code}" do
|
82
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
92
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
83
93
|
soap_api.stub!(:subscribe_and_settle).and_return(response = mock(:result_code => result_code))
|
84
94
|
|
85
95
|
server_api = Debitech::ServerApi.new({})
|
86
|
-
result = server_api.charge(
|
96
|
+
result = server_api.charge(unique_reference)
|
87
97
|
|
88
|
-
result.
|
89
|
-
result.
|
90
|
-
result.response.result_code.
|
98
|
+
expect(result).not_to be_success
|
99
|
+
expect(result).not_to be_pending
|
100
|
+
expect(result.response.result_code).to eql result_code
|
91
101
|
end
|
92
102
|
end
|
93
103
|
|
94
104
|
it "should return pending and not be successful for 403" do
|
95
|
-
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
105
|
+
DebitechSoap::API.stub!(:new).and_return(soap_api = mock)
|
96
106
|
soap_api.stub!(:subscribe_and_settle).and_return(response = mock(:result_code => 403))
|
97
107
|
server_api = Debitech::ServerApi.new({})
|
98
|
-
result = server_api.charge(
|
108
|
+
result = server_api.charge(unique_reference)
|
99
109
|
|
100
|
-
result.
|
101
|
-
result.
|
110
|
+
expect(result).not_to be_success
|
111
|
+
expect(result).to be_pending
|
102
112
|
end
|
103
|
-
|
104
113
|
end
|
@@ -1,65 +1,70 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'debitech'
|
3
3
|
|
4
|
-
describe Debitech::WebApi
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
fields[:method].should == 'cc.test'
|
9
|
-
end
|
4
|
+
describe Debitech::WebApi do
|
5
|
+
let(:secret_key) {
|
6
|
+
{ :secret_key => "secretkey" }
|
7
|
+
}
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
describe "form_fields" do
|
10
|
+
it "include static values" do
|
11
|
+
fields = Debitech::WebApi.new(secret_key).form_fields
|
12
|
+
expect(fields[:currency]).to match /SEK/
|
13
|
+
expect(fields[:method]).to match /cc.test/
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
it "is possible to override the values" do
|
17
|
+
fields = Debitech::WebApi.new(secret_key.merge(:fields => { :method => "cc.cekab" })).form_fields
|
18
|
+
expect(fields[:method]).to match /cc.cekab/
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
it "calculate mac" do
|
22
|
+
expect(Debitech::WebApi.new({ :secret_key => "secretkey1" }).form_fields[:MAC]).to match /DF253765337968C5ED7E6EA530CD692942416ABE/
|
23
|
+
expect(Debitech::WebApi.new({ :secret_key => "secretkey2" }).form_fields[:MAC]).to match /BEB3C370E37837734642111D44CA7E304A0F45F2/
|
24
|
+
end
|
25
25
|
end
|
26
|
-
end
|
27
26
|
|
28
|
-
describe
|
29
|
-
|
30
|
-
|
31
|
-
api = Debitech::WebApi.new
|
32
|
-
api.approved_reply?("A").should be_true
|
27
|
+
describe "form_action" do
|
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"
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
describe "approved_response?" do
|
34
|
+
context "given reply is 'A' for approved" do
|
35
|
+
it "is true" do
|
36
|
+
api = Debitech::WebApi.new
|
37
|
+
expect(api.approved_reply?("A")).to be_true
|
38
|
+
end
|
40
39
|
end
|
41
|
-
end
|
42
|
-
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
context "given reply is 'D' for denied" do
|
42
|
+
it "is false" do
|
43
|
+
api = Debitech::WebApi.new
|
44
|
+
expect(api.approved_reply?("D")).to be_false
|
45
|
+
end
|
46
|
+
end
|
48
47
|
end
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
describe "valid_response?" do
|
50
|
+
it "validate that the response hashes down to the mac value" do
|
51
|
+
api = Debitech::WebApi.new(secret_key)
|
52
|
+
expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be_true
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
it "is not true if any of the values are wrong" do
|
56
|
+
api = Debitech::WebApi.new(secret_key)
|
57
|
+
expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234568")).to be_false
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
it "is not true if the secretkey is different" do
|
61
|
+
api = Debitech::WebApi.new({ :secret_key => "secretkey2" })
|
62
|
+
expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be_false
|
63
|
+
end
|
64
64
|
|
65
|
-
|
65
|
+
it "handle if verify_id is an int" do
|
66
|
+
api = Debitech::WebApi.new(secret_key)
|
67
|
+
expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", 1234567)).to be_true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debitech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Joakim
|
8
|
+
- Joakim Kolsjö
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: debitech_soap
|
16
|
-
requirement: &
|
16
|
+
requirement: &70154789689380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70154789689380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70154789688920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70154789688920
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70154789688500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,29 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: guard
|
49
|
-
requirement: &2152305800 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *2152305800
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: guard-rspec
|
60
|
-
requirement: &2152304760 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ! '>='
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '0'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *2152304760
|
46
|
+
version_requirements: *70154789688500
|
69
47
|
description: Library for doing payments using DebiTech (DIBS)
|
70
48
|
email:
|
71
49
|
- joakim@barsoom.se
|
@@ -75,8 +53,8 @@ extra_rdoc_files: []
|
|
75
53
|
files:
|
76
54
|
- .gitignore
|
77
55
|
- .rvmrc
|
56
|
+
- .travis.yml
|
78
57
|
- Gemfile
|
79
|
-
- LICENSE
|
80
58
|
- README.md
|
81
59
|
- Rakefile
|
82
60
|
- debitech.gemspec
|
@@ -98,13 +76,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
76
|
requirements:
|
99
77
|
- - ! '>='
|
100
78
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
79
|
+
version: 1.8.7
|
102
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
81
|
none: false
|
104
82
|
requirements:
|
105
83
|
- - ! '>='
|
106
84
|
- !ruby/object:Gem::Version
|
107
85
|
version: '0'
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
hash: 1595935195943276561
|
108
89
|
requirements: []
|
109
90
|
rubyforge_project:
|
110
91
|
rubygems_version: 1.8.5
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Joakim Kolsjö
|
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.
|