mollie-api-ruby 4.6.2 → 4.7.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 +12 -0
- data/examples/methods/get.rb +8 -1
- data/examples/payments/update.rb +7 -0
- data/examples/subscriptions/list.rb +4 -0
- data/lib/mollie.rb +3 -2
- data/lib/mollie/client.rb +4 -0
- data/lib/mollie/customer/subscription.rb +1 -104
- data/lib/mollie/exception.rb +3 -0
- data/lib/mollie/organization.rb +1 -0
- data/lib/mollie/refund.rb +6 -1
- data/lib/mollie/subscription.rb +107 -0
- data/lib/mollie/version.rb +1 -1
- data/test/fixtures/refunds/get.json +3 -0
- data/test/mollie/client_test.rb +30 -0
- data/test/mollie/customer/subscription_test.rb +2 -2
- data/test/mollie/organization_test.rb +2 -0
- data/test/mollie/refund_test.rb +9 -7
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 199d37cfa91ad1e3132c095248ea54a26e7a25dddb748b02b2fa17b7d58334a3
|
4
|
+
data.tar.gz: 30ad0213bd7ed35038eecac7c48e4c3b965ca56b9f445c2ff6d723d2f223b741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bee04cf11e085a6886ded95949e996f66d78d4a5a5479b96fb6c4d74d8ef588ae2de6040966df27432c147062988370667c0ef601b908feeeca55b7cadb4eb5
|
7
|
+
data.tar.gz: '080873b112c5878455a65faad416ce9e5fa6af4c8acf0f3784986c5a2c8ea52895740c3d55a2fd84dff672ad83031d08b85d7a1a86c1b58aeffe7deaf2d21bb6'
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@
|
|
4
4
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
6
6
|
|
7
|
+
## 4.7.0 - 2020-02-03
|
8
|
+
|
9
|
+
- Implemented various API features from the changelog up to and including Tuesday, September 24th, 2019.
|
10
|
+
|
11
|
+
## 4.6.2 - 2019-11-21
|
12
|
+
|
13
|
+
- Added timeouts configuration for Net::HTTP
|
14
|
+
|
15
|
+
## 4.6.1 - 2019-11-20
|
16
|
+
|
17
|
+
- Update root certificates
|
18
|
+
|
7
19
|
## 4.6.0 - 2019-10-01
|
8
20
|
|
9
21
|
- Add Onboarding APIs (Get onboarding status, Submit onboarding data)
|
data/examples/methods/get.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
method = Mollie::Method.get('ideal')
|
2
2
|
|
3
|
-
# Include
|
3
|
+
# Include issuers available for the payment method (e.g. for
|
4
|
+
# iDEAL, KBC/CBC payment button or gift cards).
|
4
5
|
method = Mollie::Method.get('ideal', include: 'issuers')
|
6
|
+
|
7
|
+
# Include pricing for each payment method
|
8
|
+
method = Mollie::Method.get('ideal', include: 'pricing')
|
9
|
+
|
10
|
+
# Include both issuers and pricing
|
11
|
+
method = Mollie::Method.get('ideal', include: 'issuers,pricing')
|
data/lib/mollie.rb
CHANGED
@@ -16,8 +16,6 @@ require 'mollie/amount'
|
|
16
16
|
require 'mollie/chargeback'
|
17
17
|
require 'mollie/client'
|
18
18
|
require 'mollie/customer'
|
19
|
-
require 'mollie/customer/mandate'
|
20
|
-
require 'mollie/customer/subscription'
|
21
19
|
require 'mollie/invoice'
|
22
20
|
require 'mollie/list'
|
23
21
|
require 'mollie/method'
|
@@ -28,8 +26,11 @@ require 'mollie/permission'
|
|
28
26
|
require 'mollie/profile'
|
29
27
|
require 'mollie/refund'
|
30
28
|
require 'mollie/settlement'
|
29
|
+
require 'mollie/subscription'
|
31
30
|
|
31
|
+
require 'mollie/customer/mandate'
|
32
32
|
require 'mollie/customer/payment'
|
33
|
+
require 'mollie/customer/subscription'
|
33
34
|
require 'mollie/onboarding'
|
34
35
|
require 'mollie/order/line'
|
35
36
|
require 'mollie/order/refund'
|
data/lib/mollie/client.rb
CHANGED
@@ -123,6 +123,10 @@ module Mollie
|
|
123
123
|
Util.nested_underscore_keys(JSON.parse(response.body))
|
124
124
|
when 204
|
125
125
|
{} # No Content
|
126
|
+
when 404
|
127
|
+
json = JSON.parse(response.body)
|
128
|
+
exception = ResourceNotFoundError.new(json)
|
129
|
+
raise exception
|
126
130
|
else
|
127
131
|
json = JSON.parse(response.body)
|
128
132
|
exception = Mollie::RequestError.new(json)
|
@@ -1,109 +1,6 @@
|
|
1
1
|
module Mollie
|
2
2
|
class Customer
|
3
|
-
class Subscription <
|
4
|
-
STATUS_ACTIVE = 'active'.freeze
|
5
|
-
STATUS_PENDING = 'pending'.freeze # Waiting for a valid mandate.
|
6
|
-
STATUS_CANCELED = 'canceled'.freeze
|
7
|
-
STATUS_SUSPENDED = 'suspended'.freeze # Active, but mandate became invalid.
|
8
|
-
STATUS_COMPLETED = 'completed'.freeze
|
9
|
-
|
10
|
-
attr_accessor :id,
|
11
|
-
:customer_id,
|
12
|
-
:mode,
|
13
|
-
:created_at,
|
14
|
-
:status,
|
15
|
-
:amount,
|
16
|
-
:times,
|
17
|
-
:times_remaining,
|
18
|
-
:interval,
|
19
|
-
:next_payment_date,
|
20
|
-
:description,
|
21
|
-
:method,
|
22
|
-
:mandate_id,
|
23
|
-
:canceled_at,
|
24
|
-
:webhook_url,
|
25
|
-
:metadata,
|
26
|
-
:application_fee,
|
27
|
-
:_links
|
28
|
-
|
29
|
-
alias links _links
|
30
|
-
|
31
|
-
def active?
|
32
|
-
status == STATUS_ACTIVE
|
33
|
-
end
|
34
|
-
|
35
|
-
def pending?
|
36
|
-
status == STATUS_PENDING
|
37
|
-
end
|
38
|
-
|
39
|
-
def suspended?
|
40
|
-
status == STATUS_SUSPENDED
|
41
|
-
end
|
42
|
-
|
43
|
-
def canceled?
|
44
|
-
status == STATUS_CANCELED
|
45
|
-
end
|
46
|
-
|
47
|
-
def completed?
|
48
|
-
status == STATUS_COMPLETED
|
49
|
-
end
|
50
|
-
|
51
|
-
def created_at=(created_at)
|
52
|
-
@created_at = begin
|
53
|
-
Time.parse(created_at.to_s)
|
54
|
-
rescue StandardError
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def canceled_at=(canceled_at)
|
60
|
-
@canceled_at = begin
|
61
|
-
Time.parse(canceled_at.to_s)
|
62
|
-
rescue StandardError
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def amount=(amount)
|
68
|
-
@amount = Mollie::Amount.new(amount)
|
69
|
-
end
|
70
|
-
|
71
|
-
def times=(times)
|
72
|
-
@times = times.to_i
|
73
|
-
end
|
74
|
-
|
75
|
-
def next_payment_date=(next_payment_date)
|
76
|
-
@next_payment_date = begin
|
77
|
-
Date.parse(next_payment_date)
|
78
|
-
rescue StandardError
|
79
|
-
nil
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def customer(options = {})
|
84
|
-
Customer.get(customer_id, options)
|
85
|
-
end
|
86
|
-
|
87
|
-
def payments(options = {})
|
88
|
-
resource_url = Util.extract_url(links, 'payments')
|
89
|
-
return if resource_url.nil?
|
90
|
-
response = Mollie::Client.instance.perform_http_call('GET', resource_url, nil, {}, options)
|
91
|
-
Mollie::List.new(response, Payment)
|
92
|
-
end
|
93
|
-
|
94
|
-
def metadata=(metadata)
|
95
|
-
@metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
|
96
|
-
end
|
97
|
-
|
98
|
-
def application_fee=(application_fee)
|
99
|
-
amount = Amount.new(application_fee['amount'])
|
100
|
-
description = application_fee['description']
|
101
|
-
|
102
|
-
@application_fee = OpenStruct.new(
|
103
|
-
amount: amount,
|
104
|
-
description: description
|
105
|
-
)
|
106
|
-
end
|
3
|
+
class Subscription < Mollie::Subscription
|
107
4
|
end
|
108
5
|
end
|
109
6
|
end
|
data/lib/mollie/exception.rb
CHANGED
data/lib/mollie/organization.rb
CHANGED
data/lib/mollie/refund.rb
CHANGED
@@ -8,12 +8,14 @@ module Mollie
|
|
8
8
|
|
9
9
|
attr_accessor :id,
|
10
10
|
:amount,
|
11
|
+
:settlement_id,
|
11
12
|
:settlement_amount,
|
12
13
|
:status,
|
13
14
|
:lines,
|
14
15
|
:payment_id,
|
15
16
|
:order_id,
|
16
17
|
:description,
|
18
|
+
:metadata,
|
17
19
|
:created_at,
|
18
20
|
:_links
|
19
21
|
|
@@ -47,6 +49,10 @@ module Mollie
|
|
47
49
|
@settlement_amount = Amount.new(settlement_amount)
|
48
50
|
end
|
49
51
|
|
52
|
+
def metadata=(metadata)
|
53
|
+
@metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
|
54
|
+
end
|
55
|
+
|
50
56
|
def lines=(lines)
|
51
57
|
@lines = lines.map { |line| Order::Line.new(line) }
|
52
58
|
end
|
@@ -64,7 +70,6 @@ module Mollie
|
|
64
70
|
end
|
65
71
|
|
66
72
|
def settlement(options = {})
|
67
|
-
settlement_id = Util.extract_id(links, 'settlement')
|
68
73
|
return if settlement_id.nil?
|
69
74
|
Settlement.get(settlement_id, options)
|
70
75
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Subscription < Base
|
3
|
+
STATUS_ACTIVE = 'active'.freeze
|
4
|
+
STATUS_PENDING = 'pending'.freeze # Waiting for a valid mandate.
|
5
|
+
STATUS_CANCELED = 'canceled'.freeze
|
6
|
+
STATUS_SUSPENDED = 'suspended'.freeze # Active, but mandate became invalid.
|
7
|
+
STATUS_COMPLETED = 'completed'.freeze
|
8
|
+
|
9
|
+
attr_accessor :id,
|
10
|
+
:customer_id,
|
11
|
+
:mode,
|
12
|
+
:created_at,
|
13
|
+
:status,
|
14
|
+
:amount,
|
15
|
+
:times,
|
16
|
+
:times_remaining,
|
17
|
+
:interval,
|
18
|
+
:next_payment_date,
|
19
|
+
:description,
|
20
|
+
:method,
|
21
|
+
:mandate_id,
|
22
|
+
:canceled_at,
|
23
|
+
:webhook_url,
|
24
|
+
:metadata,
|
25
|
+
:application_fee,
|
26
|
+
:_links
|
27
|
+
|
28
|
+
alias links _links
|
29
|
+
|
30
|
+
def active?
|
31
|
+
status == STATUS_ACTIVE
|
32
|
+
end
|
33
|
+
|
34
|
+
def pending?
|
35
|
+
status == STATUS_PENDING
|
36
|
+
end
|
37
|
+
|
38
|
+
def suspended?
|
39
|
+
status == STATUS_SUSPENDED
|
40
|
+
end
|
41
|
+
|
42
|
+
def canceled?
|
43
|
+
status == STATUS_CANCELED
|
44
|
+
end
|
45
|
+
|
46
|
+
def completed?
|
47
|
+
status == STATUS_COMPLETED
|
48
|
+
end
|
49
|
+
|
50
|
+
def created_at=(created_at)
|
51
|
+
@created_at = begin
|
52
|
+
Time.parse(created_at.to_s)
|
53
|
+
rescue StandardError
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def canceled_at=(canceled_at)
|
59
|
+
@canceled_at = begin
|
60
|
+
Time.parse(canceled_at.to_s)
|
61
|
+
rescue StandardError
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def amount=(amount)
|
67
|
+
@amount = Mollie::Amount.new(amount)
|
68
|
+
end
|
69
|
+
|
70
|
+
def times=(times)
|
71
|
+
@times = times.to_i
|
72
|
+
end
|
73
|
+
|
74
|
+
def next_payment_date=(next_payment_date)
|
75
|
+
@next_payment_date = begin
|
76
|
+
Date.parse(next_payment_date)
|
77
|
+
rescue StandardError
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def customer(options = {})
|
83
|
+
Customer.get(customer_id, options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def payments(options = {})
|
87
|
+
resource_url = Util.extract_url(links, 'payments')
|
88
|
+
return if resource_url.nil?
|
89
|
+
response = Mollie::Client.instance.perform_http_call('GET', resource_url, nil, {}, options)
|
90
|
+
Mollie::List.new(response, Mollie::Payment)
|
91
|
+
end
|
92
|
+
|
93
|
+
def metadata=(metadata)
|
94
|
+
@metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
|
95
|
+
end
|
96
|
+
|
97
|
+
def application_fee=(application_fee)
|
98
|
+
amount = Amount.new(application_fee['amount'])
|
99
|
+
description = application_fee['description']
|
100
|
+
|
101
|
+
@application_fee = OpenStruct.new(
|
102
|
+
amount: amount,
|
103
|
+
description: description
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/mollie/version.rb
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
"status": "pending",
|
9
9
|
"createdAt": "2018-09-25T17:40:23+00:00",
|
10
10
|
"description": "Required quantity not in stock, refunding one photo book.",
|
11
|
+
"metadata": {
|
12
|
+
"bookkeeping_id": 12345
|
13
|
+
},
|
11
14
|
"orderId": "ord_stTC2WHAuS",
|
12
15
|
"paymentId": "tr_WDqYK6vllg",
|
13
16
|
"settlementAmount": {
|
data/test/mollie/client_test.rb
CHANGED
@@ -135,5 +135,35 @@ module Mollie
|
|
135
135
|
assert_equal(json['field'], e.field)
|
136
136
|
assert_equal(json['_links'], e.links)
|
137
137
|
end
|
138
|
+
|
139
|
+
def test_404_response
|
140
|
+
response = <<-JSON
|
141
|
+
{
|
142
|
+
"status": 404,
|
143
|
+
"title": "Not Found",
|
144
|
+
"detail": "No payment exists with token tr_WDqYK6vllg.",
|
145
|
+
"_links": {
|
146
|
+
"documentation": {
|
147
|
+
"href": "https://docs.mollie.com/guides/handling-errors",
|
148
|
+
"type": "text/html"
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
JSON
|
153
|
+
|
154
|
+
json = JSON.parse(response)
|
155
|
+
stub_request(:post, 'https://api.mollie.com/v2/my-method')
|
156
|
+
.to_return(status: 404, body: response, headers: {})
|
157
|
+
|
158
|
+
e = assert_raise ResourceNotFoundError.new(JSON.parse(response)) do
|
159
|
+
client.perform_http_call('POST', 'my-method', nil, {})
|
160
|
+
end
|
161
|
+
|
162
|
+
assert_equal(json['status'], e.status)
|
163
|
+
assert_equal(json['title'], e.title)
|
164
|
+
assert_equal(json['detail'], e.detail)
|
165
|
+
assert_equal(json['field'], e.field)
|
166
|
+
assert_equal(json['_links'], e.links)
|
167
|
+
end
|
138
168
|
end
|
139
169
|
end
|
@@ -154,8 +154,8 @@ module Mollie
|
|
154
154
|
subscription = Customer::Subscription.get('sub_8JfGzs6v3K', customer_id: 'cst_8wmqcHMN4U')
|
155
155
|
payments = subscription.payments
|
156
156
|
|
157
|
-
assert_equal payments.klass
|
158
|
-
assert_equal payments.first.id
|
157
|
+
assert_equal Mollie::Payment, payments.klass
|
158
|
+
assert_equal 'tr_DtKxVP2AgW', payments.first.id
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -16,6 +16,7 @@ module Mollie
|
|
16
16
|
},
|
17
17
|
registration_number: '30204462',
|
18
18
|
vat_number: 'NL815839091B01',
|
19
|
+
vat_regulation: 'dutch',
|
19
20
|
_links: {
|
20
21
|
'self' => {
|
21
22
|
'href' => 'https://api.mollie.com/v2/organizations/org_12345678',
|
@@ -40,6 +41,7 @@ module Mollie
|
|
40
41
|
assert_equal 'NL', organization.address.country
|
41
42
|
assert_equal '30204462', organization.registration_number
|
42
43
|
assert_equal 'NL815839091B01', organization.vat_number
|
44
|
+
assert_equal 'dutch', organization.vat_regulation
|
43
45
|
assert_equal 'https://api.mollie.com/v2/organizations/org_12345678', organization.links['self']['href']
|
44
46
|
end
|
45
47
|
|
data/test/mollie/refund_test.rb
CHANGED
@@ -126,13 +126,7 @@ module Mollie
|
|
126
126
|
{
|
127
127
|
"resource": "refund",
|
128
128
|
"id": "re_4qqhO89gsT",
|
129
|
-
"
|
130
|
-
"_links": {
|
131
|
-
"settlement": {
|
132
|
-
"href": "https://api.mollie.com/v2/settlements/stl_jDk30akdN",
|
133
|
-
"type": "application/hal+json"
|
134
|
-
}
|
135
|
-
}
|
129
|
+
"settlementId": "stl_jDk30akdN"
|
136
130
|
}
|
137
131
|
), headers: {})
|
138
132
|
|
@@ -180,5 +174,13 @@ module Mollie
|
|
180
174
|
refund = Payment::Refund.new(id: 're_4qqhO89gsT')
|
181
175
|
assert refund.order.nil?
|
182
176
|
end
|
177
|
+
|
178
|
+
def test_metadata_struct
|
179
|
+
stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT')
|
180
|
+
.to_return(status: 200, body: read_fixture('refunds/get.json'), headers: {})
|
181
|
+
|
182
|
+
refund = Payment::Refund.get('re_4qqhO89gsT', payment_id: 'tr_WDqYK6vllg')
|
183
|
+
assert_equal 12345, refund.metadata.bookkeeping_id
|
184
|
+
end
|
183
185
|
end
|
184
186
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mollie B.V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- examples/payments/get-subscription.rb
|
139
139
|
- examples/payments/get.rb
|
140
140
|
- examples/payments/list.rb
|
141
|
+
- examples/payments/update.rb
|
141
142
|
- examples/payments/webhook.rb
|
142
143
|
- examples/permissions/get.rb
|
143
144
|
- examples/permissions/list.rb
|
@@ -205,6 +206,7 @@ files:
|
|
205
206
|
- lib/mollie/settlement/chargeback.rb
|
206
207
|
- lib/mollie/settlement/payment.rb
|
207
208
|
- lib/mollie/settlement/refund.rb
|
209
|
+
- lib/mollie/subscription.rb
|
208
210
|
- lib/mollie/util.rb
|
209
211
|
- lib/mollie/version.rb
|
210
212
|
- mollie-api-ruby.gemspec
|