mollie-api-ruby 4.14.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 +4 -4
- data/CHANGELOG.md +10 -0
- data/examples/balances/get-primary.rb +1 -0
- data/examples/balances/get-report.rb +2 -0
- data/examples/balances/get.rb +1 -0
- data/examples/balances/list-transactions.rb +2 -0
- data/examples/balances/list.rb +1 -0
- data/examples/payments/get.rb +3 -0
- data/lib/mollie/balance/report.rb +25 -0
- data/lib/mollie/balance/transaction.rb +41 -0
- data/lib/mollie/balance.rb +53 -0
- data/lib/mollie/client.rb +2 -2
- data/lib/mollie/payment.rb +21 -3
- data/lib/mollie/version.rb +1 -1
- data/lib/mollie.rb +3 -0
- data/test/fixtures/balances/get.json +38 -0
- data/test/fixtures/balances/list.json +34 -0
- data/test/fixtures/balances/list_transactions.json +65 -0
- data/test/fixtures/balances/report.json +149 -0
- data/test/fixtures/payments/get_embedded_resources.json +126 -0
- data/test/mollie/balance/transaction_test.rb +36 -0
- data/test/mollie/balance_test.rb +108 -0
- data/test/mollie/payment_test.rb +32 -0
- metadata +25 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c69f3ca558a810762900aa7a74798129377ee91d41b136d5b32428085451d8f
|
4
|
+
data.tar.gz: cde2ea24aa5eeae5218d71af093b7081e9dbcdd5f94dd9b84bb7f9cef9d841de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f7c4a575b44e5ce96a8842fdb9c95f817f0beb0ab7150d221394a2b6c906921d538a8a398e6aab6f0569e772ef589fbdb6c75f51d6caa02ad9e95b6e313987
|
7
|
+
data.tar.gz: 27d0e5486b0e3c18f6e69eadc606aaaa75a32bd851780a3bebfbbd2f7952193743cfd3c2c7a133cd553292bfe561ca99727717bb710b62eba679d48576a8a49c
|
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.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
|
+
|
13
|
+
## 4.15.0 - 2024-12-01
|
14
|
+
|
15
|
+
- (f659c19) Add Balance API
|
16
|
+
|
7
17
|
## 4.14.0 - 2024-11-02
|
8
18
|
|
9
19
|
- (0876f2b) Add Payment Links API
|
@@ -0,0 +1 @@
|
|
1
|
+
primary_balance = Mollie::Balance.primary
|
@@ -0,0 +1 @@
|
|
1
|
+
balance = Mollie::Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH")
|
@@ -0,0 +1 @@
|
|
1
|
+
balances = Mollie::Balance.all
|
data/examples/payments/get.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Balance
|
3
|
+
class Report < Base
|
4
|
+
attr_accessor :balance_id,
|
5
|
+
:time_zone,
|
6
|
+
:grouping,
|
7
|
+
:totals,
|
8
|
+
:_links
|
9
|
+
|
10
|
+
attr_reader :from,
|
11
|
+
:until
|
12
|
+
|
13
|
+
alias links _links
|
14
|
+
|
15
|
+
def from=(from)
|
16
|
+
@from = Date.parse(from)
|
17
|
+
end
|
18
|
+
|
19
|
+
def until=(until_date)
|
20
|
+
# `until` is a reserved keyword
|
21
|
+
@until = Date.parse(until_date)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Balance
|
3
|
+
class Transaction < Base
|
4
|
+
attr_accessor :id,
|
5
|
+
:type,
|
6
|
+
:_links
|
7
|
+
|
8
|
+
attr_reader :result_amount,
|
9
|
+
:initial_amount,
|
10
|
+
:deductions,
|
11
|
+
:context,
|
12
|
+
:created_at
|
13
|
+
|
14
|
+
alias links _links
|
15
|
+
|
16
|
+
def self.embedded_resource_name
|
17
|
+
"balance_transactions"
|
18
|
+
end
|
19
|
+
|
20
|
+
def result_amount=(amount)
|
21
|
+
@result_amount = Mollie::Amount.new(amount)
|
22
|
+
end
|
23
|
+
|
24
|
+
def initial_amount=(amount)
|
25
|
+
@initial_amount = Mollie::Amount.new(amount)
|
26
|
+
end
|
27
|
+
|
28
|
+
def deductions=(amount)
|
29
|
+
@deductions = Mollie::Amount.new(amount)
|
30
|
+
end
|
31
|
+
|
32
|
+
def context=(context)
|
33
|
+
@context = OpenStruct.new(context) if context.is_a?(Hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
def created_at=(created_at)
|
37
|
+
@created_at = Time.parse(created_at.to_s)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Balance < Base
|
3
|
+
attr_accessor :id,
|
4
|
+
:mode,
|
5
|
+
:currency,
|
6
|
+
:description,
|
7
|
+
:status,
|
8
|
+
:transfer_frequency,
|
9
|
+
:transfer_reference,
|
10
|
+
:_links
|
11
|
+
|
12
|
+
attr_reader :transfer_threshold,
|
13
|
+
:transfer_destination,
|
14
|
+
:available_amount,
|
15
|
+
:pending_amount,
|
16
|
+
:created_at
|
17
|
+
|
18
|
+
alias links _links
|
19
|
+
|
20
|
+
def self.primary(options = {})
|
21
|
+
get('primary', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def transfer_threshold=(amount)
|
25
|
+
@transfer_threshold = Mollie::Amount.new(amount)
|
26
|
+
end
|
27
|
+
|
28
|
+
def transfer_destination=(transfer_destination)
|
29
|
+
@transfer_destination = OpenStruct.new(transfer_destination) if transfer_destination.is_a?(Hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
def available_amount=(amount)
|
33
|
+
@available_amount = Mollie::Amount.new(amount)
|
34
|
+
end
|
35
|
+
|
36
|
+
def pending_amount=(amount)
|
37
|
+
@pending_amount = Mollie::Amount.new(amount)
|
38
|
+
end
|
39
|
+
|
40
|
+
def created_at=(created_at)
|
41
|
+
@created_at = Time.parse(created_at.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def report(options = {})
|
45
|
+
response = Client.instance.perform_http_call("GET", "balances/#{id}", "report", {}, options)
|
46
|
+
Balance::Report.new(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
def transactions(options = {})
|
50
|
+
Balance::Transaction.all(options.merge(balance_id: id))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
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
|
|
data/lib/mollie/payment.rb
CHANGED
@@ -197,15 +197,33 @@ module Mollie
|
|
197
197
|
end
|
198
198
|
|
199
199
|
def refunds(options = {})
|
200
|
-
|
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
|
-
|
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
|
-
|
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 = {})
|
data/lib/mollie/version.rb
CHANGED
data/lib/mollie.rb
CHANGED
@@ -13,6 +13,7 @@ require 'mollie/version'
|
|
13
13
|
|
14
14
|
require 'mollie/base'
|
15
15
|
require 'mollie/amount'
|
16
|
+
require 'mollie/balance'
|
16
17
|
require 'mollie/chargeback'
|
17
18
|
require 'mollie/client'
|
18
19
|
require 'mollie/customer'
|
@@ -31,6 +32,8 @@ require 'mollie/settlement'
|
|
31
32
|
require 'mollie/subscription'
|
32
33
|
require 'mollie/terminal'
|
33
34
|
|
35
|
+
require 'mollie/balance/report'
|
36
|
+
require 'mollie/balance/transaction'
|
34
37
|
require 'mollie/customer/mandate'
|
35
38
|
require 'mollie/customer/payment'
|
36
39
|
require 'mollie/customer/subscription'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"resource": "balance",
|
3
|
+
"id": "bal_gVMhHKqSSRYJyPsuoPNFH",
|
4
|
+
"mode": "live",
|
5
|
+
"currency": "EUR",
|
6
|
+
"description": "Primary balance",
|
7
|
+
"availableAmount": {
|
8
|
+
"currency": "EUR",
|
9
|
+
"value": "905.25"
|
10
|
+
},
|
11
|
+
"pendingAmount": {
|
12
|
+
"currency": "EUR",
|
13
|
+
"value": "0.00"
|
14
|
+
},
|
15
|
+
"transferFrequency": "twice-a-month",
|
16
|
+
"transferThreshold": {
|
17
|
+
"currency": "EUR",
|
18
|
+
"value": "5.00"
|
19
|
+
},
|
20
|
+
"transferReference": "Mollie settlement",
|
21
|
+
"transferDestination": {
|
22
|
+
"type": "bank-account",
|
23
|
+
"beneficiaryName": "John Doe",
|
24
|
+
"bankAccount": "NL55INGB0000000000"
|
25
|
+
},
|
26
|
+
"status": "active",
|
27
|
+
"createdAt": "2019-01-10T12:06:28+00:00",
|
28
|
+
"_links": {
|
29
|
+
"self": {
|
30
|
+
"href": "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH",
|
31
|
+
"type": "application/hal+json"
|
32
|
+
},
|
33
|
+
"documentation": {
|
34
|
+
"href": "https://docs.mollie.com/reference/get-balance",
|
35
|
+
"type": "text/html"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"count": 1,
|
3
|
+
"_embedded": {
|
4
|
+
"balances": [
|
5
|
+
{
|
6
|
+
"resource": "balance",
|
7
|
+
"id": "bal_one"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"resource": "balance",
|
11
|
+
"id": "bal_two"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"resource": "balance",
|
15
|
+
"id": "bal_three"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
},
|
19
|
+
"_links": {
|
20
|
+
"documentation": {
|
21
|
+
"href": "https://docs.mollie.com/reference/v2/balances-api/list-balances",
|
22
|
+
"type": "text/html"
|
23
|
+
},
|
24
|
+
"self": {
|
25
|
+
"href": "https://api.mollie.com/v2/balances?limit=5",
|
26
|
+
"type": "application/hal+json"
|
27
|
+
},
|
28
|
+
"previous": null,
|
29
|
+
"next": {
|
30
|
+
"href": "https://api.mollie.com/v2/balances?from=bal_gVMhHKqSSRYJyPsuoPABC&limit=5",
|
31
|
+
"type": "application/hal+json"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
{
|
2
|
+
"count": 2,
|
3
|
+
"_embedded": {
|
4
|
+
"balance_transactions": [
|
5
|
+
{
|
6
|
+
"resource": "balance_transaction",
|
7
|
+
"id": "baltr_QM24QwzUWR4ev4Xfgyt29A",
|
8
|
+
"type": "refund",
|
9
|
+
"resultAmount": {
|
10
|
+
"currency": "EUR",
|
11
|
+
"value": "-10.25"
|
12
|
+
},
|
13
|
+
"initialAmount": {
|
14
|
+
"currency": "EUR",
|
15
|
+
"value": "-10.00"
|
16
|
+
},
|
17
|
+
"deductions": {
|
18
|
+
"currency": "EUR",
|
19
|
+
"value": "-0.25"
|
20
|
+
},
|
21
|
+
"context": {
|
22
|
+
"paymentId": "tr_7UhSN1zuXS",
|
23
|
+
"refundId": "re_4qqhO89gsT"
|
24
|
+
},
|
25
|
+
"createdAt": "2021-01-10T12:06:28+00:00"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"resource": "balance_transaction",
|
29
|
+
"id": "baltr_WhmDwNYR87FPDbiwBhUXCh",
|
30
|
+
"type": "payment",
|
31
|
+
"resultAmount": {
|
32
|
+
"currency": "EUR",
|
33
|
+
"value": "9.71"
|
34
|
+
},
|
35
|
+
"initialAmount": {
|
36
|
+
"currency": "EUR",
|
37
|
+
"value": "10.00"
|
38
|
+
},
|
39
|
+
"deductions": {
|
40
|
+
"currency": "EUR",
|
41
|
+
"value": "-0.29"
|
42
|
+
},
|
43
|
+
"context": {
|
44
|
+
"paymentId": "tr_7UhSN1zuXS"
|
45
|
+
},
|
46
|
+
"createdAt": "2021-01-10T12:06:28+00:00"
|
47
|
+
}
|
48
|
+
]
|
49
|
+
},
|
50
|
+
"_links": {
|
51
|
+
"self": {
|
52
|
+
"href": "...",
|
53
|
+
"type": "application/hal+json"
|
54
|
+
},
|
55
|
+
"previous": null,
|
56
|
+
"next": {
|
57
|
+
"href": "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/transactions?from=baltr_rXeW2yPqqDUyfAqq8fS5Bg&limit=5",
|
58
|
+
"type": "application/hal+json"
|
59
|
+
},
|
60
|
+
"documentation": {
|
61
|
+
"href": "...",
|
62
|
+
"type": "text/html"
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
@@ -0,0 +1,149 @@
|
|
1
|
+
{
|
2
|
+
"resource": "balance-report",
|
3
|
+
"balanceId": "bal_gVMhHKqSSRYJyPsuoPNFH",
|
4
|
+
"timeZone": "Europe/Amsterdam",
|
5
|
+
"from": "2024-01-01",
|
6
|
+
"until": "2024-01-31",
|
7
|
+
"grouping": "transaction-categories",
|
8
|
+
"totals": {
|
9
|
+
"open": {
|
10
|
+
"available": {
|
11
|
+
"amount": {
|
12
|
+
"currency": "EUR",
|
13
|
+
"value": "0.00"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"pending": {
|
17
|
+
"amount": {
|
18
|
+
"currency": "EUR",
|
19
|
+
"value": "0.00"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"payments": {
|
24
|
+
"immediatelyAvailable": {
|
25
|
+
"amount": {
|
26
|
+
"currency": "EUR",
|
27
|
+
"value": "0.00"
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"pending": {
|
31
|
+
"amount": {
|
32
|
+
"currency": "EUR",
|
33
|
+
"value": "4.98"
|
34
|
+
},
|
35
|
+
"subtotals": [
|
36
|
+
{
|
37
|
+
"transactionType": "payment",
|
38
|
+
"count": 1,
|
39
|
+
"amount": {
|
40
|
+
"currency": "EUR",
|
41
|
+
"value": "4.98"
|
42
|
+
},
|
43
|
+
"subtotals": [
|
44
|
+
{
|
45
|
+
"method": "ideal",
|
46
|
+
"count": 1,
|
47
|
+
"amount": {
|
48
|
+
"currency": "EUR",
|
49
|
+
"value": "4.98"
|
50
|
+
}
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
]
|
55
|
+
},
|
56
|
+
"movedToAvailable": {
|
57
|
+
"amount": {
|
58
|
+
"currency": "EUR",
|
59
|
+
"value": "0.00"
|
60
|
+
}
|
61
|
+
}
|
62
|
+
},
|
63
|
+
"refunds": {},
|
64
|
+
"capital": {},
|
65
|
+
"chargebacks": {},
|
66
|
+
"transfers": {},
|
67
|
+
"fee-prepayments": {
|
68
|
+
"immediatelyAvailable": {
|
69
|
+
"amount": {
|
70
|
+
"currency": "EUR",
|
71
|
+
"value": "0.00"
|
72
|
+
}
|
73
|
+
},
|
74
|
+
"movedToAvailable": {
|
75
|
+
"amount": {
|
76
|
+
"currency": "EUR",
|
77
|
+
"value": "-0.36"
|
78
|
+
},
|
79
|
+
"subtotals": [
|
80
|
+
{
|
81
|
+
"prepaymentPartType": "fee",
|
82
|
+
"count": 1,
|
83
|
+
"amount": {
|
84
|
+
"currency": "EUR",
|
85
|
+
"value": "-0.29"
|
86
|
+
},
|
87
|
+
"subtotals": [
|
88
|
+
{
|
89
|
+
"feeType": "payment-fee",
|
90
|
+
"method": "ideal",
|
91
|
+
"count": 1,
|
92
|
+
"amount": {
|
93
|
+
"currency": "EUR",
|
94
|
+
"value": "-0.29"
|
95
|
+
}
|
96
|
+
}
|
97
|
+
]
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"prepaymentPartType": "fee-vat",
|
101
|
+
"amount": {
|
102
|
+
"currency": "EUR",
|
103
|
+
"value": "-0.0609"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"prepaymentPartType": "fee-rounding-compensation",
|
108
|
+
"amount": {
|
109
|
+
"currency": "EUR",
|
110
|
+
"value": "-0.0091"
|
111
|
+
}
|
112
|
+
}
|
113
|
+
]
|
114
|
+
},
|
115
|
+
"pending": {
|
116
|
+
"amount": {
|
117
|
+
"currency": "EUR",
|
118
|
+
"value": "-0.36"
|
119
|
+
},
|
120
|
+
"subtotals": []
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"corrections": {},
|
124
|
+
"close": {
|
125
|
+
"available": {
|
126
|
+
"amount": {
|
127
|
+
"currency": "EUR",
|
128
|
+
"value": "0.00"
|
129
|
+
}
|
130
|
+
},
|
131
|
+
"pending": {
|
132
|
+
"amount": {
|
133
|
+
"currency": "EUR",
|
134
|
+
"value": "4.32"
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
},
|
139
|
+
"_links": {
|
140
|
+
"self": {
|
141
|
+
"href": "...",
|
142
|
+
"type": "application/hal+json"
|
143
|
+
},
|
144
|
+
"documentation": {
|
145
|
+
"href": "...",
|
146
|
+
"type": "text/html"
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
@@ -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
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class Balance
|
5
|
+
class TransactionTest < Test::Unit::TestCase
|
6
|
+
def test_setting_attributes
|
7
|
+
attributes = {
|
8
|
+
id: "baltr_QM24QwzUWR4ev4Xfgyt29A",
|
9
|
+
type: "refund",
|
10
|
+
result_amount: { "value" => "-10.25", "currency" => "EUR" },
|
11
|
+
initial_amount: { "value" => "-10.00", "currency" => "EUR" },
|
12
|
+
deductions: { "value" => "0.25", "currency" => "EUR" },
|
13
|
+
context: {
|
14
|
+
"paymentId" => "tr_7UhSN1zuXS",
|
15
|
+
"refundId" => "re_4qqhO89gsT"
|
16
|
+
},
|
17
|
+
created_at: "2021-01-10T12:06:28+00:00"
|
18
|
+
}
|
19
|
+
|
20
|
+
balance = Balance::Transaction.new(attributes)
|
21
|
+
|
22
|
+
assert_equal "baltr_QM24QwzUWR4ev4Xfgyt29A", balance.id
|
23
|
+
assert_equal "refund", balance.type
|
24
|
+
assert_equal BigDecimal("-10.25"), balance.result_amount.value
|
25
|
+
assert_equal "EUR", balance.result_amount.currency
|
26
|
+
assert_equal BigDecimal("-10.00"), balance.initial_amount.value
|
27
|
+
assert_equal "EUR", balance.initial_amount.currency
|
28
|
+
assert_equal BigDecimal("0.25"), balance.deductions.value
|
29
|
+
assert_equal "EUR", balance.deductions.currency
|
30
|
+
assert_equal "tr_7UhSN1zuXS", balance.context.paymentId
|
31
|
+
assert_equal "re_4qqhO89gsT", balance.context.refundId
|
32
|
+
assert_equal Time.parse("2021-01-10T12:06:28+00:00"), balance.created_at
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class BalanceTest < Test::Unit::TestCase
|
5
|
+
GET_BALANCE = read_fixture('balances/get.json')
|
6
|
+
GET_BALANCE_REPORT = read_fixture('balances/report.json')
|
7
|
+
LIST_BALANCES = read_fixture('balances/list.json')
|
8
|
+
LIST_BALANCE_TRANSACTIONS = read_fixture('balances/list_transactions.json')
|
9
|
+
|
10
|
+
def test_setting_attributes
|
11
|
+
attributes = {
|
12
|
+
id: "bal_gVMhHKqSSRYJyPsuoPNFH",
|
13
|
+
mode: "live",
|
14
|
+
currency: "EUR",
|
15
|
+
description: "Primary balance",
|
16
|
+
available_amount: { "value" => "0.00", "currency" => "EUR" },
|
17
|
+
pending_amount: { "value" => "0.00", "currency" => "EUR" },
|
18
|
+
transfer_frequency: "twice-a-month",
|
19
|
+
transfer_threshold: { "value" => "5.00", "currency" => "EUR" },
|
20
|
+
transfer_reference: "Mollie settlement",
|
21
|
+
transfer_destination: {
|
22
|
+
type: "bank-account",
|
23
|
+
beneficiary_name: "John Doe",
|
24
|
+
bank_account: "NL55INGB0000000000"
|
25
|
+
},
|
26
|
+
status: "active",
|
27
|
+
created_at: "2018-03-20T09:13:37+00:00",
|
28
|
+
}
|
29
|
+
|
30
|
+
balance = Mollie::Balance.new(attributes)
|
31
|
+
|
32
|
+
assert_equal "bal_gVMhHKqSSRYJyPsuoPNFH", balance.id
|
33
|
+
assert_equal "live", balance.mode
|
34
|
+
assert_equal "EUR", balance.currency
|
35
|
+
assert_equal "Primary balance", balance.description
|
36
|
+
assert_equal BigDecimal("0.00"), balance.available_amount.value
|
37
|
+
assert_equal "EUR", balance.available_amount.currency
|
38
|
+
assert_equal BigDecimal("0.00"), balance.pending_amount.value
|
39
|
+
assert_equal "EUR", balance.pending_amount.currency
|
40
|
+
assert_equal "twice-a-month", balance.transfer_frequency
|
41
|
+
assert_equal BigDecimal("5.00"), balance.transfer_threshold.value
|
42
|
+
assert_equal "EUR", balance.transfer_threshold.currency
|
43
|
+
assert_equal "Mollie settlement", balance.transfer_reference
|
44
|
+
assert_equal "bank-account", balance.transfer_destination.type
|
45
|
+
assert_equal "John Doe", balance.transfer_destination.beneficiary_name
|
46
|
+
assert_equal "NL55INGB0000000000", balance.transfer_destination.bank_account
|
47
|
+
assert_equal "active", balance.status
|
48
|
+
assert_equal Time.parse('2018-03-20T09:13:37+00:00'), balance.created_at
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_get_balance
|
52
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH")
|
53
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
54
|
+
|
55
|
+
balance = Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH")
|
56
|
+
assert_equal "bal_gVMhHKqSSRYJyPsuoPNFH", balance.id
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_list_balances
|
60
|
+
stub_request(:get, 'https://api.mollie.com/v2/balances')
|
61
|
+
.to_return(status: 200, body: LIST_BALANCES, headers: {})
|
62
|
+
|
63
|
+
balances = Balance.all
|
64
|
+
assert_equal 3, balances.size
|
65
|
+
assert_equal 'bal_one', balances[0].id
|
66
|
+
assert_equal 'bal_two', balances[1].id
|
67
|
+
assert_equal 'bal_three', balances[2].id
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_primary
|
71
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/primary")
|
72
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
73
|
+
|
74
|
+
balance = Balance.primary
|
75
|
+
assert_equal "bal_gVMhHKqSSRYJyPsuoPNFH", balance.id
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_report
|
79
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH")
|
80
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
81
|
+
|
82
|
+
stub_request(:get, 'https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/report')
|
83
|
+
.to_return(status: 200, body: GET_BALANCE_REPORT, headers: {})
|
84
|
+
|
85
|
+
report = Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH").report
|
86
|
+
|
87
|
+
assert_equal Date.parse("2024-01-01"), report.from
|
88
|
+
assert_equal Date.parse("2024-01-31"), report.until
|
89
|
+
assert_equal "transaction-categories", report.grouping
|
90
|
+
assert_equal "4.98", report.totals.dig("payments", "pending", "amount", "value")
|
91
|
+
assert_equal "-0.36", report.totals.dig("fee_prepayments", "moved_to_available", "amount", "value")
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_list_transactions
|
95
|
+
stub_request(:get, "https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH")
|
96
|
+
.to_return(status: 200, body: GET_BALANCE, headers: {})
|
97
|
+
|
98
|
+
stub_request(:get, 'https://api.mollie.com/v2/balances/bal_gVMhHKqSSRYJyPsuoPNFH/transactions')
|
99
|
+
.to_return(status: 200, body: LIST_BALANCE_TRANSACTIONS, headers: {})
|
100
|
+
|
101
|
+
transactions = Balance.get("bal_gVMhHKqSSRYJyPsuoPNFH").transactions
|
102
|
+
assert_equal 2, transactions.size
|
103
|
+
|
104
|
+
assert_equal "baltr_QM24QwzUWR4ev4Xfgyt29A", transactions[0].id
|
105
|
+
assert_equal "baltr_WhmDwNYR87FPDbiwBhUXCh", transactions[1].id
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
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',
|
@@ -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.
|
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:
|
10
|
+
date: 2025-03-19 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: ostruct
|
@@ -129,6 +128,11 @@ files:
|
|
129
128
|
- bin/setup
|
130
129
|
- docs/migration_v2_2_x.md
|
131
130
|
- docs/migration_v3_x.md
|
131
|
+
- examples/balances/get-primary.rb
|
132
|
+
- examples/balances/get-report.rb
|
133
|
+
- examples/balances/get.rb
|
134
|
+
- examples/balances/list-transactions.rb
|
135
|
+
- examples/balances/list.rb
|
132
136
|
- examples/captures/get-payment.rb
|
133
137
|
- examples/captures/get-settlement.rb
|
134
138
|
- examples/captures/get-shipment.rb
|
@@ -226,6 +230,9 @@ files:
|
|
226
230
|
- lib/mollie-api-ruby.rb
|
227
231
|
- lib/mollie.rb
|
228
232
|
- lib/mollie/amount.rb
|
233
|
+
- lib/mollie/balance.rb
|
234
|
+
- lib/mollie/balance/report.rb
|
235
|
+
- lib/mollie/balance/transaction.rb
|
229
236
|
- lib/mollie/base.rb
|
230
237
|
- lib/mollie/chargeback.rb
|
231
238
|
- lib/mollie/client.rb
|
@@ -263,6 +270,10 @@ files:
|
|
263
270
|
- lib/mollie/util.rb
|
264
271
|
- lib/mollie/version.rb
|
265
272
|
- mollie-api-ruby.gemspec
|
273
|
+
- test/fixtures/balances/get.json
|
274
|
+
- test/fixtures/balances/list.json
|
275
|
+
- test/fixtures/balances/list_transactions.json
|
276
|
+
- test/fixtures/balances/report.json
|
266
277
|
- test/fixtures/captures/get.json
|
267
278
|
- test/fixtures/captures/list.json
|
268
279
|
- test/fixtures/customer/get.json
|
@@ -292,6 +303,7 @@ files:
|
|
292
303
|
- test/fixtures/payment_links/list.json
|
293
304
|
- test/fixtures/payment_links/update.json
|
294
305
|
- test/fixtures/payments/get.json
|
306
|
+
- test/fixtures/payments/get_embedded_resources.json
|
295
307
|
- test/fixtures/refunds/get.json
|
296
308
|
- test/fixtures/shipments/create.json
|
297
309
|
- test/fixtures/shipments/get.json
|
@@ -303,6 +315,8 @@ files:
|
|
303
315
|
- test/fixtures/terminals/list.json
|
304
316
|
- test/helper.rb
|
305
317
|
- test/mollie/amount_test.rb
|
318
|
+
- test/mollie/balance/transaction_test.rb
|
319
|
+
- test/mollie/balance_test.rb
|
306
320
|
- test/mollie/base_test.rb
|
307
321
|
- test/mollie/chargeback_test.rb
|
308
322
|
- test/mollie/client_test.rb
|
@@ -341,7 +355,6 @@ licenses:
|
|
341
355
|
- BSD
|
342
356
|
metadata:
|
343
357
|
changelog_uri: https://github.com/mollie/mollie-api-ruby/blob/master/CHANGELOG.md
|
344
|
-
post_install_message:
|
345
358
|
rdoc_options: []
|
346
359
|
require_paths:
|
347
360
|
- lib
|
@@ -356,11 +369,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
369
|
- !ruby/object:Gem::Version
|
357
370
|
version: '0'
|
358
371
|
requirements: []
|
359
|
-
rubygems_version: 3.
|
360
|
-
signing_key:
|
372
|
+
rubygems_version: 3.6.2
|
361
373
|
specification_version: 4
|
362
374
|
summary: Official Mollie API Client for Ruby
|
363
375
|
test_files:
|
376
|
+
- test/fixtures/balances/get.json
|
377
|
+
- test/fixtures/balances/list.json
|
378
|
+
- test/fixtures/balances/list_transactions.json
|
379
|
+
- test/fixtures/balances/report.json
|
364
380
|
- test/fixtures/captures/get.json
|
365
381
|
- test/fixtures/captures/list.json
|
366
382
|
- test/fixtures/customer/get.json
|
@@ -390,6 +406,7 @@ test_files:
|
|
390
406
|
- test/fixtures/payment_links/list.json
|
391
407
|
- test/fixtures/payment_links/update.json
|
392
408
|
- test/fixtures/payments/get.json
|
409
|
+
- test/fixtures/payments/get_embedded_resources.json
|
393
410
|
- test/fixtures/refunds/get.json
|
394
411
|
- test/fixtures/shipments/create.json
|
395
412
|
- test/fixtures/shipments/get.json
|
@@ -401,6 +418,8 @@ test_files:
|
|
401
418
|
- test/fixtures/terminals/list.json
|
402
419
|
- test/helper.rb
|
403
420
|
- test/mollie/amount_test.rb
|
421
|
+
- test/mollie/balance/transaction_test.rb
|
422
|
+
- test/mollie/balance_test.rb
|
404
423
|
- test/mollie/base_test.rb
|
405
424
|
- test/mollie/chargeback_test.rb
|
406
425
|
- test/mollie/client_test.rb
|