debitech 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/README.md +4 -2
- data/lib/debitech/version.rb +1 -1
- data/lib/debitech/web_api.rb +15 -8
- data/spec/debitech/web_api_spec.rb +11 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24d3837cce2fed9f2d327af0a5e14a45956a7826
|
4
|
+
data.tar.gz: 9353b96c987b1314af7487cdd795ef54d9b4ebb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c309871d7f6a87f2e3abb27fe4a50cbaf137a19f22b923e536dcdc7bbacfc9854a65c3cdde6d0d1600b66ff09d37e9c3464351ee07e5e32850260c37edb0f7d
|
7
|
+
data.tar.gz: 15e0e23ba1d96ab869b5ce09985cafb68000969ed781be8b32d229592f4e0491781bb30a0dcdd74fc999dec7cb537201051a4f17884967cd908d6266aa2c1dc6
|
data/.travis.yml
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
3
|
+
- 2.3.0
|
4
4
|
- 1.9.3
|
5
5
|
- jruby-19mode
|
6
6
|
- rbx-19mode
|
7
7
|
- ruby-head
|
8
8
|
- jruby-head
|
9
|
-
|
9
|
+
|
10
|
+
# Workaround for Travis + Bundler issues. If this ticket has been resolved, maybe we can remove the workaround.
|
11
|
+
# https://github.com/travis-ci/travis-ci/issues/3531
|
12
|
+
before_install:
|
13
|
+
- gem install bundler
|
data/README.md
CHANGED
@@ -46,13 +46,15 @@ Get the API docs in DIBS manager, setup the account.
|
|
46
46
|
debitech_web_config = {
|
47
47
|
:merchant => "ACCOUNT_NAME",
|
48
48
|
:secret_key => "MAC",
|
49
|
-
:fields => { :method => "METHOD" }
|
49
|
+
:fields => { :method => "METHOD", pageSet: "my-default-pageset" }
|
50
50
|
}
|
51
51
|
|
52
52
|
# In the view: form to redirect the user to DIBS
|
53
|
+
# You can optionally pass a hash of further custom fields.
|
53
54
|
<% api = Debitech::WebApi.new(debitech_web_config) %>
|
55
|
+
<% custom_fields = { pageSet: "my-custom-pageset" } %>
|
54
56
|
<form accept-charset="iso-8859-1" action="<%= api.form_action %>" method="post">
|
55
|
-
<% api.form_fields.each do |name, value| %>
|
57
|
+
<% api.form_fields(custom_fields).each do |name, value| %>
|
56
58
|
<input name="<%= name %>" type="hidden" value="<%= value %>">
|
57
59
|
<% end %>
|
58
60
|
|
data/lib/debitech/version.rb
CHANGED
data/lib/debitech/web_api.rb
CHANGED
@@ -6,16 +6,23 @@ module Debitech
|
|
6
6
|
APPROVED_REPLY = "A"
|
7
7
|
|
8
8
|
def initialize(opts = {})
|
9
|
-
@
|
9
|
+
@merchant = opts.fetch(:merchant, nil)
|
10
|
+
@secret_key = opts.fetch(:secret_key, nil)
|
11
|
+
@custom_fields = opts.fetch(:fields, {})
|
10
12
|
end
|
11
13
|
|
12
14
|
# you probably want to encode these when posting to dibs, for example HTMLEntities.new.encode(v, :named) (gem: htmlentities)
|
13
|
-
def form_fields
|
14
|
-
|
15
|
+
def form_fields(more_custom_fields = {})
|
16
|
+
# Overriding via the initializer may be more convenient for per-env stuff like "method"".
|
17
|
+
# Overriding via the method argument may be more convenient for per-request stuff like multiple pageSets.
|
18
|
+
base_fields.
|
19
|
+
merge(@custom_fields).
|
20
|
+
merge(more_custom_fields).
|
21
|
+
merge(:MAC => request_mac)
|
15
22
|
end
|
16
23
|
|
17
24
|
def form_action
|
18
|
-
"https://securedt.dibspayment.com/verify/bin/#{@
|
25
|
+
"https://securedt.dibspayment.com/verify/bin/#{@merchant}/index"
|
19
26
|
end
|
20
27
|
|
21
28
|
def valid_response?(mac, sum, reply, verify_id)
|
@@ -42,16 +49,16 @@ module Debitech
|
|
42
49
|
:billingAddress => "Address",
|
43
50
|
:billingCity => "City",
|
44
51
|
:billingCountry => "Country",
|
45
|
-
:eMail => "email@example.com"
|
46
|
-
}
|
52
|
+
:eMail => "email@example.com",
|
53
|
+
}
|
47
54
|
end
|
48
55
|
|
49
56
|
def request_mac
|
50
|
-
Mac.build [ base_fields[:data], base_fields[:currency], base_fields[:method], @
|
57
|
+
Mac.build [ base_fields[:data], base_fields[:currency], base_fields[:method], @secret_key ]
|
51
58
|
end
|
52
59
|
|
53
60
|
def response_mac(sum, reply, verify_id)
|
54
|
-
Mac.build [ sum, base_fields[:currency], reply, verify_id, @
|
61
|
+
Mac.build [ sum, base_fields[:currency], reply, verify_id, @secret_key ]
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
@@ -9,13 +9,20 @@ describe Debitech::WebApi do
|
|
9
9
|
describe "form_fields" do
|
10
10
|
it "include static values" do
|
11
11
|
fields = Debitech::WebApi.new(secret_key).form_fields
|
12
|
-
expect(fields[:currency]).to
|
13
|
-
expect(fields[:method]).to
|
12
|
+
expect(fields[:currency]).to eq "SEK"
|
13
|
+
expect(fields[:method]).to eq "cc.test"
|
14
14
|
end
|
15
15
|
|
16
|
-
it "is possible to override the values" do
|
16
|
+
it "is possible to override the values via the initializer" do
|
17
17
|
fields = Debitech::WebApi.new(secret_key.merge(:fields => { :method => "cc.cekab" })).form_fields
|
18
|
-
expect(fields[:method]).to
|
18
|
+
expect(fields[:method]).to eq "cc.cekab"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "is possible to override the values via method parameters" do
|
22
|
+
api = Debitech::WebApi.new(secret_key.merge(:fields => { :pageSet => "mydefault" }))
|
23
|
+
|
24
|
+
expect(api.form_fields.fetch(:pageSet)).to eq "mydefault"
|
25
|
+
expect(api.form_fields(pageSet: "override").fetch(:pageSet)).to eq "override"
|
19
26
|
end
|
20
27
|
|
21
28
|
it "calculate mac" do
|