datatrans 5.1.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 +30 -3
- data/.github/workflows/release.yml +1 -1
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Appraisals +16 -8
- data/CHANGELOG.md +13 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +151 -0
- data/README.markdown +70 -7
- 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 +26 -11
- data/lib/datatrans/json/transaction/authorize.rb +4 -42
- 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 +7 -3
- data/lib/datatrans/json/transaction/settle.rb +41 -0
- data/lib/datatrans/json/transaction/status.rb +15 -9
- data/lib/datatrans/json/transaction.rb +30 -8
- 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 -9
- data/renovate.json +14 -0
- data/spec/common_spec.rb +6 -6
- data/spec/config_spec.rb +2 -2
- data/spec/json/authorize_spec.rb +35 -14
- 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 +2 -2
- 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 +13 -4
- data/spec/web/authorize_spec.rb +0 -157
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f34eb8d332a694f26cb82bb7f9f6d953914b4f314d6eb6cf73896b5398a228
|
4
|
+
data.tar.gz: d62d36a4d876a1b594706ef77e845fa10d80d22bfe712e01acb1d4e7d7e1b394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d5a9d7d70dec2c18bcc7b18060003f6e769497479851c8646c5b04df703a504ab5dac6f0a8b7144891ae0c65c2f3894e762429da3f9586cb06d0a08398d181
|
7
|
+
data.tar.gz: abdef0e7fc212ae0ac3015f271bf98bb9f22ce163d43bbb88e68e1b056b4deeca1f903374d50a64c9078cdfdc33da9c532a4822349f5a99a69aa8deae867ef52
|
data/.github/workflows/ci.yml
CHANGED
@@ -2,16 +2,33 @@
|
|
2
2
|
name: CI
|
3
3
|
on: [ push, pull_request ]
|
4
4
|
jobs:
|
5
|
+
standard:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v4
|
9
|
+
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.6 # keep it on the lowest supported Ruby version
|
14
|
+
bundler-cache: true
|
15
|
+
|
16
|
+
- name: Run Standard
|
17
|
+
run: bundle exec standardrb
|
18
|
+
|
5
19
|
tests:
|
6
20
|
runs-on: ubuntu-latest
|
7
21
|
strategy:
|
8
22
|
fail-fast: false
|
9
23
|
matrix:
|
10
|
-
ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ]
|
11
|
-
rails: [ '5-2', '6-0', '6-1', '7-0' ]
|
24
|
+
ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2', '3.3' ]
|
25
|
+
rails: [ '5-2', '6-0', '6-1', '7-0', '7-1' ]
|
26
|
+
# excludes are sorted by Ruby version, then Rails version
|
12
27
|
exclude:
|
13
28
|
- ruby: 2.6 # Rails 7 requires 2.7 minimum
|
14
29
|
rails: 7-0
|
30
|
+
- ruby: 2.6 # Rails 7.1 requires 2.7 minimum
|
31
|
+
rails: 7-1
|
15
32
|
- ruby: 3.0 # Ruby 3 support for 5.2 hasn't been added
|
16
33
|
rails: 5-2
|
17
34
|
- ruby: 3.1 # Ruby 3.1 only works on the latest Rails 7 version
|
@@ -26,9 +43,19 @@ jobs:
|
|
26
43
|
rails: 6-0
|
27
44
|
- ruby: 3.2
|
28
45
|
rails: 6-1
|
46
|
+
- ruby: 3.3 # Ruby 3.3 only works on the latest Rails 7 version
|
47
|
+
rails: 5-2
|
48
|
+
- ruby: 3.3
|
49
|
+
rails: 6-0
|
50
|
+
- ruby: 3.3
|
51
|
+
rails: 6-1
|
29
52
|
|
30
53
|
steps:
|
31
|
-
- uses: actions/checkout@
|
54
|
+
- uses: actions/checkout@v4
|
55
|
+
|
56
|
+
# we otherwise run into issues with different versions of actionpack / activesupport with Appraisal
|
57
|
+
- name: Remove Gemfile.lock
|
58
|
+
run: rm Gemfile.lock
|
32
59
|
|
33
60
|
- name: Set up Ruby
|
34
61
|
uses: ruby/setup-ruby@v1
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.10
|
data/Appraisals
CHANGED
@@ -1,31 +1,39 @@
|
|
1
1
|
appraise "rails-5-2" do
|
2
|
-
gem "activesupport", "~> 5.2"
|
2
|
+
gem "activesupport", "~> 5.2.0"
|
3
3
|
|
4
4
|
group :development, :test do
|
5
|
-
gem "actionpack", "~> 5.2"
|
5
|
+
gem "actionpack", "~> 5.2.0"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
appraise "rails-6-0" do
|
10
|
-
gem "activesupport", "~> 6.0"
|
10
|
+
gem "activesupport", "~> 6.0.0"
|
11
11
|
|
12
12
|
group :development, :test do
|
13
|
-
gem "actionpack", "~> 6.0"
|
13
|
+
gem "actionpack", "~> 6.0.0"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
appraise "rails-6-1" do
|
18
|
-
gem "activesupport", "~> 6.1"
|
18
|
+
gem "activesupport", "~> 6.1.0"
|
19
19
|
|
20
20
|
group :development, :test do
|
21
|
-
gem "actionpack", "~> 6.1"
|
21
|
+
gem "actionpack", "~> 6.1.0"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
appraise "rails-7-0" do
|
26
|
-
gem "activesupport", "~> 7.0"
|
26
|
+
gem "activesupport", "~> 7.0.0"
|
27
27
|
|
28
28
|
group :development, :test do
|
29
|
-
gem "actionpack", "~> 7.0"
|
29
|
+
gem "actionpack", "~> 7.0.0"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
appraise "rails-7-1" do
|
34
|
+
gem "activesupport", "~> 7.1.0"
|
35
|
+
|
36
|
+
group :development, :test do
|
37
|
+
gem "actionpack", "~> 7.1.0"
|
30
38
|
end
|
31
39
|
end
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## 5.2.0 - 2024-01-31
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
* Support for Ruby 3.3 and Rails 7.1 (@andyundso [#47](https://github.com/simplificator/datatrans/pull/47))
|
13
|
+
* Support for Merchant Initiated Payments (@visini [#48](https://github.com/simplificator/datatrans/pull/48), [#52](https://github.com/simplificator/datatrans/pull/52), [#53](https://github.com/simplificator/datatrans/pull/53), [#56](https://github.com/simplificator/datatrans/pull/56))
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
* Reformatted code with standardrb (@andyundso [#57](https://github.com/simplificator/datatrans/pull/57))
|
18
|
+
* Marked XML APIs and Web APIs as deprecated (@andyundso [#60](https://github.com/simplificator/datatrans/pull/60))
|
19
|
+
* Renamed `Datatrans::JSON::Transaction::Authorize` to `Datatrans::JSON::Transaction::Init`. `::Authorize` will still work until the next major release (@andyundso [#60](https://github.com/simplificator/datatrans/pull/60))
|
20
|
+
|
8
21
|
## 5.1.0 - 2023-07-06
|
9
22
|
|
10
23
|
### Added
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
datatrans (5.2.0)
|
5
|
+
activesupport (>= 5.2)
|
6
|
+
builder
|
7
|
+
httparty
|
8
|
+
i18n
|
9
|
+
multi_xml (>= 0.5.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: http://rubygems.org/
|
13
|
+
specs:
|
14
|
+
actionpack (6.1.5)
|
15
|
+
actionview (= 6.1.5)
|
16
|
+
activesupport (= 6.1.5)
|
17
|
+
rack (~> 2.0, >= 2.0.9)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
21
|
+
actionview (6.1.5)
|
22
|
+
activesupport (= 6.1.5)
|
23
|
+
builder (~> 3.1)
|
24
|
+
erubi (~> 1.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
+
activesupport (6.1.5)
|
28
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
|
+
i18n (>= 1.6, < 2)
|
30
|
+
minitest (>= 5.1)
|
31
|
+
tzinfo (~> 2.0)
|
32
|
+
zeitwerk (~> 2.3)
|
33
|
+
appraisal (2.4.1)
|
34
|
+
bundler
|
35
|
+
rake
|
36
|
+
thor (>= 0.14.0)
|
37
|
+
ast (2.4.2)
|
38
|
+
builder (3.2.4)
|
39
|
+
concurrent-ruby (1.1.10)
|
40
|
+
crass (1.0.6)
|
41
|
+
diff-lcs (1.5.0)
|
42
|
+
docile (1.4.0)
|
43
|
+
erubi (1.10.0)
|
44
|
+
httparty (0.21.0)
|
45
|
+
mini_mime (>= 1.0.0)
|
46
|
+
multi_xml (>= 0.5.2)
|
47
|
+
i18n (1.10.0)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
json (2.7.1)
|
50
|
+
language_server-protocol (3.17.0.3)
|
51
|
+
lint_roller (1.1.0)
|
52
|
+
loofah (2.16.0)
|
53
|
+
crass (~> 1.0.2)
|
54
|
+
nokogiri (>= 1.5.9)
|
55
|
+
mini_mime (1.1.5)
|
56
|
+
mini_portile2 (2.8.5)
|
57
|
+
minitest (5.15.0)
|
58
|
+
multi_xml (0.6.0)
|
59
|
+
nokogiri (1.13.4)
|
60
|
+
mini_portile2 (~> 2.8.0)
|
61
|
+
racc (~> 1.4)
|
62
|
+
nokogiri (1.13.4-x86_64-darwin)
|
63
|
+
racc (~> 1.4)
|
64
|
+
nokogiri (1.13.4-x86_64-linux)
|
65
|
+
racc (~> 1.4)
|
66
|
+
parallel (1.24.0)
|
67
|
+
parser (3.3.0.5)
|
68
|
+
ast (~> 2.4.1)
|
69
|
+
racc
|
70
|
+
racc (1.7.3)
|
71
|
+
rack (2.2.3)
|
72
|
+
rack-test (1.1.0)
|
73
|
+
rack (>= 1.0, < 3)
|
74
|
+
rails-dom-testing (2.0.3)
|
75
|
+
activesupport (>= 4.2.0)
|
76
|
+
nokogiri (>= 1.6)
|
77
|
+
rails-html-sanitizer (1.4.2)
|
78
|
+
loofah (~> 2.3)
|
79
|
+
rainbow (3.1.1)
|
80
|
+
rake (13.0.6)
|
81
|
+
regexp_parser (2.9.0)
|
82
|
+
rexml (3.2.6)
|
83
|
+
rspec (3.11.0)
|
84
|
+
rspec-core (~> 3.11.0)
|
85
|
+
rspec-expectations (~> 3.11.0)
|
86
|
+
rspec-mocks (~> 3.11.0)
|
87
|
+
rspec-core (3.11.0)
|
88
|
+
rspec-support (~> 3.11.0)
|
89
|
+
rspec-expectations (3.11.0)
|
90
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
91
|
+
rspec-support (~> 3.11.0)
|
92
|
+
rspec-mocks (3.11.1)
|
93
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
94
|
+
rspec-support (~> 3.11.0)
|
95
|
+
rspec-support (3.11.0)
|
96
|
+
rubocop (1.50.2)
|
97
|
+
json (~> 2.3)
|
98
|
+
parallel (~> 1.10)
|
99
|
+
parser (>= 3.2.0.0)
|
100
|
+
rainbow (>= 2.2.2, < 4.0)
|
101
|
+
regexp_parser (>= 1.8, < 3.0)
|
102
|
+
rexml (>= 3.2.5, < 4.0)
|
103
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
104
|
+
ruby-progressbar (~> 1.7)
|
105
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
106
|
+
rubocop-ast (1.30.0)
|
107
|
+
parser (>= 3.2.1.0)
|
108
|
+
rubocop-performance (1.16.0)
|
109
|
+
rubocop (>= 1.7.0, < 2.0)
|
110
|
+
rubocop-ast (>= 0.4.0)
|
111
|
+
ruby-progressbar (1.13.0)
|
112
|
+
simplecov (0.22.0)
|
113
|
+
docile (~> 1.1)
|
114
|
+
simplecov-html (~> 0.11)
|
115
|
+
simplecov_json_formatter (~> 0.1)
|
116
|
+
simplecov-html (0.12.3)
|
117
|
+
simplecov_json_formatter (0.1.4)
|
118
|
+
standard (1.28.5)
|
119
|
+
language_server-protocol (~> 3.17.0.2)
|
120
|
+
lint_roller (~> 1.0)
|
121
|
+
rubocop (~> 1.50.2)
|
122
|
+
standard-custom (~> 1.0.0)
|
123
|
+
standard-performance (~> 1.0.1)
|
124
|
+
standard-custom (1.0.2)
|
125
|
+
lint_roller (~> 1.0)
|
126
|
+
rubocop (~> 1.50)
|
127
|
+
standard-performance (1.0.1)
|
128
|
+
lint_roller (~> 1.0)
|
129
|
+
rubocop-performance (~> 1.16.0)
|
130
|
+
thor (1.2.1)
|
131
|
+
tzinfo (2.0.4)
|
132
|
+
concurrent-ruby (~> 1.0)
|
133
|
+
unicode-display_width (2.5.0)
|
134
|
+
zeitwerk (2.5.4)
|
135
|
+
|
136
|
+
PLATFORMS
|
137
|
+
ruby
|
138
|
+
x86_64-darwin-21
|
139
|
+
x86_64-linux
|
140
|
+
|
141
|
+
DEPENDENCIES
|
142
|
+
actionpack (>= 5.2)
|
143
|
+
appraisal
|
144
|
+
datatrans!
|
145
|
+
rake
|
146
|
+
rspec
|
147
|
+
simplecov
|
148
|
+
standard
|
149
|
+
|
150
|
+
BUNDLED WITH
|
151
|
+
2.3.3
|
data/README.markdown
CHANGED
@@ -31,6 +31,10 @@ Possible values for the environment: `:production`, `:development`
|
|
31
31
|
Web Authorization
|
32
32
|
=================
|
33
33
|
|
34
|
+
> [!IMPORTANT]
|
35
|
+
>
|
36
|
+
> Datatrans no longer supports the Payment Page API. The support in this gem will be removed in the next major release. Please use the [JSON API](#json-transactions) instead.
|
37
|
+
|
34
38
|
If you want to process a credit card the first time a web authorization is
|
35
39
|
necessary. Add the following code to a controller action that shows the form.
|
36
40
|
You need to pass at least `amount`, `currency` and `refno` (order number).
|
@@ -98,12 +102,24 @@ JSON Transactions
|
|
98
102
|
|
99
103
|
More information about Datatrans JSON API can be found [here](https://api-reference.datatrans.ch/). Our gem uses endpoints from `/v1/transactions` section.
|
100
104
|
|
101
|
-
We implemented support for [Redirect mode](https://docs.datatrans.ch/docs/redirect-lightbox) (since Lightbox mode may not work correctly on mobile, whereas Redirect works well on all
|
105
|
+
We implemented support for [Redirect mode](https://docs.datatrans.ch/docs/redirect-lightbox) (since Lightbox mode may not work correctly on mobile, whereas Redirect works well on all devices).
|
102
106
|
|
103
|
-
|
107
|
+
Saving Payment Information
|
108
|
+
--------------------------
|
109
|
+
|
110
|
+
According to the [docs](https://docs.datatrans.ch/docs/customer-initiated-payments#saving-payment-information), there are three possible flows:
|
111
|
+
|
112
|
+
- **Customer Initiated Payments**: _Your customer pays and nothing is registered._
|
113
|
+
- This is the most basic setup and does _not_ save any payment information: First, call `transaction.init`, and then redirect the user to the `transaction_path` (see the sections `Initialize` and `Start a transaction` below).
|
114
|
+
- **Customer Initiated Payment** and creating an `alias` for subsequent **Merchant Initiated Payments**: _Your customer pays and the card or payment method information is registered. You receive an alias which you save for later merchant initiated payments or one-click checkouts._
|
115
|
+
- In order to save payment information after your customer has finalized their payment, without them having to re-enter their payment information and go through the 3D-Secure flow, pass `option: {"createAlias": true}`. More information can be found [here](https://docs.datatrans.ch/docs/redirect-lightbox#saving-payment-information).
|
116
|
+
- **Merchant Initiated Payments**: _Your customer registers their card or payment method information without any payment. Their account is not charged. This is what we call a dedicated registration._
|
117
|
+
- This setup allows you to save a customers payment information without any charge in the beginning. This is useful in the context of setting up a subscription model (e.g., usage-based billing at the end of a billing period). See the section `Merchant Initiated Payments` below.
|
118
|
+
|
119
|
+
Initialize
|
104
120
|
---------
|
105
121
|
|
106
|
-
|
122
|
+
Initialize a JSON transaction:
|
107
123
|
|
108
124
|
```ruby
|
109
125
|
transaction = datatrans.json_transaction(
|
@@ -116,9 +132,9 @@ transaction = datatrans.json_transaction(
|
|
116
132
|
error_url: <your_application_return_url>
|
117
133
|
)
|
118
134
|
|
119
|
-
# call to
|
135
|
+
# call to initialize endpoint to initialize a transaction
|
120
136
|
# returns true or false depending if response was successful or not
|
121
|
-
init = transaction.
|
137
|
+
init = transaction.init
|
122
138
|
|
123
139
|
# successful authorization call returns in response a transaction id
|
124
140
|
if init
|
@@ -139,7 +155,7 @@ Once you have a transaction id, you can start a transaction. Users of your appli
|
|
139
155
|
render js: "window.location='#{path}'"
|
140
156
|
```
|
141
157
|
|
142
|
-
You do not have to [settle a transaction](https://api-reference.datatrans.ch/#tag/v1transactions/operation/settle) by yourself: we set `"autoSettle": true` by default when authorizing a transaction, which means the transaction will be settled automatically.
|
158
|
+
You do not have to [settle a transaction](https://api-reference.datatrans.ch/#tag/v1transactions/operation/settle) by yourself: we set `"autoSettle": true` by default when authorizing a transaction, which means the transaction will be settled automatically. This can be overridden by setting `auto_settle: false` when authorizing a transaction.
|
143
159
|
|
144
160
|
Transaction status
|
145
161
|
------------------
|
@@ -196,11 +212,58 @@ You can check the trasaction [status](https://api-reference.datatrans.ch/#tag/v1
|
|
196
212
|
end
|
197
213
|
```
|
198
214
|
|
215
|
+
Merchant Initiated Payments
|
216
|
+
---------
|
217
|
+
|
218
|
+
It's possible to authorize transactions without user interaction, via [merchant initiated payments](https://docs.datatrans.ch/docs/merchant-initiated-payments).
|
219
|
+
|
220
|
+
To perform a so-called "dedicated registration" (so we can later charge the card via its `alias`), you should follow the same steps as described above, but not provide an amount:
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
transaction = datatrans.json_transaction(
|
224
|
+
refno: 'ABCDEF',
|
225
|
+
amount: 0, # omit amount for dedicated registrations
|
226
|
+
currency: "CHF",
|
227
|
+
payment_methods: ["ECA", "VIS"],
|
228
|
+
success_url: <your_application_return_url>,
|
229
|
+
cancel_url: <your_application_return_url>,
|
230
|
+
error_url: <your_application_return_url>
|
231
|
+
)
|
232
|
+
|
233
|
+
init = transaction.init
|
234
|
+
|
235
|
+
# successful authorization call returns in response a transaction id
|
236
|
+
if init
|
237
|
+
transaction_id = transaction.response.params["transactionId"]
|
238
|
+
end
|
239
|
+
```
|
240
|
+
|
241
|
+
Then, at a later point in time, and without needing any user interaction, you can create a payment via `merchant_authorize`:
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
dedicated_registration = datatrans.json_transaction(transaction_id: transaction_id)
|
245
|
+
dedicated_registration.status # this will contain the card information
|
246
|
+
|
247
|
+
card_alias = dedicated_registration.response.params["card"]["alias"]
|
248
|
+
card_expiry_month = dedicated_registration.response.params["card"]["expiryMonth"]
|
249
|
+
card_expiry_year = dedicated_registration.response.params["card"]["expiryYear"]
|
250
|
+
|
251
|
+
transaction = datatrans.json_transaction(
|
252
|
+
refno: "ABCDEF",
|
253
|
+
amount: 1000,
|
254
|
+
currency: "CHF",
|
255
|
+
card: {alias: card_alias, expiryMonth: card_expiry_month, expiryYear: card_expiry_year}
|
256
|
+
)
|
257
|
+
|
258
|
+
transaction.merchant_authorize # this will charge the card without user interaction
|
259
|
+
```
|
199
260
|
|
200
261
|
XML Transactions
|
201
262
|
================
|
202
263
|
|
203
|
-
|
264
|
+
> [!IMPORTANT]
|
265
|
+
>
|
266
|
+
> Datatrans will stop supporting the XML API on June 3rd, 2024. The support in this gem will be removed in the next major release. Please use the [JSON API](#json-transactions) instead.
|
204
267
|
|
205
268
|
If you have already a credit card alias or an authorized transaction you can
|
206
269
|
use the convenient XML methods to process payments.
|
data/Rakefile
CHANGED
data/datatrans.gemspec
CHANGED
@@ -1,34 +1,32 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
3
2
|
require "datatrans/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.authors
|
9
|
-
s.email
|
10
|
-
s.homepage
|
11
|
-
s.summary
|
12
|
-
s.description =
|
5
|
+
s.name = "datatrans"
|
6
|
+
s.version = Datatrans::VERSION
|
7
|
+
s.authors = ["Tobias Miesel", "Thomas Maurer", "Corin Langosch", "Pascal Betz"]
|
8
|
+
s.email = ["info@simplificator.com"]
|
9
|
+
s.homepage = ""
|
10
|
+
s.summary = "Datatrans Integration for Ruby on Rails"
|
11
|
+
s.description = "Datatrans Integration for Ruby on Rails"
|
13
12
|
|
14
13
|
s.rubyforge_project = "datatrans"
|
15
14
|
|
16
|
-
s.files
|
17
|
-
s.
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
|
21
|
-
s.required_ruby_version =
|
19
|
+
s.required_ruby_version = ">= 2.6"
|
22
20
|
|
23
|
-
s.add_dependency
|
24
|
-
s.add_dependency
|
25
|
-
s.add_dependency
|
26
|
-
s.add_dependency
|
27
|
-
s.add_dependency
|
21
|
+
s.add_dependency "httparty"
|
22
|
+
s.add_dependency "activesupport", ">= 5.2"
|
23
|
+
s.add_dependency "i18n"
|
24
|
+
s.add_dependency "builder"
|
25
|
+
s.add_dependency "multi_xml", ">= 0.5.1"
|
28
26
|
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.license =
|
27
|
+
s.add_development_dependency "actionpack", ">= 5.2"
|
28
|
+
s.add_development_dependency "appraisal"
|
29
|
+
s.add_development_dependency "rake"
|
30
|
+
s.add_development_dependency "rspec"
|
31
|
+
s.license = "MIT"
|
34
32
|
end
|
data/gemfiles/rails_5_2.gemfile
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
source "http://rubygems.org"
|
4
4
|
|
5
5
|
gem "simplecov", group: :test, require: nil
|
6
|
-
gem "activesupport", "~> 5.2"
|
6
|
+
gem "activesupport", "~> 5.2.0"
|
7
7
|
|
8
8
|
group :development, :test do
|
9
|
-
gem "actionpack", "~> 5.2"
|
9
|
+
gem "actionpack", "~> 5.2.0"
|
10
10
|
end
|
11
11
|
|
12
12
|
gemspec path: "../"
|
data/gemfiles/rails_6_0.gemfile
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
source "http://rubygems.org"
|
4
4
|
|
5
5
|
gem "simplecov", group: :test, require: nil
|
6
|
-
gem "activesupport", "~> 6.0"
|
6
|
+
gem "activesupport", "~> 6.0.0"
|
7
7
|
|
8
8
|
group :development, :test do
|
9
|
-
gem "actionpack", "~> 6.0"
|
9
|
+
gem "actionpack", "~> 6.0.0"
|
10
10
|
end
|
11
11
|
|
12
12
|
gemspec path: "../"
|
data/gemfiles/rails_6_1.gemfile
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
source "http://rubygems.org"
|
4
4
|
|
5
5
|
gem "simplecov", group: :test, require: nil
|
6
|
-
gem "activesupport", "~> 6.1"
|
6
|
+
gem "activesupport", "~> 6.1.0"
|
7
7
|
|
8
8
|
group :development, :test do
|
9
|
-
gem "actionpack", "~> 6.1"
|
9
|
+
gem "actionpack", "~> 6.1.0"
|
10
10
|
end
|
11
11
|
|
12
12
|
gemspec path: "../"
|
data/gemfiles/rails_7_0.gemfile
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
source "http://rubygems.org"
|
4
4
|
|
5
5
|
gem "simplecov", group: :test, require: nil
|
6
|
-
gem "activesupport", "~> 7.0"
|
6
|
+
gem "activesupport", "~> 7.0.0"
|
7
7
|
|
8
8
|
group :development, :test do
|
9
|
-
gem "actionpack", "~> 7.0"
|
9
|
+
gem "actionpack", "~> 7.0.0"
|
10
10
|
end
|
11
11
|
|
12
12
|
gemspec path: "../"
|
data/lib/datatrans/common.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "openssl"
|
2
2
|
|
3
3
|
module Datatrans::Common
|
4
4
|
def sign(*fields)
|
5
|
-
return nil unless
|
6
|
-
key =
|
5
|
+
return nil unless datatrans.sign_key
|
6
|
+
key = datatrans.sign_key.split(/([a-f0-9][a-f0-9])/).reject(&:empty?)
|
7
7
|
key = key.pack("H*" * key.size)
|
8
|
-
OpenSSL::HMAC.hexdigest(OpenSSL::Digest
|
8
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("MD5"), key, fields.join)
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|