mollie-api-ruby 3.1.5 → 4.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +0 -3
- data/CHANGELOG.md +6 -0
- data/README.md +63 -119
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docs/migration_v2_2_x.md +67 -0
- data/docs/migration_v3_x.md +227 -0
- data/examples/chargebacks/get.rb +4 -0
- data/examples/chargebacks/list.rb +1 -0
- data/{website-docs → examples}/connect/authorize.rb +3 -2
- data/{website-docs → examples}/connect/tokens.rb +1 -1
- data/examples/customers/create-payment.rb +6 -0
- data/examples/customers/create.rb +5 -0
- data/examples/customers/delete.rb +1 -0
- data/examples/customers/get.rb +1 -0
- data/examples/customers/list-payments.rb +1 -0
- data/examples/customers/list.rb +1 -0
- data/examples/customers/update.rb +4 -0
- data/examples/invoices/get.rb +1 -0
- data/examples/invoices/list.rb +1 -0
- data/examples/mandates/create.rb +9 -0
- data/examples/mandates/delete.rb +1 -0
- data/examples/mandates/get.rb +1 -0
- data/examples/mandates/list.rb +1 -0
- data/examples/methods/get.rb +4 -0
- data/examples/methods/list.rb +4 -0
- data/examples/organisations/get-current.rb +1 -0
- data/examples/organisations/get.rb +1 -0
- data/examples/payments/create.rb +9 -0
- data/examples/payments/delete.rb +1 -0
- data/examples/payments/get-customer.rb +2 -0
- data/examples/payments/get-mandate.rb +2 -0
- data/examples/payments/get-settlement.rb +2 -0
- data/examples/payments/get-subscription.rb +2 -0
- data/examples/payments/get.rb +1 -0
- data/examples/payments/list.rb +1 -0
- data/examples/payments/webhook.rb +12 -0
- data/examples/permissions/get.rb +1 -0
- data/examples/permissions/list.rb +1 -0
- data/examples/profiles/create.rb +8 -0
- data/examples/profiles/delete.rb +1 -0
- data/examples/profiles/get.rb +1 -0
- data/examples/profiles/list-chargebacks.rb +2 -0
- data/examples/profiles/list-methods.rb +2 -0
- data/examples/profiles/list-payments.rb +2 -0
- data/examples/profiles/list-refunds.rb +2 -0
- data/examples/profiles/list.rb +1 -0
- data/examples/profiles/update.rb +5 -0
- data/examples/refunds/create.rb +5 -0
- data/examples/refunds/delete.rb +4 -0
- data/examples/refunds/get-payment.rb +2 -0
- data/examples/refunds/get.rb +4 -0
- data/examples/refunds/list.rb +1 -0
- data/examples/settlements/get.rb +1 -0
- data/examples/settlements/list-chargebacks.rb +1 -0
- data/examples/settlements/list-payments.rb +1 -0
- data/examples/settlements/list-refunds.rb +1 -0
- data/examples/settlements/list.rb +1 -0
- data/examples/settlements/next.rb +1 -0
- data/examples/settlements/open.rb +1 -0
- data/examples/subscriptions/create.rb +8 -0
- data/examples/subscriptions/delete.rb +4 -0
- data/examples/subscriptions/get.rb +4 -0
- data/examples/subscriptions/list.rb +1 -0
- data/examples/subscriptions/update.rb +5 -0
- data/lib/cacert.pem +168 -48
- data/lib/mollie.rb +1 -3
- data/lib/mollie/amount.rb +20 -0
- data/lib/mollie/base.rb +9 -8
- data/lib/mollie/chargeback.rb +25 -15
- data/lib/mollie/client.rb +33 -13
- data/lib/mollie/customer.rb +9 -14
- data/lib/mollie/customer/mandate.rb +17 -5
- data/lib/mollie/customer/subscription.rb +14 -15
- data/lib/mollie/exception.rb +15 -3
- data/lib/mollie/invoice.rb +30 -26
- data/lib/mollie/list.rb +27 -18
- data/lib/mollie/method.rb +17 -25
- data/lib/mollie/organization.rb +5 -11
- data/lib/mollie/payment.rb +89 -61
- data/lib/mollie/permission.rb +0 -1
- data/lib/mollie/profile.rb +18 -13
- data/lib/mollie/refund.rb +27 -7
- data/lib/mollie/settlement.rb +50 -9
- data/lib/mollie/util.rb +11 -0
- data/lib/mollie/version.rb +1 -1
- data/mollie-api-ruby.gemspec +0 -7
- data/test/mollie/amount_test.rb +30 -0
- data/test/mollie/base_test.rb +44 -44
- data/test/mollie/chargeback_test.rb +78 -17
- data/test/mollie/client_test.rb +29 -12
- data/test/mollie/customer/mandate_test.rb +85 -9
- data/test/mollie/customer/payment_test.rb +2 -2
- data/test/mollie/customer/subscription_test.rb +71 -20
- data/test/mollie/customer_test.rb +17 -89
- data/test/mollie/invoice_test.rb +40 -24
- data/test/mollie/list_test.rb +62 -18
- data/test/mollie/method_test.rb +2 -8
- data/test/mollie/organization_test.rb +28 -23
- data/test/mollie/payment/chargeback_test.rb +2 -3
- data/test/mollie/payment/refund_test.rb +2 -3
- data/test/mollie/payment_test.rb +272 -86
- data/test/mollie/permission_test.rb +0 -2
- data/test/mollie/profile_test.rb +129 -35
- data/test/mollie/refund_test.rb +90 -10
- data/test/mollie/settlement/chargeback_test.rb +2 -4
- data/test/mollie/settlement/payment_test.rb +2 -2
- data/test/mollie/settlement/refund_test.rb +2 -3
- data/test/mollie/settlement_test.rb +199 -98
- data/test/mollie/util_test.rb +31 -0
- metadata +96 -239
- data/examples/apis/api_docs.rb +0 -37
- data/examples/apis/chargebacks.rb +0 -17
- data/examples/apis/connect.rb +0 -58
- data/examples/apis/customers.rb +0 -116
- data/examples/apis/invoices.rb +0 -38
- data/examples/apis/issuers.rb +0 -35
- data/examples/apis/mandates.rb +0 -83
- data/examples/apis/methods.rb +0 -50
- data/examples/apis/organizations.rb +0 -16
- data/examples/apis/payments.rb +0 -174
- data/examples/apis/permissions.rb +0 -32
- data/examples/apis/profiles.rb +0 -126
- data/examples/apis/refunds.rb +0 -17
- data/examples/apis/settlements.rb +0 -84
- data/examples/apis/subscriptions.rb +0 -165
- data/examples/config.ru +0 -57
- data/examples/public/images/collapse.gif +0 -0
- data/examples/public/images/expand.gif +0 -0
- data/examples/public/images/explorer_icons.png +0 -0
- data/examples/public/images/favicon-16x16.png +0 -0
- data/examples/public/images/favicon-32x32.png +0 -0
- data/examples/public/images/favicon.ico +0 -0
- data/examples/public/images/logo_small.png +0 -0
- data/examples/public/images/pet_store_api.png +0 -0
- data/examples/public/images/throbber.gif +0 -0
- data/examples/public/images/wordnik_api.png +0 -0
- data/examples/public/index.html +0 -101
- data/examples/public/javascripts/lib/backbone-min.js +0 -1
- data/examples/public/javascripts/lib/es5-shim.js +0 -1
- data/examples/public/javascripts/lib/handlebars-4.0.5.js +0 -3
- data/examples/public/javascripts/lib/highlight.9.1.0.pack.js +0 -1
- data/examples/public/javascripts/lib/highlight.9.1.0.pack_extended.js +0 -1
- data/examples/public/javascripts/lib/jquery-1.8.0.min.js +0 -3
- data/examples/public/javascripts/lib/jquery.ba-bbq.min.js +0 -1
- data/examples/public/javascripts/lib/jquery.slideto.min.js +0 -1
- data/examples/public/javascripts/lib/jquery.wiggle.min.js +0 -1
- data/examples/public/javascripts/lib/js-yaml.min.js +0 -2
- data/examples/public/javascripts/lib/jsoneditor.min.js +0 -5
- data/examples/public/javascripts/lib/lodash.min.js +0 -2
- data/examples/public/javascripts/lib/marked.js +0 -1
- data/examples/public/javascripts/lib/object-assign-pollyfill.js +0 -1
- data/examples/public/javascripts/lib/sanitize-html.min.js +0 -4
- data/examples/public/javascripts/lib/swagger-oauth.js +0 -1
- data/examples/public/javascripts/swagger-ui.js +0 -25378
- data/examples/public/javascripts/swagger-ui.min.js +0 -15
- data/examples/public/javascripts/swagger_docs.js +0 -14
- data/examples/public/o2c.html +0 -20
- data/examples/public/stylesheets/reset.css +0 -1
- data/examples/public/stylesheets/screen.css +0 -1545
- data/examples/public/stylesheets/swagger_docs.css +0 -4
- data/examples/public/stylesheets/typography.css +0 -0
- data/lib/mollie/issuer.rb +0 -5
- data/lib/mollie/profile/api_key.rb +0 -19
- data/lib/mollie/relation.rb +0 -36
- data/test/mollie/issuer_test.rb +0 -19
- data/test/mollie/profile/apikey_test.rb +0 -31
- data/website-docs/chargebacks/list-all.rb +0 -12
- data/website-docs/customers/create-payment.rb +0 -13
- data/website-docs/customers/create.rb +0 -12
- data/website-docs/customers/delete.rb +0 -10
- data/website-docs/customers/get.rb +0 -10
- data/website-docs/customers/list-payments.rb +0 -10
- data/website-docs/customers/list.rb +0 -12
- data/website-docs/customers/update.rb +0 -11
- data/website-docs/invoices/get.rb +0 -10
- data/website-docs/invoices/list.rb +0 -12
- data/website-docs/issuers/get.rb +0 -10
- data/website-docs/issuers/list.rb +0 -12
- data/website-docs/mandates/create.rb +0 -16
- data/website-docs/mandates/delete.rb +0 -10
- data/website-docs/mandates/get.rb +0 -10
- data/website-docs/mandates/list.rb +0 -12
- data/website-docs/methods/get.rb +0 -10
- data/website-docs/methods/list.rb +0 -12
- data/website-docs/organisations/get.rb +0 -10
- data/website-docs/payments/create-refund.rb +0 -14
- data/website-docs/payments/create.rb +0 -16
- data/website-docs/payments/delete-refund.rb +0 -13
- data/website-docs/payments/delete.rb +0 -12
- data/website-docs/payments/get-chargeback.rb +0 -11
- data/website-docs/payments/get-refund.rb +0 -11
- data/website-docs/payments/get.rb +0 -10
- data/website-docs/payments/list-chargeback.rb +0 -13
- data/website-docs/payments/list-refunds.rb +0 -13
- data/website-docs/payments/list.rb +0 -12
- data/website-docs/payments/payment-webhook.rb +0 -21
- data/website-docs/permissions/get.rb +0 -10
- data/website-docs/permissions/list.rb +0 -12
- data/website-docs/profiles/create.rb +0 -15
- data/website-docs/profiles/delete.rb +0 -10
- data/website-docs/profiles/get-key.rb +0 -11
- data/website-docs/profiles/get.rb +0 -10
- data/website-docs/profiles/list-keys.rb +0 -13
- data/website-docs/profiles/list.rb +0 -12
- data/website-docs/profiles/reset-key.rb +0 -13
- data/website-docs/profiles/update.rb +0 -12
- data/website-docs/refunds/list.rb +0 -12
- data/website-docs/settlements/get.rb +0 -10
- data/website-docs/settlements/list-chargebacks.rb +0 -13
- data/website-docs/settlements/list-payments.rb +0 -13
- data/website-docs/settlements/list-refunds.rb +0 -13
- data/website-docs/settlements/list.rb +0 -12
- data/website-docs/settlements/next.rb +0 -9
- data/website-docs/settlements/open.rb +0 -9
- data/website-docs/subscriptions/create.rb +0 -14
- data/website-docs/subscriptions/delete.rb +0 -10
- data/website-docs/subscriptions/get.rb +0 -10
- data/website-docs/subscriptions/list.rb +0 -12
data/lib/mollie/list.rb
CHANGED
@@ -2,39 +2,48 @@ module Mollie
|
|
2
2
|
class List < Base
|
3
3
|
include Enumerable
|
4
4
|
|
5
|
-
attr_accessor :
|
6
|
-
|
7
|
-
:count,
|
8
|
-
:links,
|
9
|
-
:data
|
5
|
+
attr_accessor :klass, :items, :_links
|
6
|
+
alias_method :links, :_links
|
10
7
|
|
11
8
|
def initialize(list_attributes, klass)
|
12
|
-
|
9
|
+
@klass = klass
|
10
|
+
|
11
|
+
if list_attributes['_embedded']
|
12
|
+
list_attributes['items'] ||= list_attributes['_embedded'].fetch(klass.resource_name, [])
|
13
|
+
else
|
14
|
+
list_attributes['items'] ||= []
|
15
|
+
end
|
13
16
|
super list_attributes
|
14
17
|
|
15
|
-
@
|
18
|
+
@items = self.items.map do |attributes|
|
16
19
|
klass.new attributes
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
23
|
def each(&block)
|
21
|
-
@
|
24
|
+
@items.each(&block)
|
22
25
|
end
|
23
26
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
+
def next(options = {})
|
28
|
+
if links['next'].nil?
|
29
|
+
return self.class.new({}, klass)
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
32
|
+
href = URI.parse(links['next']['href'])
|
33
|
+
query = URI.decode_www_form(href.query).to_h
|
31
34
|
|
32
|
-
|
33
|
-
links && links['next']
|
35
|
+
klass.all(options.merge(query))
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
|
38
|
+
def previous(options = {})
|
39
|
+
if links['previous'].nil?
|
40
|
+
return self.class.new({}, klass)
|
41
|
+
end
|
42
|
+
|
43
|
+
href = URI.parse(links['previous']['href'])
|
44
|
+
query = URI.decode_www_form(href.query).to_h
|
45
|
+
|
46
|
+
klass.all(options.merge(query))
|
38
47
|
end
|
39
48
|
end
|
40
49
|
end
|
data/lib/mollie/method.rb
CHANGED
@@ -1,40 +1,32 @@
|
|
1
1
|
module Mollie
|
2
2
|
class Method < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
DIRECTDEBIT
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
BANCONTACT = "bancontact"
|
4
|
+
BANKTRANSFER = "banktransfer"
|
5
|
+
BELFIUS = "belfius"
|
6
|
+
BITCOIN = "bitcoin"
|
7
|
+
CREDITCARD = "creditcard"
|
8
|
+
DIRECTDEBIT = "directdebit"
|
9
|
+
EPS = "eps"
|
10
|
+
GIFTCARD = "giftcard"
|
11
|
+
GIROPAY = "giropay"
|
12
|
+
IDEAL = "ideal"
|
13
|
+
INGHOMEPAY = "inghomepay"
|
14
|
+
KBC = "kbc"
|
15
|
+
PAYPAL = "paypal"
|
16
|
+
PAYSAFECARD = "paysafecard"
|
17
|
+
SOFORT = "sofort"
|
17
18
|
|
18
19
|
attr_accessor :id,
|
19
20
|
:description,
|
20
|
-
:amount,
|
21
21
|
:image,
|
22
22
|
:issuers
|
23
23
|
|
24
24
|
def normal_image
|
25
|
-
image['
|
25
|
+
image['size1x']
|
26
26
|
end
|
27
27
|
|
28
28
|
def bigger_image
|
29
|
-
image['
|
30
|
-
end
|
31
|
-
|
32
|
-
def minimum_amount
|
33
|
-
BigDecimal.new(amount['minimum'].to_s)
|
34
|
-
end
|
35
|
-
|
36
|
-
def maximum_amount
|
37
|
-
BigDecimal.new(amount['maximum'].to_s)
|
29
|
+
image['size2x']
|
38
30
|
end
|
39
31
|
end
|
40
32
|
end
|
data/lib/mollie/organization.rb
CHANGED
@@ -4,21 +4,15 @@ module Mollie
|
|
4
4
|
:name,
|
5
5
|
:email,
|
6
6
|
:address,
|
7
|
-
:postal_code,
|
8
|
-
:city,
|
9
|
-
:country,
|
10
|
-
:country_code,
|
11
|
-
:registration_type,
|
12
7
|
:registration_number,
|
13
|
-
:
|
14
|
-
:verified_datetime
|
8
|
+
:vat_number
|
15
9
|
|
16
|
-
def
|
17
|
-
|
10
|
+
def self.current(options = {})
|
11
|
+
self.get("me", options)
|
18
12
|
end
|
19
13
|
|
20
|
-
def
|
21
|
-
@
|
14
|
+
def address=(address)
|
15
|
+
@address = OpenStruct.new(address) if address.is_a?(Hash)
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
data/lib/mollie/payment.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
module Mollie
|
2
2
|
class Payment < Base
|
3
|
-
STATUS_OPEN
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
STATUS_REFUNDED = "refunded"
|
10
|
-
STATUS_PENDING = "pending"
|
11
|
-
STATUS_CHARGED_BACK = "charged_back"
|
3
|
+
STATUS_OPEN = "open"
|
4
|
+
STATUS_CANCELED = "canceled"
|
5
|
+
STATUS_PENDING = "pending"
|
6
|
+
STATUS_EXPIRED = "expired"
|
7
|
+
STATUS_FAILED = "failed"
|
8
|
+
STATUS_PAID = "paid"
|
12
9
|
|
13
10
|
RECURRINGTYPE_NONE = nil
|
14
11
|
RECURRINGTYPE_FIRST = "first"
|
@@ -16,12 +13,14 @@ module Mollie
|
|
16
13
|
|
17
14
|
attr_accessor :id,
|
18
15
|
:mode,
|
19
|
-
:
|
16
|
+
:created_at,
|
20
17
|
:status,
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
18
|
+
:paid_at,
|
19
|
+
:is_cancelable,
|
20
|
+
:canceled_at,
|
21
|
+
:expired_at,
|
22
|
+
:expires_at,
|
23
|
+
:failed_at,
|
25
24
|
:amount,
|
26
25
|
:amount_refunded,
|
27
26
|
:amount_remaining,
|
@@ -29,50 +28,54 @@ module Mollie
|
|
29
28
|
:method,
|
30
29
|
:metadata,
|
31
30
|
:locale,
|
31
|
+
:country_code,
|
32
32
|
:profile_id,
|
33
|
+
:settlement_amount,
|
33
34
|
:settlement_id,
|
34
35
|
:customer_id,
|
35
|
-
:
|
36
|
+
:sequence_type,
|
36
37
|
:mandate_id,
|
37
38
|
:subscription_id,
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:details
|
39
|
+
:application_fee,
|
40
|
+
:_links,
|
41
|
+
:details,
|
42
|
+
:redirect_url,
|
43
|
+
:webhook_url
|
44
|
+
|
45
|
+
alias_method :links, :_links
|
41
46
|
|
42
47
|
def open?
|
43
48
|
status == STATUS_OPEN
|
44
49
|
end
|
45
50
|
|
46
|
-
def
|
47
|
-
status ==
|
48
|
-
end
|
49
|
-
|
50
|
-
def expired?
|
51
|
-
status == STATUS_EXPIRED
|
51
|
+
def canceled?
|
52
|
+
status == STATUS_CANCELED
|
52
53
|
end
|
53
54
|
|
54
|
-
def
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def paidout?
|
59
|
-
status == STATUS_PAIDOUT
|
55
|
+
def pending?
|
56
|
+
status == STATUS_PENDING
|
60
57
|
end
|
61
58
|
|
62
|
-
def
|
63
|
-
status ==
|
59
|
+
def expired?
|
60
|
+
status == STATUS_EXPIRED
|
64
61
|
end
|
65
62
|
|
66
63
|
def failed?
|
67
64
|
status == STATUS_FAILED
|
68
65
|
end
|
69
66
|
|
70
|
-
def
|
71
|
-
status ==
|
67
|
+
def paid?
|
68
|
+
status == STATUS_PAID
|
72
69
|
end
|
73
70
|
|
74
|
-
def
|
75
|
-
|
71
|
+
def application_fee=(application_fee)
|
72
|
+
amount = Amount.new(application_fee["amount"])
|
73
|
+
description = application_fee["description"]
|
74
|
+
|
75
|
+
@application_fee = OpenStruct.new(
|
76
|
+
amount: amount,
|
77
|
+
description: description
|
78
|
+
)
|
76
79
|
end
|
77
80
|
|
78
81
|
def details=(details)
|
@@ -83,60 +86,85 @@ module Mollie
|
|
83
86
|
@metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
|
84
87
|
end
|
85
88
|
|
86
|
-
def
|
87
|
-
@
|
89
|
+
def created_at=(created_at)
|
90
|
+
@created_at = Time.parse(created_at.to_s) rescue nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def paid_at=(paid_at)
|
94
|
+
@paid_at = Time.parse(paid_at.to_s) rescue nil
|
88
95
|
end
|
89
96
|
|
90
|
-
def
|
91
|
-
@
|
97
|
+
def canceled_at=(canceled_at)
|
98
|
+
@canceled_at = Time.parse(canceled_at.to_s) rescue nil
|
92
99
|
end
|
93
100
|
|
94
|
-
def
|
95
|
-
@
|
101
|
+
def expired_at=(expired_at)
|
102
|
+
@expired_at = Time.parse(expired_at.to_s) rescue nil
|
96
103
|
end
|
97
104
|
|
98
|
-
def
|
99
|
-
@
|
105
|
+
def expires_at=(expires_at)
|
106
|
+
@expires_at = Time.parse(expires_at.to_s) rescue nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def failed_at=(failed_at)
|
110
|
+
@failed_at = Time.parse(failed_at)
|
100
111
|
end
|
101
112
|
|
102
113
|
def amount=(amount)
|
103
|
-
@amount =
|
114
|
+
@amount = Mollie::Amount.new(amount)
|
115
|
+
end
|
116
|
+
|
117
|
+
def settlement_amount=(settlement_amount)
|
118
|
+
@settlement_amount = Mollie::Amount.new(settlement_amount)
|
104
119
|
end
|
105
120
|
|
106
121
|
def amount_remaining=(amount_remaining)
|
107
|
-
@amount_remaining =
|
122
|
+
@amount_remaining = Mollie::Amount.new(amount_remaining)
|
108
123
|
end
|
109
124
|
|
110
125
|
def amount_refunded=(amount_refunded)
|
111
|
-
@amount_refunded =
|
126
|
+
@amount_refunded = Mollie::Amount.new(amount_refunded)
|
127
|
+
end
|
128
|
+
|
129
|
+
def checkout_url
|
130
|
+
Util.extract_url(links, 'checkout')
|
112
131
|
end
|
113
132
|
|
114
|
-
def
|
115
|
-
|
133
|
+
def refund!(options = {})
|
134
|
+
options[:payment_id] = id
|
135
|
+
# refund full amount by default
|
136
|
+
options[:amount] ||= amount.to_h
|
137
|
+
Payment::Refund.create(options)
|
116
138
|
end
|
117
139
|
|
118
|
-
def
|
119
|
-
|
140
|
+
def refunds(options = {})
|
141
|
+
Payment::Refund.all(options.merge(payment_id: id))
|
120
142
|
end
|
121
143
|
|
122
|
-
def
|
123
|
-
|
144
|
+
def chargebacks(options = {})
|
145
|
+
Payment::Chargeback.all(options.merge(payment_id: id))
|
124
146
|
end
|
125
147
|
|
126
|
-
def
|
127
|
-
|
148
|
+
def customer(options = {})
|
149
|
+
return if customer_id.nil?
|
150
|
+
Customer.get(customer_id, options)
|
128
151
|
end
|
129
152
|
|
130
|
-
def
|
131
|
-
|
153
|
+
def mandate(options = {})
|
154
|
+
return if mandate_id.nil?
|
155
|
+
Customer::Mandate.get(mandate_id, options)
|
132
156
|
end
|
133
157
|
|
134
|
-
def
|
135
|
-
|
158
|
+
def settlement(options = {})
|
159
|
+
return if settlement_id.nil?
|
160
|
+
Settlement.get(settlement_id, options)
|
136
161
|
end
|
137
162
|
|
138
|
-
def
|
139
|
-
|
163
|
+
def subscription(options = {})
|
164
|
+
return if customer_id.nil?
|
165
|
+
return if subscription_id.nil?
|
166
|
+
options = options.merge(customer_id: customer_id)
|
167
|
+
Customer::Subscription.get(subscription_id, options)
|
140
168
|
end
|
141
169
|
end
|
142
170
|
end
|
data/lib/mollie/permission.rb
CHANGED
data/lib/mollie/profile.rb
CHANGED
@@ -27,9 +27,10 @@ module Mollie
|
|
27
27
|
:category_code,
|
28
28
|
:status,
|
29
29
|
:review,
|
30
|
-
:
|
31
|
-
:
|
32
|
-
|
30
|
+
:created_at,
|
31
|
+
:_links
|
32
|
+
|
33
|
+
alias_method :links, :_links
|
33
34
|
|
34
35
|
def unverified?
|
35
36
|
status == STATUS_UNVERIFIED
|
@@ -55,24 +56,28 @@ module Mollie
|
|
55
56
|
@review && @review.status == REVIEW_STATUS_REJECTED
|
56
57
|
end
|
57
58
|
|
58
|
-
def
|
59
|
-
@
|
59
|
+
def created_at=(created_at)
|
60
|
+
@created_at = Time.parse(created_at.to_s) rescue nil
|
60
61
|
end
|
61
62
|
|
62
|
-
def
|
63
|
-
|
63
|
+
def checkout_preview_url
|
64
|
+
Util.extract_url(links, 'checkout_preview_url')
|
64
65
|
end
|
65
66
|
|
66
|
-
def
|
67
|
-
|
67
|
+
def chargebacks(options = {})
|
68
|
+
Chargeback.all(options.merge(profile_id: id))
|
68
69
|
end
|
69
70
|
|
70
|
-
def
|
71
|
-
|
71
|
+
def methods(options = {})
|
72
|
+
Method.all(options.merge(profile_id: id))
|
73
|
+
end
|
74
|
+
|
75
|
+
def payments(options = {})
|
76
|
+
Payment.all(options.merge(profile_id: id))
|
72
77
|
end
|
73
78
|
|
74
|
-
def
|
75
|
-
|
79
|
+
def refunds(options = {})
|
80
|
+
Refund.all(options.merge(profile_id: id))
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
data/lib/mollie/refund.rb
CHANGED
@@ -4,12 +4,18 @@ module Mollie
|
|
4
4
|
STATUS_PENDING = "pending"
|
5
5
|
STATUS_PROCESSING = "processing"
|
6
6
|
STATUS_REFUNDED = "refunded"
|
7
|
+
STATUS_FAILED = "failed"
|
7
8
|
|
8
9
|
attr_accessor :id,
|
9
|
-
:payment,
|
10
10
|
:amount,
|
11
|
+
:settlement_amount,
|
11
12
|
:status,
|
12
|
-
:
|
13
|
+
:payment_id,
|
14
|
+
:description,
|
15
|
+
:created_at,
|
16
|
+
:_links
|
17
|
+
|
18
|
+
alias_method :links, :_links
|
13
19
|
|
14
20
|
def queued?
|
15
21
|
status == STATUS_QUEUED
|
@@ -27,16 +33,30 @@ module Mollie
|
|
27
33
|
status == STATUS_REFUNDED
|
28
34
|
end
|
29
35
|
|
30
|
-
def
|
31
|
-
|
36
|
+
def failed?
|
37
|
+
status == STATUS_FAILED
|
32
38
|
end
|
33
39
|
|
34
40
|
def amount=(amount)
|
35
|
-
@amount =
|
41
|
+
@amount = Amount.new(amount)
|
42
|
+
end
|
43
|
+
|
44
|
+
def settlement_amount=(settlement_amount)
|
45
|
+
@settlement_amount = Amount.new(settlement_amount)
|
46
|
+
end
|
47
|
+
|
48
|
+
def created_at=(created_at)
|
49
|
+
@created_at = Time.parse(created_at) rescue nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def payment(options = {})
|
53
|
+
Payment.get(payment_id, options)
|
36
54
|
end
|
37
55
|
|
38
|
-
def
|
39
|
-
|
56
|
+
def settlement(options = {})
|
57
|
+
settlement_id = Util.extract_id(links, "settlement")
|
58
|
+
return if settlement_id.nil?
|
59
|
+
Settlement.get(settlement_id, options)
|
40
60
|
end
|
41
61
|
end
|
42
62
|
end
|