mollie-api-ruby 4.15.0 → 4.17.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/CHANGELOG.md +10 -0
- data/examples/payments/get.rb +3 -0
- data/lib/mollie/client.rb +4 -2
- data/lib/mollie/payment.rb +25 -3
- data/lib/mollie/version.rb +1 -1
- data/test/fixtures/payments/get_embedded_resources.json +126 -0
- data/test/mollie/payment_test.rb +48 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cecda0428cc1ec88b912368395adf92608fdb85e92f642e95373cd8cdb6399d
|
4
|
+
data.tar.gz: a0ca1de61ed2079f318a58ac70a80f379bde66ef17a90f69836aa387c68326df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d957aeb32e7653adbde02ec1c8c840e94c70e7fe2c467b5c37d58e14323a14f17c37149b7bf6d136e49045f6c8ab094554fdc1a153347bffeea47e2ea2a69d9
|
7
|
+
data.tar.gz: 978df1487eb575b7dd289928996e1d6d474d6a4cd6eb8e9a0099d831cdadec1da95fdab7a70921a53c27773b7eb277f47339ff6b95f00869e9120f1055ab17f0
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@
|
|
4
4
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
6
6
|
|
7
|
+
## 4.17.0 - 2025-04-21
|
8
|
+
|
9
|
+
- (bc414d0) Payment: add release payment authorization API
|
10
|
+
|
11
|
+
## 4.16.0 - 2025-03-19
|
12
|
+
|
13
|
+
- (9caf303) Support embedded payment captures and chargebacks
|
14
|
+
- (ed1916e) Add support for embedded refunds
|
15
|
+
- (c322aca) Avoid frozen string literals warnings with Ruby 3.4
|
16
|
+
|
7
17
|
## 4.15.0 - 2024-12-01
|
8
18
|
|
9
19
|
- (f659c19) Add Balance API
|
data/examples/payments/get.rb
CHANGED
data/lib/mollie/client.rb
CHANGED
@@ -50,8 +50,8 @@ module Mollie
|
|
50
50
|
@api_key = api_key
|
51
51
|
@version_strings = []
|
52
52
|
|
53
|
-
add_version_string
|
54
|
-
add_version_string
|
53
|
+
add_version_string "Mollie/#{VERSION}"
|
54
|
+
add_version_string "Ruby/#{RUBY_VERSION}"
|
55
55
|
add_version_string OpenSSL::OPENSSL_VERSION.split(' ').slice(0, 2).join '/'
|
56
56
|
end
|
57
57
|
|
@@ -126,6 +126,8 @@ module Mollie
|
|
126
126
|
case http_code
|
127
127
|
when 200, 201
|
128
128
|
Util.nested_underscore_keys(JSON.parse(response.body))
|
129
|
+
when 202
|
130
|
+
JSON.parse(response.body)
|
129
131
|
when 204
|
130
132
|
{} # No Content
|
131
133
|
when 404
|
data/lib/mollie/payment.rb
CHANGED
@@ -196,16 +196,38 @@ module Mollie
|
|
196
196
|
Payment::Refund.create(options)
|
197
197
|
end
|
198
198
|
|
199
|
+
def release_authorization(options = {})
|
200
|
+
Client.instance.perform_http_call("POST", "payments/#{id}", "release-authorization", {}, options) == {}
|
201
|
+
end
|
202
|
+
|
199
203
|
def refunds(options = {})
|
200
|
-
|
204
|
+
resources = (attributes['_embedded']['refunds'] if attributes['_embedded'])
|
205
|
+
|
206
|
+
if resources.nil?
|
207
|
+
Payment::Refund.all(options.merge(payment_id: id))
|
208
|
+
else
|
209
|
+
List.new({ '_embedded' => { 'refunds' => resources } }, Payment::Refund)
|
210
|
+
end
|
201
211
|
end
|
202
212
|
|
203
213
|
def chargebacks(options = {})
|
204
|
-
|
214
|
+
resources = (attributes['_embedded']['chargebacks'] if attributes['_embedded'])
|
215
|
+
|
216
|
+
if resources.nil?
|
217
|
+
Payment::Chargeback.all(options.merge(payment_id: id))
|
218
|
+
else
|
219
|
+
List.new({ '_embedded' => { 'chargebacks' => resources } }, Payment::Chargeback)
|
220
|
+
end
|
205
221
|
end
|
206
222
|
|
207
223
|
def captures(options = {})
|
208
|
-
|
224
|
+
resources = (attributes['_embedded']['captures'] if attributes['_embedded'])
|
225
|
+
|
226
|
+
if resources.nil?
|
227
|
+
Payment::Capture.all(options.merge(payment_id: id))
|
228
|
+
else
|
229
|
+
List.new({ '_embedded' => { 'captures' => resources } }, Payment::Capture)
|
230
|
+
end
|
209
231
|
end
|
210
232
|
|
211
233
|
def customer(options = {})
|
data/lib/mollie/version.rb
CHANGED
@@ -0,0 +1,126 @@
|
|
1
|
+
{
|
2
|
+
"resource": "payment",
|
3
|
+
"id": "tr_WDqYK6vllg",
|
4
|
+
"mode": "test",
|
5
|
+
"createdAt": "2018-03-20T13:13:37+00:00",
|
6
|
+
"amount": {
|
7
|
+
"value": "10.00",
|
8
|
+
"currency": "EUR"
|
9
|
+
},
|
10
|
+
"description": "Order #12345",
|
11
|
+
"method": null,
|
12
|
+
"metadata": {
|
13
|
+
"order_id": "12345"
|
14
|
+
},
|
15
|
+
"status": "open",
|
16
|
+
"isCancelable": false,
|
17
|
+
"locale": "nl_NL",
|
18
|
+
"restrictPaymentMethodsToCountry": "NL",
|
19
|
+
"expiresAt": "2018-03-20T13:28:37+00:00",
|
20
|
+
"details": null,
|
21
|
+
"profileId": "pfl_QkEhN94Ba",
|
22
|
+
"sequenceType": "oneoff",
|
23
|
+
"redirectUrl": "https://webshop.example.org/order/12345/",
|
24
|
+
"webhookUrl": "https://webshop.example.org/payments/webhook/",
|
25
|
+
"_embedded": {
|
26
|
+
"captures": [
|
27
|
+
{
|
28
|
+
"resource": "capture",
|
29
|
+
"id": "cpt_mNepDkEtco6ah3QNPUGYH",
|
30
|
+
"mode": "test",
|
31
|
+
"amount": {
|
32
|
+
"value": "10.00",
|
33
|
+
"currency": "EUR"
|
34
|
+
},
|
35
|
+
"status": "succeeded",
|
36
|
+
"createdAt": "2025-03-19T15:03:34+00:00",
|
37
|
+
"description": "Capture for order #12345",
|
38
|
+
"settlementAmount": {
|
39
|
+
"value": "10.00",
|
40
|
+
"currency": "EUR"
|
41
|
+
},
|
42
|
+
"paymentId": "tr_WDqYK6vllg",
|
43
|
+
"_links": {
|
44
|
+
"self": {
|
45
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/captures/cpt_mNepDkEtco6ah3QNPUGYH",
|
46
|
+
"type": "application/hal+json"
|
47
|
+
},
|
48
|
+
"payment": {
|
49
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
50
|
+
"type": "application/hal+json"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
],
|
55
|
+
"chargebacks": [
|
56
|
+
{
|
57
|
+
"resource": "chargeback",
|
58
|
+
"id": "chb_ls7ahg",
|
59
|
+
"amount": {
|
60
|
+
"value": "10.00",
|
61
|
+
"currency": "EUR"
|
62
|
+
},
|
63
|
+
"created_at": "2022-01-03T13:20:37+00:00",
|
64
|
+
"payment_id": "tr_WDqYK6vllg",
|
65
|
+
"settlement_amount": {
|
66
|
+
"value": "-10.00",
|
67
|
+
"currency": "EUR"
|
68
|
+
},
|
69
|
+
"_links": {
|
70
|
+
"self": {
|
71
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/chargebacks/chb_ls7ahg",
|
72
|
+
"type": "application/hal+json"
|
73
|
+
},
|
74
|
+
"payment": {
|
75
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
76
|
+
"type": "application/hal+json"
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
],
|
81
|
+
"refunds": [
|
82
|
+
{
|
83
|
+
"resource": "refund",
|
84
|
+
"id": "re_vD3Jm32wQt",
|
85
|
+
"mode": "test",
|
86
|
+
"amount": {
|
87
|
+
"value": "329.99",
|
88
|
+
"currency": "EUR"
|
89
|
+
},
|
90
|
+
"status": "pending",
|
91
|
+
"createdAt": "2019-01-15T15:41:21+00:00",
|
92
|
+
"description": "Required quantity not in stock, refunding one photo book.",
|
93
|
+
"metadata": null,
|
94
|
+
"paymentId": "tr_WDqYK6vllg",
|
95
|
+
"settlementAmount": {
|
96
|
+
"value": "-329.99",
|
97
|
+
"currency": "EUR"
|
98
|
+
},
|
99
|
+
"_links": {
|
100
|
+
"self": {
|
101
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_vD3Jm32wQt",
|
102
|
+
"type": "application/hal+json"
|
103
|
+
},
|
104
|
+
"payment": {
|
105
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
106
|
+
"type": "application/hal+json"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
]
|
111
|
+
},
|
112
|
+
"_links": {
|
113
|
+
"self": {
|
114
|
+
"href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
|
115
|
+
"type": "application/hal+json"
|
116
|
+
},
|
117
|
+
"checkout": {
|
118
|
+
"href": "https://www.mollie.com/payscreen/select-method/WDqYK6vllg",
|
119
|
+
"type": "text/html"
|
120
|
+
},
|
121
|
+
"documentation": {
|
122
|
+
"href": "https://docs.mollie.com/reference/v2/payments-api/get-payment",
|
123
|
+
"type": "text/html"
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
data/test/mollie/payment_test.rb
CHANGED
@@ -2,6 +2,8 @@ require 'helper'
|
|
2
2
|
|
3
3
|
module Mollie
|
4
4
|
class PaymentTest < Test::Unit::TestCase
|
5
|
+
GET_PAYMENT_WITH_EMBEDDED_RESOURCES = read_fixture('payments/get_embedded_resources.json')
|
6
|
+
|
5
7
|
def test_setting_attributes
|
6
8
|
attributes = {
|
7
9
|
resource: 'payment',
|
@@ -149,6 +151,22 @@ module Mollie
|
|
149
151
|
assert_equal 'cst_8wmqcHMN4U', payment.customer_id
|
150
152
|
end
|
151
153
|
|
154
|
+
def test_release_authorization
|
155
|
+
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
|
156
|
+
.to_return(status: 200, body: %(
|
157
|
+
{
|
158
|
+
"resource": "payment",
|
159
|
+
"id": "tr_WDqYK6vllg"
|
160
|
+
}
|
161
|
+
), headers: {})
|
162
|
+
|
163
|
+
stub_request(:post, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/release-authorization')
|
164
|
+
.to_return(status: 202, body: %({}), headers: {})
|
165
|
+
|
166
|
+
payment = Payment.get('tr_WDqYK6vllg')
|
167
|
+
assert payment.release_authorization
|
168
|
+
end
|
169
|
+
|
152
170
|
def test_refund!
|
153
171
|
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
|
154
172
|
.to_return(status: 200, body: %(
|
@@ -233,6 +251,36 @@ module Mollie
|
|
233
251
|
assert_equal 'NL', payment.restrict_payment_methods_to_country
|
234
252
|
end
|
235
253
|
|
254
|
+
def test_embedded_captures
|
255
|
+
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg?embed=captures')
|
256
|
+
.to_return(status: 200, body: GET_PAYMENT_WITH_EMBEDDED_RESOURCES, headers: {})
|
257
|
+
|
258
|
+
payment = Payment.get('tr_WDqYK6vllg', embed: 'captures')
|
259
|
+
|
260
|
+
assert_equal 'cpt_mNepDkEtco6ah3QNPUGYH', payment.captures.first.id
|
261
|
+
assert_equal 1, payment.captures.size
|
262
|
+
end
|
263
|
+
|
264
|
+
def test_embedded_chargebacks
|
265
|
+
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg?embed=chargebacks')
|
266
|
+
.to_return(status: 200, body: GET_PAYMENT_WITH_EMBEDDED_RESOURCES, headers: {})
|
267
|
+
|
268
|
+
payment = Payment.get('tr_WDqYK6vllg', embed: 'chargebacks')
|
269
|
+
|
270
|
+
assert_equal 'chb_ls7ahg', payment.chargebacks.first.id
|
271
|
+
assert_equal 1, payment.chargebacks.size
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_embedded_refunds
|
275
|
+
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg?embed=refunds')
|
276
|
+
.to_return(status: 200, body: GET_PAYMENT_WITH_EMBEDDED_RESOURCES, headers: {})
|
277
|
+
|
278
|
+
payment = Payment.get('tr_WDqYK6vllg', embed: 'refunds')
|
279
|
+
|
280
|
+
assert_equal 're_vD3Jm32wQt', payment.refunds.first.id
|
281
|
+
assert_equal 1, payment.refunds.size
|
282
|
+
end
|
283
|
+
|
236
284
|
def test_list_refunds
|
237
285
|
stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/refunds')
|
238
286
|
.to_return(status: 200, body: %({"_embedded" : {"refunds" : [{"id":"ref-id", "payment_id":"pay-id"}]}}), headers: {})
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mollie-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mollie B.V.
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: ostruct
|
@@ -304,6 +303,7 @@ files:
|
|
304
303
|
- test/fixtures/payment_links/list.json
|
305
304
|
- test/fixtures/payment_links/update.json
|
306
305
|
- test/fixtures/payments/get.json
|
306
|
+
- test/fixtures/payments/get_embedded_resources.json
|
307
307
|
- test/fixtures/refunds/get.json
|
308
308
|
- test/fixtures/shipments/create.json
|
309
309
|
- test/fixtures/shipments/get.json
|
@@ -355,7 +355,6 @@ licenses:
|
|
355
355
|
- BSD
|
356
356
|
metadata:
|
357
357
|
changelog_uri: https://github.com/mollie/mollie-api-ruby/blob/master/CHANGELOG.md
|
358
|
-
post_install_message:
|
359
358
|
rdoc_options: []
|
360
359
|
require_paths:
|
361
360
|
- lib
|
@@ -370,8 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
370
369
|
- !ruby/object:Gem::Version
|
371
370
|
version: '0'
|
372
371
|
requirements: []
|
373
|
-
rubygems_version: 3.
|
374
|
-
signing_key:
|
372
|
+
rubygems_version: 3.6.7
|
375
373
|
specification_version: 4
|
376
374
|
summary: Official Mollie API Client for Ruby
|
377
375
|
test_files:
|
@@ -408,6 +406,7 @@ test_files:
|
|
408
406
|
- test/fixtures/payment_links/list.json
|
409
407
|
- test/fixtures/payment_links/update.json
|
410
408
|
- test/fixtures/payments/get.json
|
409
|
+
- test/fixtures/payments/get_embedded_resources.json
|
411
410
|
- test/fixtures/refunds/get.json
|
412
411
|
- test/fixtures/shipments/create.json
|
413
412
|
- test/fixtures/shipments/get.json
|