datatrans 5.0.0 → 5.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/.github/workflows/ci.yml +37 -4
- data/.github/workflows/release.yml +1 -1
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Appraisals +16 -8
- data/CHANGELOG.md +22 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +151 -0
- data/README.markdown +183 -3
- data/Rakefile +2 -2
- data/datatrans.gemspec +20 -22
- data/gemfiles/rails_5_2.gemfile +2 -2
- data/gemfiles/rails_6_0.gemfile +2 -2
- data/gemfiles/rails_6_1.gemfile +2 -2
- data/gemfiles/rails_7_0.gemfile +2 -2
- data/gemfiles/rails_7_1.gemfile +12 -0
- data/lib/datatrans/common.rb +5 -5
- data/lib/datatrans/config.rb +41 -12
- data/lib/datatrans/json/transaction/authorize.rb +10 -0
- data/lib/datatrans/json/transaction/init.rb +61 -0
- data/lib/datatrans/json/transaction/merchant_authorize.rb +45 -0
- data/lib/datatrans/json/transaction/response.rb +26 -0
- data/lib/datatrans/json/transaction/settle.rb +41 -0
- data/lib/datatrans/json/transaction/status.rb +50 -0
- data/lib/datatrans/json/transaction.rb +54 -0
- data/lib/datatrans/version.rb +1 -1
- data/lib/datatrans/web/transaction/authorize.rb +46 -17
- data/lib/datatrans/web/transaction.rb +10 -4
- data/lib/datatrans/web/view_helper.rb +3 -1
- data/lib/datatrans/xml/transaction/authorize.rb +39 -19
- data/lib/datatrans/xml/transaction/capture.rb +29 -15
- data/lib/datatrans/xml/transaction/request.rb +10 -9
- data/lib/datatrans/xml/transaction/response.rb +4 -2
- data/lib/datatrans/xml/transaction/status.rb +41 -25
- data/lib/datatrans/xml/transaction/void.rb +30 -16
- data/lib/datatrans/xml/transaction.rb +18 -14
- data/lib/datatrans.rb +9 -8
- data/renovate.json +14 -0
- data/spec/common_spec.rb +6 -6
- data/spec/config_spec.rb +8 -2
- data/spec/json/authorize_spec.rb +100 -0
- data/spec/json/init_spec.rb +100 -0
- data/spec/json/merchant_authorize_spec.rb +97 -0
- data/spec/json/settle_spec.rb +55 -0
- data/spec/json/status_spec.rb +75 -0
- data/spec/json/transaction_spec.rb +10 -0
- data/spec/spec_helper.rb +11 -11
- data/spec/web/init_spec.rb +157 -0
- data/spec/xml/capture_spec.rb +5 -5
- data/spec/xml/{authorize_spec.rb → init_spec.rb} +7 -7
- data/spec/xml/request_spec.rb +21 -22
- data/spec/xml/status_spec.rb +4 -4
- data/spec/xml/void_spec.rb +5 -5
- metadata +20 -4
- data/spec/web/authorize_spec.rb +0 -157
data/spec/xml/request_spec.rb
CHANGED
@@ -1,42 +1,41 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Datatrans::XML::Transaction::Request do
|
4
4
|
describe "Proxy" do
|
5
5
|
describe "configured" do
|
6
6
|
before(:each) do
|
7
7
|
@datatrans = Datatrans::Config.new(
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
8
|
+
merchant_id: "1100000000",
|
9
|
+
sign_key: "d777c17ba2010282c2d2350a68b441ca07a799d294bfaa630b7c8442207c0b69703cc55775b0ca5a4e455b818a9bb10a43669c0c20ce31f4a43f10e0cabb9525",
|
10
|
+
password: "basic_auth_password",
|
11
|
+
key: "value",
|
12
|
+
proxy: {
|
13
|
+
http_proxyaddr: "proxy.com",
|
14
|
+
http_proxyport: 80,
|
15
|
+
http_proxyuser: "hans",
|
16
|
+
http_proxpass: "xxx"
|
17
17
|
},
|
18
|
-
:
|
18
|
+
environment: :development
|
19
19
|
)
|
20
|
-
|
21
20
|
end
|
22
21
|
it "forward those options to HTTParty" do
|
23
22
|
request = Datatrans::XML::Transaction::Request.new(@datatrans, {})
|
24
|
-
expect(HTTParty).to receive(:post).with(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
request.post(
|
23
|
+
expect(HTTParty).to receive(:post).with("lirum",
|
24
|
+
basic_auth: {password: "basic_auth_password", username: "1100000000"},
|
25
|
+
params: {foo: :bar},
|
26
|
+
http_proxpass: "xxx",
|
27
|
+
http_proxyuser: "hans",
|
28
|
+
http_proxyaddr: "proxy.com",
|
29
|
+
http_proxyport: 80)
|
30
|
+
request.post("lirum", params: {foo: :bar})
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
34
|
describe "not configured" do
|
36
35
|
it "should not add any proxy settings" do
|
37
36
|
request = Datatrans::XML::Transaction::Request.new(@datatrans, {})
|
38
|
-
expect(HTTParty).to receive(:post).with(
|
39
|
-
request.post(
|
37
|
+
expect(HTTParty).to receive(:post).with("lirum", basic_auth: {password: "basic_auth_password", username: "1100000000"}, params: {foo: :bar})
|
38
|
+
request.post("lirum", params: {foo: :bar})
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/spec/xml/status_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Datatrans::XML::Transaction::StatusRequest do
|
4
4
|
before do
|
@@ -17,7 +17,7 @@ describe Datatrans::XML::Transaction::StatusRequest do
|
|
17
17
|
"amount" => "500",
|
18
18
|
"currency" => "CHF",
|
19
19
|
"authorizationCode" => "891104057",
|
20
|
-
"pmethod" => "ECA"
|
20
|
+
"pmethod" => "ECA"
|
21
21
|
},
|
22
22
|
"trxStatus" => "response"
|
23
23
|
},
|
@@ -43,7 +43,7 @@ describe Datatrans::XML::Transaction::StatusRequest do
|
|
43
43
|
"amount" => "",
|
44
44
|
"currency" => "",
|
45
45
|
"authorizationCode" => "",
|
46
|
-
"pmethod" => ""
|
46
|
+
"pmethod" => ""
|
47
47
|
},
|
48
48
|
"trxStatus" => "response"
|
49
49
|
},
|
@@ -55,7 +55,7 @@ describe Datatrans::XML::Transaction::StatusRequest do
|
|
55
55
|
}
|
56
56
|
|
57
57
|
@valid_params = {
|
58
|
-
:
|
58
|
+
transaction_id: "111013090000394044"
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
data/spec/xml/void_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Datatrans::XML::Transaction::VoidRequest do
|
4
4
|
before do
|
@@ -54,10 +54,10 @@ describe Datatrans::XML::Transaction::VoidRequest do
|
|
54
54
|
}
|
55
55
|
|
56
56
|
@valid_params = {
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
57
|
+
refno: "ABCDEF",
|
58
|
+
amount: 1000,
|
59
|
+
currency: "CHF",
|
60
|
+
transaction_id: "110808143302868124"
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datatrans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Miesel
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- Appraisals
|
155
155
|
- CHANGELOG.md
|
156
156
|
- Gemfile
|
157
|
+
- Gemfile.lock
|
157
158
|
- LICENSE
|
158
159
|
- README.markdown
|
159
160
|
- Rakefile
|
@@ -162,9 +163,17 @@ files:
|
|
162
163
|
- gemfiles/rails_6_0.gemfile
|
163
164
|
- gemfiles/rails_6_1.gemfile
|
164
165
|
- gemfiles/rails_7_0.gemfile
|
166
|
+
- gemfiles/rails_7_1.gemfile
|
165
167
|
- lib/datatrans.rb
|
166
168
|
- lib/datatrans/common.rb
|
167
169
|
- lib/datatrans/config.rb
|
170
|
+
- lib/datatrans/json/transaction.rb
|
171
|
+
- lib/datatrans/json/transaction/authorize.rb
|
172
|
+
- lib/datatrans/json/transaction/init.rb
|
173
|
+
- lib/datatrans/json/transaction/merchant_authorize.rb
|
174
|
+
- lib/datatrans/json/transaction/response.rb
|
175
|
+
- lib/datatrans/json/transaction/settle.rb
|
176
|
+
- lib/datatrans/json/transaction/status.rb
|
168
177
|
- lib/datatrans/version.rb
|
169
178
|
- lib/datatrans/web/transaction.rb
|
170
179
|
- lib/datatrans/web/transaction/authorize.rb
|
@@ -176,12 +185,19 @@ files:
|
|
176
185
|
- lib/datatrans/xml/transaction/response.rb
|
177
186
|
- lib/datatrans/xml/transaction/status.rb
|
178
187
|
- lib/datatrans/xml/transaction/void.rb
|
188
|
+
- renovate.json
|
179
189
|
- spec/common_spec.rb
|
180
190
|
- spec/config_spec.rb
|
191
|
+
- spec/json/authorize_spec.rb
|
192
|
+
- spec/json/init_spec.rb
|
193
|
+
- spec/json/merchant_authorize_spec.rb
|
194
|
+
- spec/json/settle_spec.rb
|
195
|
+
- spec/json/status_spec.rb
|
196
|
+
- spec/json/transaction_spec.rb
|
181
197
|
- spec/spec_helper.rb
|
182
|
-
- spec/web/
|
183
|
-
- spec/xml/authorize_spec.rb
|
198
|
+
- spec/web/init_spec.rb
|
184
199
|
- spec/xml/capture_spec.rb
|
200
|
+
- spec/xml/init_spec.rb
|
185
201
|
- spec/xml/request_spec.rb
|
186
202
|
- spec/xml/status_spec.rb
|
187
203
|
- spec/xml/void_spec.rb
|
data/spec/web/authorize_spec.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'action_controller'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Datatrans::Web::Transaction do
|
5
|
-
before do
|
6
|
-
@successful_response = {
|
7
|
-
:status => "success",
|
8
|
-
:returnCustomerCountry => "CHE",
|
9
|
-
:sign => "95f3111123e628eab6469c636e0d3f06",
|
10
|
-
:aliasCC => "70323122544311173",
|
11
|
-
:maskedCC => "520000xxxxxx0007",
|
12
|
-
:responseMessage => "Authorized",
|
13
|
-
:useAlias => "yes",
|
14
|
-
:expm => "12",
|
15
|
-
:responseCode => "01",
|
16
|
-
:sign2 => "a9571428be4d9d37b88988656984bfbf",
|
17
|
-
:testOnly => "yes",
|
18
|
-
:currency => "CHF",
|
19
|
-
:amount => "1000",
|
20
|
-
:hiddenMode => "yes",
|
21
|
-
:expy => "15",
|
22
|
-
:merchantId => "1100000000",
|
23
|
-
:authorizationCode => "521029462",
|
24
|
-
:uppTransactionId => "110808173520119430",
|
25
|
-
:refno => "1",
|
26
|
-
:uppMsgType => "web",
|
27
|
-
:uppCustomerName => "",
|
28
|
-
:pmethod => "ECA",
|
29
|
-
:reqtype => "NOA",
|
30
|
-
:uppCustomerEmail => "customer@email.com",
|
31
|
-
:acqAuthorizationCode => "173520"
|
32
|
-
}
|
33
|
-
|
34
|
-
@successful_swisspost_response = @successful_response.merge({
|
35
|
-
:pmethod => "PFC",
|
36
|
-
:txtEp2TrxID => "7777777000000001",
|
37
|
-
:responseMessage => "YellowPay transaction Ok"
|
38
|
-
})
|
39
|
-
|
40
|
-
@failed_response = {
|
41
|
-
:status => "error",
|
42
|
-
:returnCustomerCountry => "CHE",
|
43
|
-
:sign => "95f3123246e628eab6469c636e0d3f06",
|
44
|
-
:aliasCC => "70323122544311173",
|
45
|
-
:maskedCC => "520000xxxxxx0007",
|
46
|
-
:errorMessage => "declined",
|
47
|
-
:useAlias => "yes",
|
48
|
-
:expm => "12",
|
49
|
-
:errorCode => "1403",
|
50
|
-
:testOnly => "yes",
|
51
|
-
:currency => "CHF",
|
52
|
-
:amount => "1000",
|
53
|
-
:hiddenMode => "yes",
|
54
|
-
:expy => "14",
|
55
|
-
:merchantId => "1100000000",
|
56
|
-
:errorDetail => "Declined",
|
57
|
-
:uppTransactionId => "110808173951050102",
|
58
|
-
:refno => "1",
|
59
|
-
:uppMsgType => "web",
|
60
|
-
:uppCustomerName => "",
|
61
|
-
:pmethod => "ECA",
|
62
|
-
:reqtype => "NOA",
|
63
|
-
:uppCustomerEmail => "customer@email.com"
|
64
|
-
}
|
65
|
-
|
66
|
-
@valid_params = {
|
67
|
-
:refno => 'ABCDEF',
|
68
|
-
:amount => 1000,
|
69
|
-
:currency => 'CHF',
|
70
|
-
:uppCustomerEmail => 'customer@email.com'
|
71
|
-
# also params from view helper needed
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
context "rails form helper" do
|
76
|
-
before do
|
77
|
-
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
|
78
|
-
|
79
|
-
if Gem.loaded_specs['activesupport'].version >= Gem::Version.create('6.0')
|
80
|
-
@view = ActionView::Base.new(ActionController::Base.view_paths, {}, {})
|
81
|
-
else
|
82
|
-
@view = ActionView::Base.new
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should generate valid form field string' do
|
87
|
-
if Gem.loaded_specs['activesupport'].version >= Gem::Version.create('6.0')
|
88
|
-
expected_output = '<input type="hidden" name="merchantId" id="merchantId" value="1100000000" autocomplete="off" /><input type="hidden" name="hiddenMode" id="hiddenMode" value="yes" autocomplete="off" /><input type="hidden" name="reqtype" id="reqtype" value="NOA" autocomplete="off" /><input type="hidden" name="amount" id="amount" value="1000" autocomplete="off" /><input type="hidden" name="currency" id="currency" value="CHF" autocomplete="off" /><input type="hidden" name="useAlias" id="useAlias" value="yes" autocomplete="off" /><input type="hidden" name="sign" id="sign" value="0402fb3fba8c6fcb40df9b7756e7e637" autocomplete="off" /><input type="hidden" name="refno" id="refno" value="ABCDEF" autocomplete="off" /><input type="hidden" name="uppCustomerDetails" id="uppCustomerDetails" autocomplete="off" /><input type="hidden" name="uppCustomerEmail" id="uppCustomerEmail" value="customer@email.com" autocomplete="off" />'
|
89
|
-
else
|
90
|
-
expected_output = '<input type="hidden" name="merchantId" id="merchantId" value="1100000000" /><input type="hidden" name="hiddenMode" id="hiddenMode" value="yes" /><input type="hidden" name="reqtype" id="reqtype" value="NOA" /><input type="hidden" name="amount" id="amount" value="1000" /><input type="hidden" name="currency" id="currency" value="CHF" /><input type="hidden" name="useAlias" id="useAlias" value="yes" /><input type="hidden" name="sign" id="sign" value="0402fb3fba8c6fcb40df9b7756e7e637" /><input type="hidden" name="refno" id="refno" value="ABCDEF" /><input type="hidden" name="uppCustomerDetails" id="uppCustomerDetails" /><input type="hidden" name="uppCustomerEmail" id="uppCustomerEmail" value="customer@email.com" />'
|
91
|
-
end
|
92
|
-
|
93
|
-
expect(@view.datatrans_notification_request_hidden_fields(@datatrans, @transaction)).to eq expected_output
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "successful response" do
|
98
|
-
before do
|
99
|
-
allow_any_instance_of(Datatrans::Web::Transaction::AuthorizeResponse).to receive(:params).and_return(@successful_response)
|
100
|
-
end
|
101
|
-
|
102
|
-
context "process" do
|
103
|
-
it "handles a valid datatrans authorize response" do
|
104
|
-
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
|
105
|
-
expect(@transaction.authorize).to be true
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "successful response (swiss post)" do
|
111
|
-
before do
|
112
|
-
allow_any_instance_of(Datatrans::Web::Transaction::AuthorizeResponse).to receive(:params).and_return(@successful_swisspost_response)
|
113
|
-
end
|
114
|
-
|
115
|
-
context "process" do
|
116
|
-
it "handles a valid datatrans authorize response" do
|
117
|
-
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
|
118
|
-
expect(@transaction.authorize).to be true
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "compromised response" do
|
124
|
-
before do
|
125
|
-
fake_response = @successful_response
|
126
|
-
fake_response[:sign2] = 'invalid'
|
127
|
-
allow_any_instance_of(Datatrans::Web::Transaction::AuthorizeResponse).to receive(:params).and_return(fake_response)
|
128
|
-
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
|
129
|
-
end
|
130
|
-
|
131
|
-
it "raises an exception if sign2 is invalid" do
|
132
|
-
expect {
|
133
|
-
@transaction.authorize
|
134
|
-
}.to raise_error(Datatrans::InvalidSignatureError)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "failed response" do
|
139
|
-
before do
|
140
|
-
allow_any_instance_of(Datatrans::Web::Transaction::AuthorizeResponse).to receive(:params).and_return(@failed_response)
|
141
|
-
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
|
142
|
-
end
|
143
|
-
|
144
|
-
context "process" do
|
145
|
-
it "handles a failed datatrans authorize response" do
|
146
|
-
expect(@transaction.authorize).to be false
|
147
|
-
end
|
148
|
-
|
149
|
-
it "returns error details" do
|
150
|
-
@transaction.authorize
|
151
|
-
expect(@transaction.error_code.length).to be > 0
|
152
|
-
expect(@transaction.error_message.length).to be > 0
|
153
|
-
expect(@transaction.error_detail.length).to be > 0
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|