mollie-api-ruby 4.4.1 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mollie/client.rb +6 -1
- data/lib/mollie/customer/subscription.rb +7 -0
- data/lib/mollie/version.rb +1 -1
- data/test/fixtures/subscriptions/get.json +45 -0
- data/test/fixtures/subscriptions/get_payments.json +75 -0
- data/test/mollie/customer/subscription_test.rb +14 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 077c3341a3246c466e7d7d62d32bd68da1957af6c3c646fdaffcda51697efb68
|
4
|
+
data.tar.gz: b5731818494fb85b6c4c088ea1e4bbfa1d0ecbd9ed3e56d41d5736c3af2d5e11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9498ca7ba156382ad00369ccff33e40018580cd73ba5bfc5a3922262c2627bef527f61532f0f05b35e87c260e5177d297376b5fca96873fbe83605d632808c26
|
7
|
+
data.tar.gz: e5bd2c61d222ba1f13de30565977fd2d40a08f165eebbb45b8890fff5b76d19c3741ecb00dac98740215e9576bc9a80b78d2357ff4393e4034699e2ab4d29bef
|
data/lib/mollie/client.rb
CHANGED
@@ -62,7 +62,12 @@ module Mollie
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def perform_http_call(http_method, api_method, id = nil, http_body = {}, query = {})
|
65
|
-
path
|
65
|
+
path = if api_method.start_with?(API_ENDPOINT)
|
66
|
+
URI.parse(api_method).path
|
67
|
+
else
|
68
|
+
"/#{API_VERSION}/#{api_method}/#{id}".chomp('/')
|
69
|
+
end
|
70
|
+
|
66
71
|
api_key = http_body.delete(:api_key) || query.delete(:api_key) || @api_key
|
67
72
|
api_endpoint = http_body.delete(:api_endpoint) || query.delete(:api_endpoint) || @api_endpoint
|
68
73
|
|
@@ -84,6 +84,13 @@ module Mollie
|
|
84
84
|
Customer.get(customer_id, options)
|
85
85
|
end
|
86
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
|
+
|
87
94
|
def metadata=(metadata)
|
88
95
|
@metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
|
89
96
|
end
|
data/lib/mollie/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"resource": "subscription",
|
3
|
+
"id": "sub_8JfGzs6v3K",
|
4
|
+
"mode": "live",
|
5
|
+
"createdAt": "2016-06-01T12:23:34+00:00",
|
6
|
+
"status": "active",
|
7
|
+
"amount": {
|
8
|
+
"value": "25.00",
|
9
|
+
"currency": "EUR"
|
10
|
+
},
|
11
|
+
"times": 4,
|
12
|
+
"timesRemaining": 4,
|
13
|
+
"interval": "3 months",
|
14
|
+
"startDate": "2016-06-01",
|
15
|
+
"nextPaymentDate": "2016-09-01",
|
16
|
+
"description": "Quarterly payment",
|
17
|
+
"method": null,
|
18
|
+
"mandateId": "mdt_aGQNkteF6w",
|
19
|
+
"webhookUrl": "https://webshop.example.org/payments/webhook",
|
20
|
+
"metadata": {
|
21
|
+
"plan": "small"
|
22
|
+
},
|
23
|
+
"_links": {
|
24
|
+
"self": {
|
25
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_8JfGzs6v3K",
|
26
|
+
"type": "application/hal+json"
|
27
|
+
},
|
28
|
+
"customer": {
|
29
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U",
|
30
|
+
"type": "application/hal+json"
|
31
|
+
},
|
32
|
+
"payments": {
|
33
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_8JfGzs6v3K/payments",
|
34
|
+
"type": "application/hal+json"
|
35
|
+
},
|
36
|
+
"profile": {
|
37
|
+
"href": "https://api.mollie.com/v2/profiles/pfl_URR55HPMGx",
|
38
|
+
"type": "application/hal+json"
|
39
|
+
},
|
40
|
+
"documentation": {
|
41
|
+
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/get-subscription",
|
42
|
+
"type": "text/html"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
{
|
2
|
+
"_embedded": {
|
3
|
+
"payments": [
|
4
|
+
{
|
5
|
+
"resource": "payment",
|
6
|
+
"id": "tr_DtKxVP2AgW",
|
7
|
+
"mode": "live",
|
8
|
+
"createdAt": "2018-09-19T12:49:52+00:00",
|
9
|
+
"amount": {
|
10
|
+
"value": "10.00",
|
11
|
+
"currency": "EUR"
|
12
|
+
},
|
13
|
+
"description": "Some subscription 19 sep. 2018",
|
14
|
+
"method": "directdebit",
|
15
|
+
"metadata": null,
|
16
|
+
"status": "pending",
|
17
|
+
"isCancelable": true,
|
18
|
+
"expiresAt": "2019-09-19T12:49:52+00:00",
|
19
|
+
"locale": "nl_NL",
|
20
|
+
"profileId": "pfl_URR55HPMGx",
|
21
|
+
"customerId": "cst_8wmqcHMN4U",
|
22
|
+
"mandateId": "mdt_aGQNkteF6w",
|
23
|
+
"subscriptionId": "sub_8JfGzs6v3K",
|
24
|
+
"sequenceType": "recurring",
|
25
|
+
"redirectUrl": null,
|
26
|
+
"webhookUrl": "https://example.org/webhook",
|
27
|
+
"settlementAmount": {
|
28
|
+
"value": "10.00",
|
29
|
+
"currency": "EUR"
|
30
|
+
},
|
31
|
+
"details": {
|
32
|
+
"transferReference": "SD67-6850-2204-6029",
|
33
|
+
"creditorIdentifier": "NL08ZZZ502057730000",
|
34
|
+
"consumerName": "Customer A",
|
35
|
+
"consumerAccount": "NL50INGB0006588912",
|
36
|
+
"consumerBic": "INGBNL2A",
|
37
|
+
"dueDate": "2018-09-21",
|
38
|
+
"signatureDate": "2018-09-19"
|
39
|
+
},
|
40
|
+
"_links": {
|
41
|
+
"self": {
|
42
|
+
"href": "https://api.mollie.com/v2/payments/tr_DtKxVP2AgW",
|
43
|
+
"type": "application/hal+json"
|
44
|
+
},
|
45
|
+
"checkout": null,
|
46
|
+
"customer": {
|
47
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U",
|
48
|
+
"type": "application/hal+json"
|
49
|
+
},
|
50
|
+
"mandate": {
|
51
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/mandates/mdt_aGQNkteF6w",
|
52
|
+
"type": "application/hal+json"
|
53
|
+
},
|
54
|
+
"subscription": {
|
55
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_8JfGzs6v3K",
|
56
|
+
"type": "application/hal+json"
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
]
|
61
|
+
},
|
62
|
+
"count": 1,
|
63
|
+
"_links": {
|
64
|
+
"documentation": {
|
65
|
+
"href": "https://docs.mollie.com/reference/v2/subscriptions-api/list-subscriptions-payments",
|
66
|
+
"type": "text/html"
|
67
|
+
},
|
68
|
+
"self": {
|
69
|
+
"href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_8JfGzs6v3K/payments?limit=50",
|
70
|
+
"type": "application/hal+json"
|
71
|
+
},
|
72
|
+
"previous": null,
|
73
|
+
"next": null
|
74
|
+
}
|
75
|
+
}
|
@@ -143,6 +143,20 @@ module Mollie
|
|
143
143
|
assert_equal 42.10, subscription.application_fee.amount.value
|
144
144
|
assert_equal'EUR', subscription.application_fee.amount.currency
|
145
145
|
end
|
146
|
+
|
147
|
+
def test_get_payments
|
148
|
+
stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_8JfGzs6v3K')
|
149
|
+
.to_return(status: 200, body: read_fixture('subscriptions/get.json'), headers: {})
|
150
|
+
|
151
|
+
stub_request(:get, 'https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions/sub_8JfGzs6v3K/payments')
|
152
|
+
.to_return(status: 200, body: read_fixture('subscriptions/get_payments.json'), headers: {})
|
153
|
+
|
154
|
+
subscription = Customer::Subscription.get('sub_8JfGzs6v3K', customer_id: 'cst_8wmqcHMN4U')
|
155
|
+
payments = subscription.payments
|
156
|
+
|
157
|
+
assert_equal payments.klass, Payment
|
158
|
+
assert_equal payments.first.id, 'tr_DtKxVP2AgW'
|
159
|
+
end
|
146
160
|
end
|
147
161
|
end
|
148
162
|
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.5.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: 2019-
|
11
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -222,6 +222,8 @@ files:
|
|
222
222
|
- test/fixtures/shipments/get.json
|
223
223
|
- test/fixtures/shipments/list.json
|
224
224
|
- test/fixtures/shipments/update.json
|
225
|
+
- test/fixtures/subscriptions/get.json
|
226
|
+
- test/fixtures/subscriptions/get_payments.json
|
225
227
|
- test/helper.rb
|
226
228
|
- test/mollie/amount_test.rb
|
227
229
|
- test/mollie/base_test.rb
|
@@ -278,6 +280,8 @@ summary: Official Mollie API Client for Ruby
|
|
278
280
|
test_files:
|
279
281
|
- test/fixtures/captures/get.json
|
280
282
|
- test/fixtures/captures/list.json
|
283
|
+
- test/fixtures/subscriptions/get.json
|
284
|
+
- test/fixtures/subscriptions/get_payments.json
|
281
285
|
- test/fixtures/shipments/get.json
|
282
286
|
- test/fixtures/shipments/create.json
|
283
287
|
- test/fixtures/shipments/update.json
|