mollie-api-ruby 2.2.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +7 -0
- data/README.md +37 -8
- data/examples/apis/api_docs.rb +1 -1
- data/examples/apis/chargebacks.rb +17 -0
- data/examples/apis/connect.rb +1 -1
- data/examples/apis/customers.rb +7 -6
- data/examples/apis/invoices.rb +2 -2
- data/examples/apis/issuers.rb +2 -2
- data/examples/apis/mandates.rb +5 -5
- data/examples/apis/methods.rb +2 -2
- data/examples/apis/organizations.rb +1 -1
- data/examples/apis/payments.rb +43 -9
- data/examples/apis/permissions.rb +2 -2
- data/examples/apis/profiles.rb +7 -7
- data/examples/apis/refunds.rb +1 -1
- data/examples/apis/settlements.rb +5 -5
- data/examples/apis/subscriptions.rb +7 -7
- data/examples/config.ru +6 -7
- data/lib/{mollie/api/cacert.pem → cacert.pem} +0 -0
- data/lib/mollie-api-ruby.rb +1 -0
- data/lib/mollie.rb +39 -0
- data/lib/mollie/base.rb +91 -0
- data/lib/mollie/chargeback.rb +36 -0
- data/lib/mollie/client.rb +125 -0
- data/lib/mollie/customer.rb +36 -0
- data/lib/mollie/customer/mandate.rb +33 -0
- data/lib/mollie/customer/payment.rb +6 -0
- data/lib/mollie/customer/subscription.rb +65 -0
- data/lib/mollie/exception.rb +8 -0
- data/lib/mollie/invoice.rb +66 -0
- data/lib/mollie/issuer.rb +5 -0
- data/lib/mollie/list.rb +40 -0
- data/lib/mollie/method.rb +38 -0
- data/lib/mollie/organization.rb +24 -0
- data/lib/mollie/payment.rb +142 -0
- data/lib/mollie/payment/chargeback.rb +6 -0
- data/lib/mollie/payment/refund.rb +6 -0
- data/lib/mollie/permission.rb +26 -0
- data/lib/mollie/profile.rb +78 -0
- data/lib/mollie/profile/api_key.rb +19 -0
- data/lib/mollie/refund.rb +42 -0
- data/lib/mollie/relation.rb +36 -0
- data/lib/mollie/settlement.rb +36 -0
- data/lib/mollie/settlement/chargeback.rb +6 -0
- data/lib/mollie/settlement/payment.rb +6 -0
- data/lib/mollie/settlement/refund.rb +6 -0
- data/lib/mollie/util.rb +57 -0
- data/lib/mollie/version.rb +3 -0
- data/mollie.gemspec +2 -2
- data/test/helper.rb +5 -1
- data/test/mollie/base_test.rb +182 -0
- data/test/mollie/chargeback_test.rb +35 -0
- data/test/mollie/client_test.rb +122 -0
- data/test/mollie/customer/mandate_test.rb +43 -0
- data/test/mollie/customer/payment_test.rb +23 -0
- data/test/mollie/customer/subscription_test.rb +66 -0
- data/test/mollie/customer_test.rb +128 -0
- data/test/mollie/invoice_test.rb +55 -0
- data/test/mollie/issuer_test.rb +19 -0
- data/test/mollie/list_test.rb +40 -0
- data/test/mollie/method_test.rb +29 -0
- data/test/mollie/organization_test.rb +41 -0
- data/test/mollie/payment/chargeback_test.rb +22 -0
- data/test/mollie/payment/refund_test.rb +22 -0
- data/test/mollie/payment_test.rb +161 -0
- data/test/mollie/permission_test.rb +21 -0
- data/test/mollie/profile/apikey_test.rb +31 -0
- data/test/mollie/profile_test.rb +98 -0
- data/test/mollie/refund_test.rb +40 -0
- data/test/mollie/settlement/chargeback_test.rb +22 -0
- data/test/mollie/settlement/payment_test.rb +22 -0
- data/test/mollie/settlement/refund_test.rb +22 -0
- data/test/mollie/settlement_test.rb +156 -0
- data/website-docs/chargebacks/list-all.rb +12 -0
- data/website-docs/connect/authorize.rb +15 -0
- data/website-docs/connect/tokens.rb +14 -0
- data/website-docs/customers/create-payment.rb +13 -0
- data/website-docs/customers/create.rb +12 -0
- data/website-docs/customers/delete.rb +10 -0
- data/website-docs/customers/get.rb +10 -0
- data/website-docs/customers/list-payments.rb +10 -0
- data/website-docs/customers/list.rb +12 -0
- data/website-docs/customers/update.rb +11 -0
- data/website-docs/invoices/get.rb +10 -0
- data/website-docs/invoices/list.rb +12 -0
- data/website-docs/issuers/get.rb +10 -0
- data/website-docs/issuers/list.rb +12 -0
- data/website-docs/mandates/create.rb +16 -0
- data/website-docs/mandates/delete.rb +10 -0
- data/website-docs/mandates/get.rb +10 -0
- data/website-docs/mandates/list.rb +12 -0
- data/website-docs/methods/get.rb +10 -0
- data/website-docs/methods/list.rb +12 -0
- data/website-docs/organisations/get.rb +10 -0
- data/website-docs/payments/create-refund.rb +14 -0
- data/website-docs/payments/create.rb +16 -0
- data/website-docs/payments/delete-refund.rb +13 -0
- data/website-docs/payments/delete.rb +12 -0
- data/website-docs/payments/get-chargeback.rb +11 -0
- data/website-docs/payments/get-refund.rb +11 -0
- data/website-docs/payments/get.rb +10 -0
- data/website-docs/payments/list-chargeback.rb +13 -0
- data/website-docs/payments/list-refunds.rb +13 -0
- data/website-docs/payments/list.rb +12 -0
- data/website-docs/payments/payment-webhook.rb +21 -0
- data/website-docs/permissions/get.rb +10 -0
- data/website-docs/permissions/list.rb +12 -0
- data/website-docs/profiles/create.rb +15 -0
- data/website-docs/profiles/delete.rb +10 -0
- data/website-docs/profiles/get-key.rb +11 -0
- data/website-docs/profiles/get.rb +10 -0
- data/website-docs/profiles/list-keys.rb +13 -0
- data/website-docs/profiles/list.rb +12 -0
- data/website-docs/profiles/reset-key.rb +13 -0
- data/website-docs/profiles/update.rb +12 -0
- data/website-docs/refunds/list.rb +12 -0
- data/website-docs/settlements/get.rb +10 -0
- data/website-docs/settlements/list-chargebacks.rb +13 -0
- data/website-docs/settlements/list-payments.rb +13 -0
- data/website-docs/settlements/list-refunds.rb +13 -0
- data/website-docs/settlements/list.rb +12 -0
- data/website-docs/settlements/next.rb +9 -0
- data/website-docs/settlements/open.rb +9 -0
- data/website-docs/subscriptions/create.rb +14 -0
- data/website-docs/subscriptions/delete.rb +10 -0
- data/website-docs/subscriptions/get.rb +10 -0
- data/website-docs/subscriptions/list.rb +12 -0
- metadata +134 -104
- data/lib/mollie/api/client.rb +0 -161
- data/lib/mollie/api/client/version.rb +0 -7
- data/lib/mollie/api/exception.rb +0 -10
- data/lib/mollie/api/object/base.rb +0 -18
- data/lib/mollie/api/object/customer.rb +0 -28
- data/lib/mollie/api/object/customer/mandate.rb +0 -37
- data/lib/mollie/api/object/customer/subscription.rb +0 -69
- data/lib/mollie/api/object/invoice.rb +0 -70
- data/lib/mollie/api/object/issuer.rb +0 -9
- data/lib/mollie/api/object/list.rb +0 -44
- data/lib/mollie/api/object/method.rb +0 -42
- data/lib/mollie/api/object/organization.rb +0 -28
- data/lib/mollie/api/object/payment.rb +0 -137
- data/lib/mollie/api/object/payment/refund.rb +0 -47
- data/lib/mollie/api/object/permission.rb +0 -12
- data/lib/mollie/api/object/profile.rb +0 -78
- data/lib/mollie/api/object/profile/apikey.rb +0 -23
- data/lib/mollie/api/object/settlement.rb +0 -32
- data/lib/mollie/api/resource/base.rb +0 -53
- data/lib/mollie/api/resource/customers.rb +0 -11
- data/lib/mollie/api/resource/customers/mandates.rb +0 -27
- data/lib/mollie/api/resource/customers/payments.rb +0 -27
- data/lib/mollie/api/resource/customers/subscriptions.rb +0 -27
- data/lib/mollie/api/resource/invoices.rb +0 -11
- data/lib/mollie/api/resource/issuers.rb +0 -11
- data/lib/mollie/api/resource/methods.rb +0 -11
- data/lib/mollie/api/resource/organizations.rb +0 -11
- data/lib/mollie/api/resource/payments.rb +0 -11
- data/lib/mollie/api/resource/payments/refunds.rb +0 -27
- data/lib/mollie/api/resource/permissions.rb +0 -31
- data/lib/mollie/api/resource/profiles.rb +0 -11
- data/lib/mollie/api/resource/profiles/apikeys.rb +0 -33
- data/lib/mollie/api/resource/refunds.rb +0 -11
- data/lib/mollie/api/resource/settlements.rb +0 -19
- data/lib/mollie/api/resource/settlements/payments.rb +0 -27
- data/lib/mollie/api/util.rb +0 -53
- data/test/mollie/api/client_test.rb +0 -111
- data/test/mollie/api/object/base_test.rb +0 -21
- data/test/mollie/api/object/customer/mandate_test.rb +0 -47
- data/test/mollie/api/object/customer/subscription_test.rb +0 -70
- data/test/mollie/api/object/customer_test.rb +0 -35
- data/test/mollie/api/object/invoice_test.rb +0 -59
- data/test/mollie/api/object/issuer_test.rb +0 -23
- data/test/mollie/api/object/list_test.rb +0 -44
- data/test/mollie/api/object/method_test.rb +0 -33
- data/test/mollie/api/object/organization_test.rb +0 -45
- data/test/mollie/api/object/payment/refund_test.rb +0 -46
- data/test/mollie/api/object/payment_test.rb +0 -106
- data/test/mollie/api/object/permission_test.rb +0 -25
- data/test/mollie/api/object/profile/apikey_test.rb +0 -35
- data/test/mollie/api/object/profile_test.rb +0 -72
- data/test/mollie/api/object/settlement_test.rb +0 -140
- data/test/mollie/api/resource/base_test.rb +0 -83
- data/test/mollie/api/resource/customers/mandates_test.rb +0 -23
- data/test/mollie/api/resource/customers/payments_test.rb +0 -23
- data/test/mollie/api/resource/customers/subscriptions_test.rb +0 -23
- data/test/mollie/api/resource/customers_test.rb +0 -13
- data/test/mollie/api/resource/invoices_test.rb +0 -13
- data/test/mollie/api/resource/issuers_test.rb +0 -13
- data/test/mollie/api/resource/methods_test.rb +0 -13
- data/test/mollie/api/resource/organizations_test.rb +0 -13
- data/test/mollie/api/resource/payments/refunds_test.rb +0 -23
- data/test/mollie/api/resource/payments_test.rb +0 -13
- data/test/mollie/api/resource/permissions_test.rb +0 -13
- data/test/mollie/api/resource/profiles/apikeys_test.rb +0 -23
- data/test/mollie/api/resource/profiles_test.rb +0 -13
- data/test/mollie/api/resource/settlements_test.rb +0 -13
- data/test/mollie/api/util_test.rb +0 -47
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class RefundTest < Test::Unit::TestCase
|
5
|
+
def test_setting_attributes
|
6
|
+
attributes = {
|
7
|
+
id: "re_4qqhO89gsT",
|
8
|
+
payment: {
|
9
|
+
id: "tr_WDqYK6vllg",
|
10
|
+
},
|
11
|
+
amount: "5.95",
|
12
|
+
refunded_datetime: "2016-10-08T07:59:53.0Z",
|
13
|
+
status: "pending"
|
14
|
+
}
|
15
|
+
|
16
|
+
refund = Refund.new(attributes)
|
17
|
+
|
18
|
+
assert_equal "re_4qqhO89gsT", refund.id
|
19
|
+
assert_equal BigDecimal.new("5.95"), refund.amount
|
20
|
+
assert_kind_of Payment, refund.payment
|
21
|
+
assert_equal Time.parse("2016-10-08T07:59:53.0Z"), refund.refunded_datetime
|
22
|
+
assert_equal Refund::STATUS_PENDING, refund.status
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_pending?
|
26
|
+
assert Refund.new(status: Refund::STATUS_PENDING).pending?
|
27
|
+
assert !Refund.new(status: 'not-pending').pending?
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_processing?
|
31
|
+
assert Refund.new(status: Refund::STATUS_PROCESSING).processing?
|
32
|
+
assert !Refund.new(status: 'not-processing').processing?
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_refunded?
|
36
|
+
assert Refund.new(status: Refund::STATUS_REFUNDED).refunded?
|
37
|
+
assert !Refund.new(status: 'not-refunded').refunded?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class Settlement
|
5
|
+
class ChargebackTest < Test::Unit::TestCase
|
6
|
+
def test_kind_of_chargeback
|
7
|
+
chargeback = Mollie::Settlement::Chargeback.new({})
|
8
|
+
assert_kind_of Mollie::Chargeback, chargeback
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list_chargebacks
|
12
|
+
stub_request(:get, "https://api.mollie.nl/v1/settlements/set-id/chargebacks?count=50&offset=0")
|
13
|
+
.to_return(:status => 200, :body => %{{"data" : [{"id":"chg-id", "settlement_id":"set-id"}]}}, :headers => {})
|
14
|
+
|
15
|
+
chargebacks = Chargeback.all(settlement_id: "set-id")
|
16
|
+
|
17
|
+
assert_equal "chg-id", chargebacks.first.id
|
18
|
+
assert_equal "set-id", chargebacks.first.settlement_id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class Settlement
|
5
|
+
class PaymentTest < Test::Unit::TestCase
|
6
|
+
def test_kind_of_payment
|
7
|
+
payment = Mollie::Settlement::Payment.new({})
|
8
|
+
assert_kind_of Mollie::Payment, payment
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list_payments
|
12
|
+
stub_request(:get, "https://api.mollie.nl/v1/settlements/set-id/payments?count=50&offset=0")
|
13
|
+
.to_return(:status => 200, :body => %{{"data" : [{"id":"pay-id", "settlement_id":"set-id"}]}}, :headers => {})
|
14
|
+
|
15
|
+
payments = Payment.all(settlement_id: "set-id")
|
16
|
+
|
17
|
+
assert_equal "pay-id", payments.first.id
|
18
|
+
assert_equal "set-id", payments.first.settlement_id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class Settlement
|
5
|
+
class RefundTest < Test::Unit::TestCase
|
6
|
+
def test_kind_of_refund
|
7
|
+
refund = Mollie::Settlement::Refund.new({})
|
8
|
+
assert_kind_of Mollie::Refund, refund
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list_refunds
|
12
|
+
stub_request(:get, "https://api.mollie.nl/v1/settlements/set-id/refunds?count=50&offset=0")
|
13
|
+
.to_return(:status => 200, :body => %{{"data" : [{"id":"re-id", "payment": {"id":"pay-id"}}]}}, :headers => {})
|
14
|
+
|
15
|
+
refunds = Mollie::Settlement::Refund.all(settlement_id: "set-id")
|
16
|
+
|
17
|
+
assert_equal "re-id", refunds.first.id
|
18
|
+
assert_equal "pay-id", refunds.first.payment.id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Mollie
|
4
|
+
class SettlementTest < Test::Unit::TestCase
|
5
|
+
def test_setting_attributes
|
6
|
+
attributes = {
|
7
|
+
id: 'stl_jDk30akdN',
|
8
|
+
reference: '1234567.1511.03',
|
9
|
+
settled_datetime: '2015-11-06T06:00:02.0Z',
|
10
|
+
amount: 39.75,
|
11
|
+
periods: {
|
12
|
+
"2015" => {
|
13
|
+
"11" => {
|
14
|
+
revenue: [
|
15
|
+
{
|
16
|
+
description: 'iDEAL',
|
17
|
+
method: 'ideal',
|
18
|
+
count: 6,
|
19
|
+
amount: {
|
20
|
+
net: 86.1000,
|
21
|
+
vat: nil,
|
22
|
+
gross: 86.1000
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
description: 'Refunds iDEAL',
|
27
|
+
method: 'refund',
|
28
|
+
count: 2,
|
29
|
+
amount: {
|
30
|
+
net: -43.2000,
|
31
|
+
vat: nil,
|
32
|
+
gross: -43.2000
|
33
|
+
}
|
34
|
+
}
|
35
|
+
],
|
36
|
+
costs: [
|
37
|
+
{
|
38
|
+
description: 'iDEAL',
|
39
|
+
method: 'ideal',
|
40
|
+
count: 6,
|
41
|
+
rate: {
|
42
|
+
fixed: 0.3500,
|
43
|
+
percentage: nil
|
44
|
+
},
|
45
|
+
amount: {
|
46
|
+
net: 2.1000,
|
47
|
+
vat: 0.4410,
|
48
|
+
gross: 2.5410
|
49
|
+
}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
description: 'Refunds iDEAL',
|
53
|
+
method: 'refund',
|
54
|
+
count: 2,
|
55
|
+
rate: {
|
56
|
+
fixed: 0.2500,
|
57
|
+
percentage: nil
|
58
|
+
},
|
59
|
+
amount: {
|
60
|
+
net: 0.5000,
|
61
|
+
vat: 0.1050,
|
62
|
+
gross: 0.6050
|
63
|
+
}
|
64
|
+
}
|
65
|
+
]
|
66
|
+
}
|
67
|
+
}
|
68
|
+
},
|
69
|
+
links: {
|
70
|
+
'payments' => 'https://api.mollie.nl/v1/settlements/stl_jDk30akdN/payments',
|
71
|
+
},
|
72
|
+
payment_ids: [
|
73
|
+
'tr_PBHPvA2ViG',
|
74
|
+
'tr_GAHivPBVP2',
|
75
|
+
'tr_2VBPiPvGAH',
|
76
|
+
'tr_2iHGBvPPVA',
|
77
|
+
'tr_VPH2iPGvAB',
|
78
|
+
'tr_AGPVviP2BH',
|
79
|
+
],
|
80
|
+
refund_ids: [
|
81
|
+
're_PvGHiV2BPA',
|
82
|
+
're_APBiGPH2vV',
|
83
|
+
]
|
84
|
+
}
|
85
|
+
|
86
|
+
settlement = Settlement.new(attributes)
|
87
|
+
|
88
|
+
assert_equal 'stl_jDk30akdN', settlement.id
|
89
|
+
assert_equal '1234567.1511.03', settlement.reference
|
90
|
+
assert_equal Time.parse('2015-11-06T06:00:02.0Z'), settlement.settled_datetime
|
91
|
+
assert_equal 39.75, settlement.amount
|
92
|
+
|
93
|
+
assert_equal 'iDEAL', settlement.periods[:'2015'][:'11'].revenue[0].description
|
94
|
+
assert_equal 'ideal', settlement.periods[:'2015'][:'11'].revenue[0][:method]
|
95
|
+
assert_equal 6, settlement.periods[:'2015'][:'11'].revenue[0].count
|
96
|
+
assert_equal 86.1, settlement.periods[:'2015'][:'11'].revenue[0].amount.net
|
97
|
+
assert_equal nil, settlement.periods[:'2015'][:'11'].revenue[0].amount.vat
|
98
|
+
assert_equal 86.1, settlement.periods[:'2015'][:'11'].revenue[0].amount.gross
|
99
|
+
|
100
|
+
assert_equal 'Refunds iDEAL', settlement.periods[:'2015'][:'11'].revenue[1].description
|
101
|
+
assert_equal 'refund', settlement.periods[:'2015'][:'11'].revenue[1][:method]
|
102
|
+
assert_equal 2, settlement.periods[:'2015'][:'11'].revenue[1].count
|
103
|
+
assert_equal -43.2, settlement.periods[:'2015'][:'11'].revenue[1].amount.net
|
104
|
+
assert_equal nil, settlement.periods[:'2015'][:'11'].revenue[1].amount.vat
|
105
|
+
assert_equal -43.2, settlement.periods[:'2015'][:'11'].revenue[1].amount.gross
|
106
|
+
|
107
|
+
assert_equal 'iDEAL', settlement.periods[:'2015'][:'11'].costs[0].description
|
108
|
+
assert_equal 'ideal', settlement.periods[:'2015'][:'11'].costs[0][:method]
|
109
|
+
assert_equal 6, settlement.periods[:'2015'][:'11'].costs[0].count
|
110
|
+
assert_equal 0.35, settlement.periods[:'2015'][:'11'].costs[0].rate.fixed
|
111
|
+
assert_equal nil, settlement.periods[:'2015'][:'11'].costs[0].rate.percentage
|
112
|
+
assert_equal 2.1, settlement.periods[:'2015'][:'11'].costs[0].amount.net
|
113
|
+
assert_equal 0.441, settlement.periods[:'2015'][:'11'].costs[0].amount.vat
|
114
|
+
assert_equal 2.541, settlement.periods[:'2015'][:'11'].costs[0].amount.gross
|
115
|
+
|
116
|
+
assert_equal 'Refunds iDEAL', settlement.periods[:'2015'][:'11'].costs[1].description
|
117
|
+
assert_equal 'refund', settlement.periods[:'2015'][:'11'].costs[1][:method]
|
118
|
+
assert_equal 2, settlement.periods[:'2015'][:'11'].costs[1].count
|
119
|
+
assert_equal 0.25, settlement.periods[:'2015'][:'11'].costs[1].rate.fixed
|
120
|
+
assert_equal nil, settlement.periods[:'2015'][:'11'].costs[1].rate.percentage
|
121
|
+
assert_equal 0.5, settlement.periods[:'2015'][:'11'].costs[1].amount.net
|
122
|
+
assert_equal 0.105, settlement.periods[:'2015'][:'11'].costs[1].amount.vat
|
123
|
+
assert_equal 0.605, settlement.periods[:'2015'][:'11'].costs[1].amount.gross
|
124
|
+
|
125
|
+
assert_equal 'https://api.mollie.nl/v1/settlements/stl_jDk30akdN/payments', settlement.payments
|
126
|
+
assert_equal 'tr_PBHPvA2ViG', settlement.payment_ids[0]
|
127
|
+
assert_equal 'tr_GAHivPBVP2', settlement.payment_ids[1]
|
128
|
+
assert_equal 'tr_2VBPiPvGAH', settlement.payment_ids[2]
|
129
|
+
assert_equal 'tr_2iHGBvPPVA', settlement.payment_ids[3]
|
130
|
+
assert_equal 'tr_VPH2iPGvAB', settlement.payment_ids[4]
|
131
|
+
assert_equal 'tr_AGPVviP2BH', settlement.payment_ids[5]
|
132
|
+
assert_equal 're_PvGHiV2BPA', settlement.refund_ids[0]
|
133
|
+
assert_equal 're_APBiGPH2vV', settlement.refund_ids[1]
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_open_settlement
|
137
|
+
stub_request(:get, "https://api.mollie.nl/v1/settlements/open")
|
138
|
+
.to_return(:status => 200, :body => %{{"id":"set-id"}}, :headers => {})
|
139
|
+
|
140
|
+
settlement = Settlement.open
|
141
|
+
|
142
|
+
assert_kind_of Settlement, settlement
|
143
|
+
assert_equal "set-id", settlement.id
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_next_settlement
|
147
|
+
stub_request(:get, "https://api.mollie.nl/v1/settlements/next")
|
148
|
+
.to_return(:status => 200, :body => %{{"id":"set-id"}}, :headers => {})
|
149
|
+
|
150
|
+
settlement = Settlement.next
|
151
|
+
|
152
|
+
assert_kind_of Settlement, settlement
|
153
|
+
assert_equal "set-id", settlement.id
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'mollie-api-ruby'
|
2
|
+
|
3
|
+
begin
|
4
|
+
offset = 0
|
5
|
+
limit = 50
|
6
|
+
chargebacks = Mollie::Chargeback.all(
|
7
|
+
offset, limit,
|
8
|
+
api_key: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
|
9
|
+
)
|
10
|
+
rescue Mollie::Exception => e
|
11
|
+
puts 'An error has occurred: ' << e.message
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rack/oauth2'
|
2
|
+
|
3
|
+
client = Rack::OAuth2::Client.new(
|
4
|
+
identifier: client_id,
|
5
|
+
secret: secret,
|
6
|
+
state: 'some_state',
|
7
|
+
redirect_uri: redirect_url,
|
8
|
+
authorization_endpoint: 'https://www.mollie.com/oauth2/authorize',
|
9
|
+
token_endpoint: 'https://api.mollie.nl/oauth2/tokens'
|
10
|
+
)
|
11
|
+
redirect_to client.authorization_uri(
|
12
|
+
state: 'some_state',
|
13
|
+
scope: 'payments.read refunds.write',
|
14
|
+
approval_prompt: true
|
15
|
+
)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rack/oauth2'
|
2
|
+
|
3
|
+
client = Rack::OAuth2::Client.new(
|
4
|
+
identifier: client_id,
|
5
|
+
secret: secret,
|
6
|
+
state: 'some_state',
|
7
|
+
redirect_uri: redirect_url,
|
8
|
+
authorization_endpoint: 'https://www.mollie.com/oauth2/authorize',
|
9
|
+
token_endpoint: 'https://api.mollie.nl/oauth2/tokens'
|
10
|
+
)
|
11
|
+
|
12
|
+
# Use the code returned as parameter on the redirect endpoint
|
13
|
+
client.authorization_code = params['code']
|
14
|
+
client.access_token!.access_token
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'mollie-api-ruby'
|
2
|
+
|
3
|
+
begin
|
4
|
+
payment = Mollie::Customer::Payment.create(
|
5
|
+
customer_id: 'cst_8wmqcHMN4U',
|
6
|
+
amount: '10.0',
|
7
|
+
description: 'First payment',
|
8
|
+
redirect_url: 'https://webshop.example.org/order/12345/',
|
9
|
+
api_key: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
|
10
|
+
)
|
11
|
+
rescue Mollie::Exception => e
|
12
|
+
puts 'An error has occurred: ' << e.message
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'mollie-api-ruby'
|
2
|
+
|
3
|
+
begin
|
4
|
+
customer = Mollie::Customer.create(
|
5
|
+
name: "John",
|
6
|
+
email: "john@example.com",
|
7
|
+
locale: "en_US",
|
8
|
+
api_key: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
|
9
|
+
)
|
10
|
+
rescue Mollie::Exception => e
|
11
|
+
puts 'An error has occurred: ' << e.message
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'mollie-api-ruby'
|
2
|
+
|
3
|
+
begin
|
4
|
+
customer = Mollie::Customer.update(
|
5
|
+
"cst_8wmqcHMN4U",
|
6
|
+
email: "otherjohn@example.com",
|
7
|
+
api_key: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
|
8
|
+
)
|
9
|
+
rescue Mollie::Exception => e
|
10
|
+
puts 'An error has occurred: ' << e.message
|
11
|
+
end
|