debitech 1.6.0 → 1.6.1
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/.github/workflows/ci.yml +26 -0
- data/.rubocop.yml +5 -0
- data/Gemfile +9 -1
- data/README.md +66 -56
- data/Rakefile +5 -5
- data/debitech.gemspec +5 -4
- data/lib/debitech/server_api.rb +2 -2
- data/lib/debitech/version.rb +1 -1
- data/lib/debitech/web_api.rb +13 -13
- data/lib/debitech.rb +3 -3
- data/spec/debitech/server_api_spec.rb +29 -29
- data/spec/debitech/web_api_spec.rb +11 -11
- metadata +7 -5
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 448697aa6d7c6fec201cbca4371590832853ab761f32fde54fa510a85598611a
|
4
|
+
data.tar.gz: 475d18a41fbfbf71660dc6e897721fda5b83aea1127609be20954de89894330b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09ed9bdb56735924483932fa52135f19dc60235e9302814dfe2620509746cb6d008c64ea92d6aa19b298db53933ffdd2daf1a8deab97f453e057a0f57fa025a1'
|
7
|
+
data.tar.gz: '08b6a7ab5517031de70b1bf98e63c9a71b86baa570db26c948717552541039a9c856ce62053d997c70accea43a0a1a1b60a1051f75668957dd0bad3abd9a6ab1'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby-version: ["3.0", "2.7", "2.6", "2.5", "jruby-head"]
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
21
|
+
uses: ruby/setup-ruby@ae9cb3b565e36682a2c6045e4f664388da4c73aa
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Debitech
|
2
2
|
|
3
|
-
[](https://github.com/barsoom/debitech/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
This is a DebiTech payment library extracted from production code.
|
6
6
|
|
7
7
|
You can use this to do subscription payments without needing to handle any credit card information yourself.
|
8
8
|
|
9
|
-
If you want something more low
|
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
10
|
|
11
11
|
Setting up payments using DebiTech (one of the two payment systems run by DIBS) is not trivial,
|
12
12
|
but it seems there are not many good options in Sweden yet. Atleast using this you don't need to
|
@@ -22,7 +22,9 @@ Todo:
|
|
22
22
|
|
23
23
|
Add this line to your application's Gemfile:
|
24
24
|
|
25
|
-
|
25
|
+
```ruby
|
26
|
+
gem 'debitech'
|
27
|
+
```
|
26
28
|
|
27
29
|
And then execute:
|
28
30
|
|
@@ -41,69 +43,77 @@ Get the API docs in DIBS manager, setup the account.
|
|
41
43
|
|
42
44
|
## Usage: Adding a credit card
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
46
|
+
```erb
|
47
|
+
# MAC: Secret key shared by your app and DIBS, get it from the DIBS manager
|
48
|
+
# METHOD: Something like cc.cekab, check the docs or ask support.
|
49
|
+
debitech_web_config = {
|
50
|
+
:merchant => "ACCOUNT_NAME",
|
51
|
+
:secret_key => "MAC",
|
52
|
+
:fields => { :method => "METHOD", pageSet: "my-default-pageset" }
|
53
|
+
}
|
54
|
+
|
55
|
+
# In the view: form to redirect the user to DIBS
|
56
|
+
<% api = Debitech::WebApi.new(debitech_web_config) %>
|
57
|
+
# You can optionally pass a hash of further custom fields.
|
58
|
+
# Note that if you override the "currency" here, you will also need to pass it explicitly into `valid_response?`.
|
59
|
+
<% custom_fields = { pageSet: "my-custom-pageset" } %>
|
60
|
+
<form accept-charset="iso-8859-1" action="<%= api.form_action %>" method="post">
|
61
|
+
<% api.form_fields(custom_fields).each do |name, value| %>
|
62
|
+
<input name="<%= name %>" type="hidden" value="<%= value %>">
|
63
|
+
<% end %>
|
64
|
+
|
65
|
+
<!-- send translation strings, redirect back urls, etc here -->
|
66
|
+
<input name="redirect_back_url" type="hidden" value="https://yourapp/credit_cards">
|
67
|
+
</form>
|
68
|
+
```
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
# When you get the response back (TODO: add example templates)
|
72
|
+
api.valid_response?(mac, sum, reply, verify_id) # is the response from DIBS?
|
73
|
+
api.valid_response?(mac, sum, reply, verify_id, currency, reference_number) # if the request included "referenceNo", do this instead
|
74
|
+
api.approved_reply?(reply) # was the card added successfully?
|
75
|
+
|
76
|
+
# Store verify_id as your reference to the card.
|
77
|
+
```
|
72
78
|
|
73
79
|
## Usage: Charging a credit card
|
74
80
|
|
75
81
|
Configuration:
|
76
82
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
```ruby
|
84
|
+
# METHOD, MAC, ACCOUNT_NAME: Just like with the Web Api.
|
85
|
+
# API_USER, API_PASSWORD: A API user you can create in DIBS manager.
|
86
|
+
debitech_server_config = {
|
87
|
+
:method => "METHOD",
|
88
|
+
:secret_key => "MAC",
|
89
|
+
:soap_opts => {
|
90
|
+
:merchant => "ACCOUNT_NAME",
|
91
|
+
:username => "API_USER",
|
92
|
+
:password => "API_PASSWORD"
|
93
|
+
}
|
94
|
+
}
|
95
|
+
```
|
88
96
|
|
89
97
|
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.
|
90
98
|
|
91
99
|
Charging a credit card:
|
92
100
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
101
|
+
```ruby
|
102
|
+
debitech = Debitech::ServerApi.new(debitech_server_config)
|
103
|
+
|
104
|
+
# VERIFY_ID: The id you get back when registering a card.
|
105
|
+
# AMOUNT: The amount to charge, must be in cents (1 SEK = 100).
|
106
|
+
# IP: The ip, can be "127.0.0.1", but the request ip is probably more useful.
|
107
|
+
# UNIQUE_REFERENCE: A unique reference, you want this to be something like invoice-NUM, so that you can search for it
|
108
|
+
# in DIBS manager with "invoice*". This is required so that you don't charge more than once for a
|
109
|
+
# single payment by accident. Must be atleast 5 characters long.
|
110
|
+
|
111
|
+
debitech.charge(:verify_id => verify_id,
|
112
|
+
:amount => AMOUNT,
|
113
|
+
:unique_reference => "UNIQUE_REFERENCE",
|
114
|
+
:currency => "SEK",
|
115
|
+
:ip => "IP")
|
116
|
+
```
|
107
117
|
|
108
118
|
This returns a Debitech::ServerApi::ChargeResult, check [server_api.rb](https://github.com/barsoom/debitech/blob/master/lib/debitech/server_api.rb).
|
109
119
|
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
4
|
|
5
5
|
desc "Run all specs"
|
6
|
-
RSpec::Core::RakeTask.new(
|
7
|
-
t.pattern =
|
6
|
+
RSpec::Core::RakeTask.new("spec") do |t|
|
7
|
+
t.pattern = "spec/**/*.rb"
|
8
8
|
end
|
9
9
|
|
10
|
-
task :
|
10
|
+
task default: :spec
|
11
11
|
|
data/debitech.gemspec
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path(
|
2
|
+
require File.expand_path("../lib/debitech/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
|
-
s.authors = ["Joakim Kolsjö"]
|
7
|
-
s.email = ["joakim@barsoom.se"]
|
6
|
+
s.authors = [ "Joakim Kolsjö" ]
|
7
|
+
s.email = [ "joakim@barsoom.se" ]
|
8
8
|
s.description = %q{Library for doing payments using DebiTech (DIBS)}
|
9
9
|
s.summary = %q{Library for doing payments using DebiTech (DIBS)}
|
10
10
|
s.homepage = "https://github.com/barsoom/debitech"
|
11
11
|
s.name = "debitech"
|
12
12
|
s.version = Debitech::VERSION
|
13
|
+
s.metadata = { "rubygems_mfa_required" => "true" }
|
13
14
|
|
14
15
|
s.required_ruby_version = ">= 1.8.7"
|
15
16
|
|
@@ -20,5 +21,5 @@ Gem::Specification.new do |s|
|
|
20
21
|
|
21
22
|
s.files = `git ls-files`.split("\n")
|
22
23
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
23
|
-
s.require_paths = ["lib"]
|
24
|
+
s.require_paths = [ "lib" ]
|
24
25
|
end
|
data/lib/debitech/server_api.rb
CHANGED
@@ -13,7 +13,7 @@ module Debitech
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def success?
|
16
|
-
@response.result_code.to_s[0,1] == "1"
|
16
|
+
@response.result_code.to_s[0, 1] == "1"
|
17
17
|
end
|
18
18
|
|
19
19
|
def pending?
|
@@ -44,7 +44,7 @@ module Debitech
|
|
44
44
|
data = "001:payment:1:#{opts[:amount].to_i}:"
|
45
45
|
mac = Mac.build [ data, opts[:currency], opts[:unique_reference], @config[:secret_key] ]
|
46
46
|
extra = "&method=#{@config[:method]}¤cy=#{opts[:currency]}&MAC=#{mac}&referenceNo=#{opts[:unique_reference]}"
|
47
|
-
response = @soap_api.subscribe_and_settle(:
|
47
|
+
response = @soap_api.subscribe_and_settle(verifyID: opts[:verify_id], ip: opts[:ip], data: data, extra: extra)
|
48
48
|
ChargeResult.new(response)
|
49
49
|
end
|
50
50
|
end
|
data/lib/debitech/version.rb
CHANGED
data/lib/debitech/web_api.rb
CHANGED
@@ -17,7 +17,7 @@ module Debitech
|
|
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)
|
20
|
-
all_fields_except_mac.merge(:
|
20
|
+
all_fields_except_mac.merge(MAC: mac)
|
21
21
|
end
|
22
22
|
|
23
23
|
def form_action
|
@@ -42,18 +42,18 @@ module Debitech
|
|
42
42
|
|
43
43
|
def base_fields
|
44
44
|
{
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
45
|
+
currency: "SEK",
|
46
|
+
method: "cc.test",
|
47
|
+
amount: "100",
|
48
|
+
authOnly: "true",
|
49
|
+
pageSet: "creditcard",
|
50
|
+
data: "001:auth:1:100:",
|
51
|
+
billingFirstName: "First name",
|
52
|
+
billingLastName: "Last name",
|
53
|
+
billingAddress: "Address",
|
54
|
+
billingCity: "City",
|
55
|
+
billingCountry: "Country",
|
56
|
+
eMail: "email@example.com",
|
57
57
|
}
|
58
58
|
end
|
59
59
|
|
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"
|
@@ -2,51 +2,51 @@ require "debitech"
|
|
2
2
|
|
3
3
|
describe Debitech::ServerApi, "charge" do
|
4
4
|
let(:unique_reference) {
|
5
|
-
{ :
|
5
|
+
{ unique_reference: "some_unique_ref" }
|
6
6
|
}
|
7
7
|
|
8
8
|
let(:transaction) {
|
9
|
-
{ :
|
9
|
+
{ verify_id: 1234567, amount: 2235, currency: "SEK", ip: "127.0.0.1" }.merge(unique_reference)
|
10
10
|
}
|
11
11
|
|
12
12
|
it "should perform a subscribe_and_settle call" do
|
13
13
|
settings = {
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
}
|
14
|
+
secret_key: "112756FC8C60C5603C58DA6E0A4844ACFDB60525",
|
15
|
+
method: "cc.cekab",
|
16
|
+
soap_opts: {
|
17
|
+
merchant: "store",
|
18
|
+
username: "api_user",
|
19
|
+
password: "api_password",
|
20
|
+
},
|
21
21
|
}
|
22
22
|
|
23
23
|
soap_api = double
|
24
|
-
allow(DebitechSoap::API).to receive(:new)
|
25
|
-
with({ :
|
26
|
-
and_return(soap_api)
|
24
|
+
allow(DebitechSoap::API).to receive(:new)
|
25
|
+
.with({ merchant: "store", username: "api_user", password: "api_password" })
|
26
|
+
.and_return(soap_api)
|
27
27
|
expect(soap_api).to receive(:subscribe_and_settle).with(
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
28
|
+
verifyID: 1234567,
|
29
|
+
data: "001:payment:1:10000:",
|
30
|
+
ip: "127.0.0.1",
|
31
|
+
extra: "&method=cc.cekab¤cy=SEK&MAC=1931EE498A77F6B12B2C2D2EC8599719EF9CE419&referenceNo=some_unique_ref",
|
32
32
|
)
|
33
33
|
|
34
34
|
server_api = Debitech::ServerApi.new(settings)
|
35
|
-
server_api.charge(transaction.merge(:
|
35
|
+
server_api.charge(transaction.merge(amount: 10000))
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should convert the amount to a integer to avoid 500 errors" do
|
39
39
|
soap_api = double
|
40
40
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
41
41
|
expect(soap_api).to receive(:subscribe_and_settle).with(
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
42
|
+
verifyID: 1234567,
|
43
|
+
data: "001:payment:1:2235:",
|
44
|
+
ip: "127.0.0.1",
|
45
|
+
extra: "&method=¤cy=SEK&MAC=78B1144270B1A74A55539FAEB81BB49EC39B90DF&referenceNo=some_unique_ref",
|
46
46
|
)
|
47
47
|
|
48
48
|
server_api = Debitech::ServerApi.new({})
|
49
|
-
server_api.charge(transaction.merge(:
|
49
|
+
server_api.charge(transaction.merge(amount: 2235.0))
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should raise an error if the amount has a fraction" do
|
@@ -54,7 +54,7 @@ describe Debitech::ServerApi, "charge" do
|
|
54
54
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
55
55
|
server_api = Debitech::ServerApi.new({})
|
56
56
|
expect {
|
57
|
-
server_api.charge(transaction.merge(:
|
57
|
+
server_api.charge(transaction.merge(amount: 2235.55))
|
58
58
|
}.to raise_error("The amount (2235.55) contains fractions (for example 10.44 instead of 10), amount should specified in cents.")
|
59
59
|
end
|
60
60
|
|
@@ -63,7 +63,7 @@ describe Debitech::ServerApi, "charge" do
|
|
63
63
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
64
64
|
server_api = Debitech::ServerApi.new({})
|
65
65
|
expect {
|
66
|
-
server_api.charge(transaction.merge(:
|
66
|
+
server_api.charge(transaction.merge(unique_reference: nil))
|
67
67
|
}.to raise_error(Debitech::ServerApi::ValidUniqueReferenceRequired)
|
68
68
|
end
|
69
69
|
|
@@ -72,7 +72,7 @@ describe Debitech::ServerApi, "charge" do
|
|
72
72
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
73
73
|
server_api = Debitech::ServerApi.new({})
|
74
74
|
expect {
|
75
|
-
server_api.charge(transaction.merge(:
|
75
|
+
server_api.charge(transaction.merge(unique_reference: "1234"))
|
76
76
|
}.to raise_error(Debitech::ServerApi::ValidUniqueReferenceRequired)
|
77
77
|
end
|
78
78
|
|
@@ -81,14 +81,14 @@ describe Debitech::ServerApi, "charge" do
|
|
81
81
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
82
82
|
allow(soap_api).to receive(:subscribe_and_settle)
|
83
83
|
server_api = Debitech::ServerApi.new({})
|
84
|
-
server_api.charge(transaction.merge(:
|
84
|
+
server_api.charge(transaction.merge(unique_reference: "12345"))
|
85
85
|
end
|
86
86
|
|
87
87
|
[ 100, 101, 150, 199 ].each do |result_code|
|
88
88
|
it "should return success for result_code #{result_code}" do
|
89
89
|
soap_api = double
|
90
90
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
91
|
-
response = double(:
|
91
|
+
response = double(result_code: result_code)
|
92
92
|
allow(soap_api).to receive(:subscribe_and_settle).and_return(response)
|
93
93
|
|
94
94
|
server_api = Debitech::ServerApi.new({})
|
@@ -104,7 +104,7 @@ describe Debitech::ServerApi, "charge" do
|
|
104
104
|
it "should not be successful for result_code #{result_code}" do
|
105
105
|
soap_api = double
|
106
106
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
107
|
-
response = double(:
|
107
|
+
response = double(result_code: result_code)
|
108
108
|
allow(soap_api).to receive(:subscribe_and_settle).and_return(response)
|
109
109
|
|
110
110
|
server_api = Debitech::ServerApi.new({})
|
@@ -119,7 +119,7 @@ describe Debitech::ServerApi, "charge" do
|
|
119
119
|
it "should return pending and not be successful for 403" do
|
120
120
|
soap_api = double
|
121
121
|
allow(DebitechSoap::API).to receive(:new).and_return(soap_api)
|
122
|
-
response = double(:
|
122
|
+
response = double(result_code: 403)
|
123
123
|
allow(soap_api).to receive(:subscribe_and_settle).and_return(response)
|
124
124
|
server_api = Debitech::ServerApi.new({})
|
125
125
|
result = server_api.charge(unique_reference)
|
@@ -3,7 +3,7 @@ require "debitech"
|
|
3
3
|
|
4
4
|
describe Debitech::WebApi do
|
5
5
|
let(:secret_key) {
|
6
|
-
{ :
|
6
|
+
{ secret_key: "secretkey" }
|
7
7
|
}
|
8
8
|
|
9
9
|
describe "form_fields" do
|
@@ -14,38 +14,38 @@ describe Debitech::WebApi do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "is possible to override the values via the initializer" do
|
17
|
-
fields = Debitech::WebApi.new(secret_key.merge(:
|
17
|
+
fields = Debitech::WebApi.new(secret_key.merge(fields: { method: "cc.cekab" })).form_fields
|
18
18
|
expect(fields[:method]).to eq "cc.cekab"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "is possible to override the values via method parameters" do
|
22
|
-
api = Debitech::WebApi.new(secret_key.merge(:
|
22
|
+
api = Debitech::WebApi.new(secret_key.merge(fields: { pageSet: "mydefault" }))
|
23
23
|
|
24
24
|
expect(api.form_fields.fetch(:pageSet)).to eq "mydefault"
|
25
25
|
expect(api.form_fields(pageSet: "override").fetch(:pageSet)).to eq "override"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "calculates MAC" do
|
29
|
-
expect(Debitech::WebApi.new({ :
|
30
|
-
expect(Debitech::WebApi.new({ :
|
29
|
+
expect(Debitech::WebApi.new({ secret_key: "secretkey1" }).form_fields[:MAC]).to match /DF253765337968C5ED7E6EA530CD692942416ABE/
|
30
|
+
expect(Debitech::WebApi.new({ secret_key: "secretkey2" }).form_fields[:MAC]).to match /BEB3C370E37837734642111D44CA7E304A0F45F2/
|
31
31
|
end
|
32
32
|
|
33
33
|
it "accounts for overrides in the MAC" do
|
34
|
-
mac_without_override = Debitech::WebApi.new({ :
|
35
|
-
mac_with_override = Debitech::WebApi.new({ :
|
34
|
+
mac_without_override = Debitech::WebApi.new({ secret_key: "secretkey1" }).form_fields.fetch(:MAC)
|
35
|
+
mac_with_override = Debitech::WebApi.new({ secret_key: "secretkey1" }).form_fields(method: "other-method").fetch(:MAC)
|
36
36
|
expect(mac_without_override).not_to eq(mac_with_override)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "includes verify_id in the MAC if provided" do
|
40
|
-
mac_without_verify_id = Debitech::WebApi.new({ :
|
41
|
-
mac_with_verify_id = Debitech::WebApi.new({ :
|
40
|
+
mac_without_verify_id = Debitech::WebApi.new({ secret_key: "secretkey1" }).form_fields.fetch(:MAC)
|
41
|
+
mac_with_verify_id = Debitech::WebApi.new({ secret_key: "secretkey1" }).form_fields(verifyID: "123456").fetch(:MAC)
|
42
42
|
expect(mac_without_verify_id).not_to eq(mac_with_verify_id)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "form_action" do
|
47
47
|
it "return the url based on shop" do
|
48
|
-
api = Debitech::WebApi.new({ :
|
48
|
+
api = Debitech::WebApi.new({ merchant: "myshop" })
|
49
49
|
expect(api.form_action).to include "https://securedt.dibspayment.com/verify/bin/myshop/index"
|
50
50
|
end
|
51
51
|
end
|
@@ -78,7 +78,7 @@ describe Debitech::WebApi do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "is not true if the secretkey is different" do
|
81
|
-
api = Debitech::WebApi.new({ :
|
81
|
+
api = Debitech::WebApi.new({ secret_key: "secretkey2" })
|
82
82
|
expect(api.valid_response?("MAC=667026AD7692F9AFDA362919EA72D8E6A250A849", "1,00", "A", "1234567")).to be false
|
83
83
|
end
|
84
84
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debitech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Kolsjö
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debitech_soap
|
@@ -59,8 +59,9 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/workflows/ci.yml"
|
62
63
|
- ".gitignore"
|
63
|
-
- ".
|
64
|
+
- ".rubocop.yml"
|
64
65
|
- Gemfile
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
@@ -74,7 +75,8 @@ files:
|
|
74
75
|
- spec/debitech/web_api_spec.rb
|
75
76
|
homepage: https://github.com/barsoom/debitech
|
76
77
|
licenses: []
|
77
|
-
metadata:
|
78
|
+
metadata:
|
79
|
+
rubygems_mfa_required: 'true'
|
78
80
|
post_install_message:
|
79
81
|
rdoc_options: []
|
80
82
|
require_paths:
|
@@ -90,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
92
|
- !ruby/object:Gem::Version
|
91
93
|
version: '0'
|
92
94
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
95
|
+
rubygems_version: 3.2.28
|
94
96
|
signing_key:
|
95
97
|
specification_version: 4
|
96
98
|
summary: Library for doing payments using DebiTech (DIBS)
|
data/.travis.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3.0
|
4
|
-
- 1.9.3
|
5
|
-
- jruby-19mode
|
6
|
-
- ruby-head
|
7
|
-
- jruby-head
|
8
|
-
|
9
|
-
# Workaround for Travis + Bundler issues. If this ticket has been resolved, maybe we can remove the workaround.
|
10
|
-
# https://github.com/travis-ci/travis-ci/issues/3531
|
11
|
-
before_install:
|
12
|
-
- gem install bundler
|