mollie-api-ruby 4.15.0 → 4.16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06f14768975850db4a88530cf6cfbe4d4b80f274c2616736ba6af908e83a044c
4
- data.tar.gz: d7eae71e95f7d0b06646fcc39b069658dc0d808874654fdfd9b2353f1af70d3c
3
+ metadata.gz: 8c69f3ca558a810762900aa7a74798129377ee91d41b136d5b32428085451d8f
4
+ data.tar.gz: cde2ea24aa5eeae5218d71af093b7081e9dbcdd5f94dd9b84bb7f9cef9d841de
5
5
  SHA512:
6
- metadata.gz: d450cb135d44a6b17b51cdb5921aa03fa9a3796c540b427fb8796251177c776f5d3541f4bccf10739f1bf17fdc65611a318ae6ed17938718d915d487000ac435
7
- data.tar.gz: 9a8fad769b51f90ecf0a4d464661b5e22cda7304b32388091019bb754d66eed1abe731f598547778e8357e302500f32a33a2c740a60b725625e03ed261ec29a2
6
+ metadata.gz: 25f7c4a575b44e5ce96a8842fdb9c95f817f0beb0ab7150d221394a2b6c906921d538a8a398e6aab6f0569e772ef589fbdb6c75f51d6caa02ad9e95b6e313987
7
+ data.tar.gz: 27d0e5486b0e3c18f6e69eadc606aaaa75a32bd851780a3bebfbbd2f7952193743cfd3c2c7a133cd553292bfe561ca99727717bb710b62eba679d48576a8a49c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ ## 4.16.0 - 2025-03-19
8
+
9
+ - (9caf303) Support embedded payment captures and chargebacks
10
+ - (ed1916e) Add support for embedded refunds
11
+ - (c322aca) Avoid frozen string literals warnings with Ruby 3.4
12
+
7
13
  ## 4.15.0 - 2024-12-01
8
14
 
9
15
  - (f659c19) Add Balance API
@@ -1 +1,4 @@
1
1
  payment = Mollie::Payment.get('tr_7UhSN1zuXS')
2
+
3
+ # With embedded resources
4
+ payment = Mollie::Payment.get('tr_7UhSN1zuXS', embed: 'captures,chargebacks,refunds')
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 'Mollie/' << VERSION
54
- add_version_string 'Ruby/' << RUBY_VERSION
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
 
@@ -197,15 +197,33 @@ module Mollie
197
197
  end
198
198
 
199
199
  def refunds(options = {})
200
- Payment::Refund.all(options.merge(payment_id: id))
200
+ resources = (attributes['_embedded']['refunds'] if attributes['_embedded'])
201
+
202
+ if resources.nil?
203
+ Payment::Refund.all(options.merge(payment_id: id))
204
+ else
205
+ List.new({ '_embedded' => { 'refunds' => resources } }, Payment::Refund)
206
+ end
201
207
  end
202
208
 
203
209
  def chargebacks(options = {})
204
- Payment::Chargeback.all(options.merge(payment_id: id))
210
+ resources = (attributes['_embedded']['chargebacks'] if attributes['_embedded'])
211
+
212
+ if resources.nil?
213
+ Payment::Chargeback.all(options.merge(payment_id: id))
214
+ else
215
+ List.new({ '_embedded' => { 'chargebacks' => resources } }, Payment::Chargeback)
216
+ end
205
217
  end
206
218
 
207
219
  def captures(options = {})
208
- Payment::Capture.all(options.merge(payment_id: id))
220
+ resources = (attributes['_embedded']['captures'] if attributes['_embedded'])
221
+
222
+ if resources.nil?
223
+ Payment::Capture.all(options.merge(payment_id: id))
224
+ else
225
+ List.new({ '_embedded' => { 'captures' => resources } }, Payment::Capture)
226
+ end
209
227
  end
210
228
 
211
229
  def customer(options = {})
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.15.0'.freeze
2
+ VERSION = '4.16.0'.freeze
3
3
  end
@@ -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
+ }
@@ -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',
@@ -233,6 +235,36 @@ module Mollie
233
235
  assert_equal 'NL', payment.restrict_payment_methods_to_country
234
236
  end
235
237
 
238
+ def test_embedded_captures
239
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg?embed=captures')
240
+ .to_return(status: 200, body: GET_PAYMENT_WITH_EMBEDDED_RESOURCES, headers: {})
241
+
242
+ payment = Payment.get('tr_WDqYK6vllg', embed: 'captures')
243
+
244
+ assert_equal 'cpt_mNepDkEtco6ah3QNPUGYH', payment.captures.first.id
245
+ assert_equal 1, payment.captures.size
246
+ end
247
+
248
+ def test_embedded_chargebacks
249
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg?embed=chargebacks')
250
+ .to_return(status: 200, body: GET_PAYMENT_WITH_EMBEDDED_RESOURCES, headers: {})
251
+
252
+ payment = Payment.get('tr_WDqYK6vllg', embed: 'chargebacks')
253
+
254
+ assert_equal 'chb_ls7ahg', payment.chargebacks.first.id
255
+ assert_equal 1, payment.chargebacks.size
256
+ end
257
+
258
+ def test_embedded_refunds
259
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg?embed=refunds')
260
+ .to_return(status: 200, body: GET_PAYMENT_WITH_EMBEDDED_RESOURCES, headers: {})
261
+
262
+ payment = Payment.get('tr_WDqYK6vllg', embed: 'refunds')
263
+
264
+ assert_equal 're_vD3Jm32wQt', payment.refunds.first.id
265
+ assert_equal 1, payment.refunds.size
266
+ end
267
+
236
268
  def test_list_refunds
237
269
  stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/refunds')
238
270
  .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.15.0
4
+ version: 4.16.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: 2024-12-01 00:00:00.000000000 Z
10
+ date: 2025-03-19 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.5.22
374
- signing_key:
372
+ rubygems_version: 3.6.2
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