comgate_ruby 0.7.1 → 0.8.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/CHANGELOG.md +11 -3
- data/Gemfile.lock +1 -1
- data/README.md +21 -2
- data/lib/comgate/api_caller.rb +16 -2
- data/lib/comgate/gateway.rb +8 -4
- data/lib/comgate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7882560b8946462a01c78940b5c3f9c1e771418b90123e5de3b4f4e3c8dea2e
|
4
|
+
data.tar.gz: 47271d5e947abd8f189c42f79e248fd0992d56e3a92eb24b624e3f8559ec09fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e412a79248be368f95a76c7a8e3214e7156edb8a2336af3150ac1b652e7d95c2e8614ad1c1e4d1f2a3b7d201a7aa915101a6f05fa6fb7f58497f32dd17fd36
|
7
|
+
data.tar.gz: 8ce0f483ea79eebd5c25cfac010cc0761b5de48cfd1bb5b36155aabf2621bfc9a834e42428f75dcf4bff89554adec82a6289f34a4af8966ce8e86e2afa841239
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
## [0.
|
2
|
-
|
3
|
-
- Initial release
|
1
|
+
## [0.8.1] - 2023-06-13
|
2
|
+
- Allowed `proxy_uri` param for Comgate::Gateway
|
4
3
|
|
4
|
+
## [0.8] - 2023-06-06
|
5
|
+
- Update to conform universal payment interface params (see Readme)
|
6
|
+
- BREAKING: change in repeating params `{transaction_id: "xxx", ....}` is now at `{payment: {reccurrence: { init_transaction_id: "xxx" } } }`
|
5
7
|
|
6
8
|
## [0.7.1] - 2023-04-27
|
7
9
|
|
8
10
|
- better handling errors not in "error" param from Comgate
|
9
11
|
- renamed `check_state` to `check_transaction` (and keep backward compatibility)
|
10
12
|
- renamed `process_payment_callback` to `process_callback` (and keep backward compatibility)
|
13
|
+
|
14
|
+
## [0.5.0] - 2023-04-20
|
15
|
+
|
16
|
+
- Initial release
|
17
|
+
|
18
|
+
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,11 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
21
21
|
gateway = Comgate::Gateway.new(merchant_gateway_id: ":comgate_id",
|
22
22
|
test_calls: false,
|
23
23
|
client_secret: ":comgate_secret")
|
24
|
+
# or with proxy
|
25
|
+
gateway = Comgate::Gateway.new(merchant_gateway_id: ":comgate_id",
|
26
|
+
test_calls: false,
|
27
|
+
client_secret: ":comgate_secret",
|
28
|
+
proxy_uri: "http://pxuser:pxpassword@proxy.me:123") # or just "http://proxy.me:123"
|
24
29
|
```
|
25
30
|
|
26
31
|
### 2) prepare endpoint
|
@@ -59,7 +64,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
59
64
|
|
60
65
|
### Recurring payments
|
61
66
|
1) Use `gateway.start_recurring_transaction(payment_data)` and store `transaction_id`.
|
62
|
-
2) Create following payments `gateway.repeat_recurring_transaction(payment_data: new_payment_data
|
67
|
+
2) Create following payments `gateway.repeat_recurring_transaction(payment_data: new_payment_data)`, where `new_payment_data` includes `{payment: {reccurrence: { init_transaction_id: transaction_id } } }`. No redirection here. Price can change in each payment.
|
63
68
|
3) Handle status change like bullets 4) and 5) in single payment
|
64
69
|
|
65
70
|
### Preauthorized payments
|
@@ -141,20 +146,34 @@ Maximal mixed version looks like:
|
|
141
146
|
apple_pay_payload: "raw apple pay payload", # input
|
142
147
|
dynamic_expiration: false, # input (see https://help.comgate.cz/v1/docs/expirace-plateb )
|
143
148
|
expiration_time: "10h", # input ( use "m" or "h" or "d", but only one of them; allowed rage "30m".."7d")
|
149
|
+
description: "Some description",
|
150
|
+
reccurrence: { init_transaction_id: "12AD-dfsA-4568",
|
151
|
+
period: 1 } },
|
144
152
|
},
|
145
153
|
payer: {
|
146
154
|
email: "payer1@gmail.com", # input/output
|
147
155
|
phone: "+420778899", # input/output
|
156
|
+
first_name: "John", # input - not used at Comgate
|
157
|
+
last_name: "Doe", # input - not used at Comgate
|
148
158
|
account_number: "account_num", # output
|
149
159
|
account_name: "payer account name" # output
|
150
160
|
},
|
151
161
|
options: {
|
152
162
|
country_code: "DE", # input (can restrict allowed payment methods)
|
153
|
-
language_code: "sk" # input
|
163
|
+
language_code: "sk", # input
|
164
|
+
shop_return_url: "https://example.com/return",
|
165
|
+
callback_url: "https://example.com/callback"
|
154
166
|
},
|
167
|
+
# items are not used at Comgate
|
168
|
+
items: [{ type: "ITEM",
|
169
|
+
name: "Je to kulatý – Měsíční (6. 6. 2023 – 6. 7. 2023)",
|
170
|
+
amount_in_cents: 9900,
|
171
|
+
count: 1,
|
172
|
+
vat_rate_percent: 21 }],
|
155
173
|
headers: {} # not actually used now
|
156
174
|
}
|
157
175
|
```
|
176
|
+
|
158
177
|
## Response
|
159
178
|
Response returned from `gateway` call is `Comgate::Response` instance.
|
160
179
|
You can check redirection `response.redirect? ? response.redirect_to : nil`.
|
data/lib/comgate/api_caller.rb
CHANGED
@@ -20,11 +20,12 @@ module Comgate
|
|
20
20
|
|
21
21
|
attr_reader :payload, :url
|
22
22
|
|
23
|
-
def initialize(url:, payload:, test_call: false)
|
23
|
+
def initialize(url:, payload:, test_call: false, proxy_uri: nil)
|
24
24
|
super()
|
25
25
|
@url = url
|
26
26
|
@payload = payload
|
27
27
|
@payload.merge!(test: "true") if test_call
|
28
|
+
@proxy_uri = proxy_uri
|
28
29
|
end
|
29
30
|
|
30
31
|
def build_result
|
@@ -57,7 +58,20 @@ module Comgate
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def https_conn
|
60
|
-
@https_conn ||=
|
61
|
+
@https_conn ||= if @proxy_uri
|
62
|
+
proxy = URI.parse(@proxy_uri)
|
63
|
+
Net::HTTP.start(service_uri.host,
|
64
|
+
service_uri.port,
|
65
|
+
proxy.host,
|
66
|
+
proxy.port,
|
67
|
+
proxy.user,
|
68
|
+
proxy.password,
|
69
|
+
connection_options)
|
70
|
+
else
|
71
|
+
Net::HTTP.start(service_uri.host,
|
72
|
+
service_uri.port,
|
73
|
+
connection_options)
|
74
|
+
end
|
61
75
|
end
|
62
76
|
|
63
77
|
def request
|
data/lib/comgate/gateway.rb
CHANGED
@@ -74,6 +74,10 @@ module Comgate
|
|
74
74
|
options[:test_calls] == true
|
75
75
|
end
|
76
76
|
|
77
|
+
def proxy_uri
|
78
|
+
options[:proxy_uri]
|
79
|
+
end
|
80
|
+
|
77
81
|
def start_transaction(payment_data)
|
78
82
|
make_call(url: "#{BASE_URL}/create",
|
79
83
|
payload: single_payment_payload(payment_data),
|
@@ -87,9 +91,9 @@ module Comgate
|
|
87
91
|
end
|
88
92
|
|
89
93
|
def repeat_recurring_transaction(payment_data)
|
90
|
-
|
94
|
+
init_transaction_id = payment_data[:payment][:recurrence].delete(:init_transaction_id)
|
91
95
|
make_call(url: "#{BASE_URL}/recurring",
|
92
|
-
payload: single_payment_payload(payment_data).merge(initRecurringId:
|
96
|
+
payload: single_payment_payload(payment_data).merge(initRecurringId: init_transaction_id),
|
93
97
|
test_call: test_call?(payment_data[:test]))
|
94
98
|
end
|
95
99
|
|
@@ -139,7 +143,7 @@ module Comgate
|
|
139
143
|
payload: gateway_params.merge(transId: transaction_id),
|
140
144
|
test_call: false)
|
141
145
|
end
|
142
|
-
alias check_state check_transaction
|
146
|
+
alias check_state check_transaction # backward compatibility
|
143
147
|
|
144
148
|
def process_callback(comgate_params)
|
145
149
|
Comgate::Response.new({ response_body: comgate_params }, DATA_CONVERSION_HASH)
|
@@ -173,7 +177,7 @@ module Comgate
|
|
173
177
|
def make_call(url:, payload:, test_call:, conversion_hash: DATA_CONVERSION_HASH)
|
174
178
|
raise "There are errors in pre-api-call phase: #{payload[:errors]}" unless payload[:errors].nil?
|
175
179
|
|
176
|
-
srv = Comgate::ApiCaller.call(url: url, payload: payload, test_call: test_call)
|
180
|
+
srv = Comgate::ApiCaller.call(url: url, payload: payload, test_call: test_call, proxy_uri: proxy_uri)
|
177
181
|
if srv.success?
|
178
182
|
Comgate::Response.new(srv.result, conversion_hash)
|
179
183
|
else
|
data/lib/comgate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comgate_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Mlčoch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a longer description or delete this line.
|
14
14
|
email:
|