mollie-api-ruby 4.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +6 -0
- data/examples/captures/get-payment.rb +2 -0
- data/examples/captures/get-settlement.rb +2 -0
- data/examples/captures/get-shipment.rb +2 -0
- data/examples/captures/get.rb +4 -0
- data/examples/captures/list.rb +1 -0
- data/examples/orders/cancel-lines.rb +2 -0
- data/examples/orders/cancel.rb +5 -0
- data/examples/orders/create-refund.rb +15 -0
- data/examples/orders/create.rb +88 -0
- data/examples/orders/get.rb +1 -0
- data/examples/orders/list-refunds.rb +1 -0
- data/examples/orders/list.rb +1 -0
- data/examples/orders/update.rb +15 -0
- data/examples/payments/get-order.rb +2 -0
- data/examples/refunds/get-order.rb +2 -0
- data/examples/shipments/create.rb +17 -0
- data/examples/shipments/get-order.rb +2 -0
- data/examples/shipments/get.rb +4 -0
- data/examples/shipments/list.rb +1 -0
- data/examples/shipments/update.rb +9 -0
- data/lib/mollie.rb +5 -0
- data/lib/mollie/base.rb +2 -0
- data/lib/mollie/exception.rb +1 -1
- data/lib/mollie/list.rb +8 -0
- data/lib/mollie/order.rb +142 -0
- data/lib/mollie/order/line.rb +95 -0
- data/lib/mollie/order/refund.rb +6 -0
- data/lib/mollie/order/shipment.rb +34 -0
- data/lib/mollie/payment.rb +17 -6
- data/lib/mollie/payment/capture.rb +43 -0
- data/lib/mollie/refund.rb +11 -0
- data/lib/mollie/version.rb +1 -1
- data/test/fixtures/captures/get.json +39 -0
- data/test/fixtures/captures/list.json +58 -0
- data/test/fixtures/orders/cancel_line.json +8 -0
- data/test/fixtures/orders/cancel_line_qty.json +8 -0
- data/test/fixtures/orders/create.json +88 -0
- data/test/fixtures/orders/create_refund.json +9 -0
- data/test/fixtures/orders/get.json +218 -0
- data/test/fixtures/orders/list.json +34 -0
- data/test/fixtures/orders/list_refunds.json +85 -0
- data/test/fixtures/orders/refund.json +63 -0
- data/test/fixtures/orders/refund_all.json +3 -0
- data/test/fixtures/orders/update.json +14 -0
- data/test/fixtures/refunds/get.json +111 -0
- data/test/fixtures/shipments/create.json +16 -0
- data/test/fixtures/shipments/get.json +101 -0
- data/test/fixtures/shipments/list.json +74 -0
- data/test/fixtures/shipments/update.json +7 -0
- data/test/helper.rb +4 -0
- data/test/mollie/list_test.rb +3 -0
- data/test/mollie/order/line_test.rb +45 -0
- data/test/mollie/order/shipment_test.rb +143 -0
- data/test/mollie/order_test.rb +289 -0
- data/test/mollie/payment/capture_test.rb +77 -0
- data/test/mollie/payment_test.rb +33 -0
- data/test/mollie/refund_test.rb +64 -0
- metadata +101 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f94d074aceda8fa4e7e541274aa0310d6dd414e80764f57bae3a2eaa604cc3dc
|
4
|
+
data.tar.gz: 74c99d214bd5f014134fc667e4aeff19cfec559b3d748dc64bfa7fac1b375fd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc8639da1239db004daa99c723193cf0f56e8c82790267698d61d5597d49d8ec03a7bd338033be98644459d27cb8512810f47eac83ec205d000a34266bc7cbe
|
7
|
+
data.tar.gz: 4c13bc4d8756cd9a4c2701b4a04a037865fca7a8458865897f177af16a57ea97a4e883ca9c1096867646b501dbfbb9ecc83052431b7a53535f1dc38111aefee1
|
data/.rubocop_todo.yml
CHANGED
@@ -23,6 +23,10 @@ Lint/DuplicateMethods:
|
|
23
23
|
- 'lib/mollie/customer/mandate.rb'
|
24
24
|
- 'lib/mollie/customer/subscription.rb'
|
25
25
|
- 'lib/mollie/invoice.rb'
|
26
|
+
- 'lib/mollie/order.rb'
|
27
|
+
- 'lib/mollie/order/line.rb'
|
28
|
+
- 'lib/mollie/order/shipment.rb'
|
29
|
+
- 'lib/mollie/payment/capture.rb'
|
26
30
|
- 'lib/mollie/organization.rb'
|
27
31
|
- 'lib/mollie/payment.rb'
|
28
32
|
- 'lib/mollie/profile.rb'
|
@@ -37,6 +41,8 @@ Metrics/AbcSize:
|
|
37
41
|
# Configuration parameters: CountComments.
|
38
42
|
Metrics/ClassLength:
|
39
43
|
Max: 295
|
44
|
+
Exclude:
|
45
|
+
- 'test/**/*'
|
40
46
|
|
41
47
|
# Offense count: 1
|
42
48
|
Metrics/CyclomaticComplexity:
|
@@ -0,0 +1 @@
|
|
1
|
+
capture = Mollie::Payment::Capture.all(payment_id: 'tr_WDqYK6vllg')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Refund all order lines
|
2
|
+
order = Mollie::Order.get('ord_kEn1PlbGa')
|
3
|
+
refund = order.refund!
|
4
|
+
|
5
|
+
# Refund a specific order line
|
6
|
+
order = Mollie::Order.get('ord_kEn1PlbGa')
|
7
|
+
refund = order.refund!(
|
8
|
+
lines: [
|
9
|
+
{
|
10
|
+
id: 'odl_dgtxyl',
|
11
|
+
quantity: 1
|
12
|
+
}
|
13
|
+
],
|
14
|
+
description: 'Required quantity not in stock, refunding one photo book.'
|
15
|
+
)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
order = Mollie::Order.create(
|
2
|
+
amount: {
|
3
|
+
value: '1027.99',
|
4
|
+
currency: 'EUR'
|
5
|
+
},
|
6
|
+
billingAddress: {
|
7
|
+
streetAndNumber: 'Keizersgracht 313',
|
8
|
+
city: 'Amsterdam',
|
9
|
+
region: 'Noord-Holland',
|
10
|
+
postalCode: '1234AB',
|
11
|
+
country: 'NL',
|
12
|
+
title: 'Dhr',
|
13
|
+
givenName: 'Piet',
|
14
|
+
familyName: 'Mondriaan',
|
15
|
+
email: 'piet@mondriaan.com',
|
16
|
+
phone: '+31208202070'
|
17
|
+
},
|
18
|
+
shippingAddress: {
|
19
|
+
streetAndNumber: 'Prinsengracht 313',
|
20
|
+
streetAdditional: '4th floor',
|
21
|
+
city: 'Haarlem',
|
22
|
+
region: 'Noord-Holland',
|
23
|
+
postalCode: '5678AB',
|
24
|
+
country: 'NL',
|
25
|
+
title: 'Mr',
|
26
|
+
givenName: 'Chuck',
|
27
|
+
familyName: 'Norris',
|
28
|
+
email: 'norris@chucknorrisfacts.net'
|
29
|
+
},
|
30
|
+
metadata: {
|
31
|
+
order_id: '1337',
|
32
|
+
description: 'Lego cars'
|
33
|
+
},
|
34
|
+
consumerDateOfBirth: '1958-01-31',
|
35
|
+
locale: 'nl_NL',
|
36
|
+
orderNumber: '1337',
|
37
|
+
redirectUrl: 'https://example.org/redirect',
|
38
|
+
webhookUrl: 'https://example.org/webhook',
|
39
|
+
method: 'klarnapaylater',
|
40
|
+
lines: [
|
41
|
+
{
|
42
|
+
type: 'physical',
|
43
|
+
sku: '5702016116977',
|
44
|
+
name: 'LEGO 42083 Bugatti Chiron',
|
45
|
+
productUrl: 'https://shop.lego.com/nl-NL/Bugatti-Chiron-42083',
|
46
|
+
imageUrl: 'https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$',
|
47
|
+
quantity: 2,
|
48
|
+
vatRate: '21.00',
|
49
|
+
unitPrice: {
|
50
|
+
"currency": 'EUR',
|
51
|
+
"value": '399.00'
|
52
|
+
},
|
53
|
+
totalAmount: {
|
54
|
+
"currency": 'EUR',
|
55
|
+
"value": '698.00'
|
56
|
+
},
|
57
|
+
discountAmount: {
|
58
|
+
"currency": 'EUR',
|
59
|
+
"value": '100.00'
|
60
|
+
},
|
61
|
+
vatAmount: {
|
62
|
+
"currency": 'EUR',
|
63
|
+
"value": '121.14'
|
64
|
+
}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
type: 'physical',
|
68
|
+
sku: '5702015594028',
|
69
|
+
name: 'LEGO 42056 Porsche 911 GT3 RS',
|
70
|
+
productUrl: 'https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056',
|
71
|
+
imageUrl: 'https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$',
|
72
|
+
quantity: 1,
|
73
|
+
vatRate: '21.00',
|
74
|
+
unitPrice: {
|
75
|
+
currency: 'EUR',
|
76
|
+
value: '329.99'
|
77
|
+
},
|
78
|
+
totalAmount: {
|
79
|
+
currency: 'EUR',
|
80
|
+
value: '329.99'
|
81
|
+
},
|
82
|
+
vatAmount: {
|
83
|
+
currency: 'EUR',
|
84
|
+
value: '57.27'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
]
|
88
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
order = Mollie::Order.get('ord_kEn1PlbGa')
|
@@ -0,0 +1 @@
|
|
1
|
+
refunds = Order::Refund.all(order_id: 'ord_kEn1PlbGa')
|
@@ -0,0 +1 @@
|
|
1
|
+
orders = Mollie::Order.all
|
@@ -0,0 +1,15 @@
|
|
1
|
+
order = Mollie::Order.update(
|
2
|
+
'ord_kEn1PlbGa',
|
3
|
+
billingAddress: {
|
4
|
+
city: 'Amsterdam',
|
5
|
+
country: 'NL',
|
6
|
+
email: 'piet@mondriaan.com',
|
7
|
+
familyName: 'Mondriaan',
|
8
|
+
givenName: 'Piet',
|
9
|
+
phone: '+31208202070',
|
10
|
+
postalCode: '1234AB',
|
11
|
+
region: 'Noord-Holland',
|
12
|
+
streetAndNumber: 'Keizersgracht 313',
|
13
|
+
title: 'Dhr'
|
14
|
+
}
|
15
|
+
)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
shipment = Mollie::Order::Shipment.create(
|
2
|
+
order_id: 'ord_kEn1PlbGa',
|
3
|
+
lines: [
|
4
|
+
{
|
5
|
+
id: 'odl_dgtxyl',
|
6
|
+
quantity: 1
|
7
|
+
},
|
8
|
+
{
|
9
|
+
id: 'odl_jp31jz'
|
10
|
+
}
|
11
|
+
],
|
12
|
+
tracking: {
|
13
|
+
carrier: 'PostNL',
|
14
|
+
code: '3SKABA000000000',
|
15
|
+
url: 'http://postnl.nl/tracktrace/?B=3SKABA000000000&P=1016EE&D=NL&T=C'
|
16
|
+
}
|
17
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
shipments = Mollie::Order::Shipment.all(order_id: 'ord_kEn1PlbGa')
|
data/lib/mollie.rb
CHANGED
@@ -21,6 +21,7 @@ require 'mollie/customer/subscription'
|
|
21
21
|
require 'mollie/invoice'
|
22
22
|
require 'mollie/list'
|
23
23
|
require 'mollie/method'
|
24
|
+
require 'mollie/order'
|
24
25
|
require 'mollie/organization'
|
25
26
|
require 'mollie/payment'
|
26
27
|
require 'mollie/permission'
|
@@ -29,6 +30,10 @@ require 'mollie/refund'
|
|
29
30
|
require 'mollie/settlement'
|
30
31
|
|
31
32
|
require 'mollie/customer/payment'
|
33
|
+
require 'mollie/order/line'
|
34
|
+
require 'mollie/order/refund'
|
35
|
+
require 'mollie/order/shipment'
|
36
|
+
require 'mollie/payment/capture'
|
32
37
|
require 'mollie/payment/chargeback'
|
33
38
|
require 'mollie/payment/refund'
|
34
39
|
require 'mollie/settlement/chargeback'
|
data/lib/mollie/base.rb
CHANGED
@@ -44,6 +44,7 @@ module Mollie
|
|
44
44
|
def delete(id, options = {})
|
45
45
|
request('DELETE', id, options)
|
46
46
|
end
|
47
|
+
alias cancel delete
|
47
48
|
|
48
49
|
def request(method, id = 0, data = {}, options = {})
|
49
50
|
parent_id = options.delete(self.parent_id) || data.delete(self.parent_id)
|
@@ -88,5 +89,6 @@ module Mollie
|
|
88
89
|
end
|
89
90
|
self.class.delete(id, options)
|
90
91
|
end
|
92
|
+
alias cancel delete
|
91
93
|
end
|
92
94
|
end
|
data/lib/mollie/exception.rb
CHANGED
data/lib/mollie/list.rb
CHANGED
data/lib/mollie/order.rb
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
module Mollie
|
2
|
+
class Order < Base
|
3
|
+
STATUS_PENDING = 'pending'.freeze
|
4
|
+
STATUS_AUTHORIZED = 'authorized'.freeze
|
5
|
+
STATUS_PAID = 'paid'.freeze
|
6
|
+
STATUS_SHIPPING = 'shipping'.freeze
|
7
|
+
STATUS_EXPIRED = 'expired'.freeze
|
8
|
+
STATUS_CANCELED = 'canceled'.freeze
|
9
|
+
STATUS_COMPLETED = 'completed'.freeze
|
10
|
+
|
11
|
+
attr_accessor :id,
|
12
|
+
:profile_id,
|
13
|
+
:method,
|
14
|
+
:mode,
|
15
|
+
:amount,
|
16
|
+
:amount_captured,
|
17
|
+
:amount_refunded,
|
18
|
+
:status,
|
19
|
+
:is_cancelable,
|
20
|
+
:billing_address,
|
21
|
+
:consumer_date_of_birth,
|
22
|
+
:order_number,
|
23
|
+
:shipping_address,
|
24
|
+
:locale,
|
25
|
+
:metadata,
|
26
|
+
:redirect_url,
|
27
|
+
:webhook_url,
|
28
|
+
:created_at,
|
29
|
+
:expires_at,
|
30
|
+
:expired_at,
|
31
|
+
:paid_at,
|
32
|
+
:authorized_at,
|
33
|
+
:canceled_at,
|
34
|
+
:completed_at,
|
35
|
+
:lines,
|
36
|
+
:_links
|
37
|
+
|
38
|
+
alias links _links
|
39
|
+
|
40
|
+
def pending?
|
41
|
+
status == STATUS_PENDING
|
42
|
+
end
|
43
|
+
|
44
|
+
def authorized?
|
45
|
+
status == STATUS_AUTHORIZED
|
46
|
+
end
|
47
|
+
|
48
|
+
def paid?
|
49
|
+
status == STATUS_PAID
|
50
|
+
end
|
51
|
+
|
52
|
+
def shipping?
|
53
|
+
status == STATUS_SHIPPING
|
54
|
+
end
|
55
|
+
|
56
|
+
def expired?
|
57
|
+
status == STATUS_EXPIRED
|
58
|
+
end
|
59
|
+
|
60
|
+
def canceled?
|
61
|
+
status == STATUS_CANCELED
|
62
|
+
end
|
63
|
+
|
64
|
+
def completed?
|
65
|
+
status == STATUS_COMPLETED
|
66
|
+
end
|
67
|
+
|
68
|
+
def cancelable?
|
69
|
+
is_cancelable
|
70
|
+
end
|
71
|
+
|
72
|
+
def checkout_url
|
73
|
+
Util.extract_url(links, 'checkout')
|
74
|
+
end
|
75
|
+
|
76
|
+
def lines=(lines)
|
77
|
+
@lines = lines.map { |line| Order::Line.new(line) }
|
78
|
+
end
|
79
|
+
|
80
|
+
def amount=(amount)
|
81
|
+
@amount = Mollie::Amount.new(amount)
|
82
|
+
end
|
83
|
+
|
84
|
+
def amount_captured=(amount)
|
85
|
+
@amount_captured = Mollie::Amount.new(amount)
|
86
|
+
end
|
87
|
+
|
88
|
+
def amount_refunded=(amount)
|
89
|
+
@amount_refunded = Mollie::Amount.new(amount)
|
90
|
+
end
|
91
|
+
|
92
|
+
def billing_address=(address)
|
93
|
+
@billing_address = OpenStruct.new(address) if address.is_a?(Hash)
|
94
|
+
end
|
95
|
+
|
96
|
+
def shipping_address=(address)
|
97
|
+
@shipping_address = OpenStruct.new(address) if address.is_a?(Hash)
|
98
|
+
end
|
99
|
+
|
100
|
+
def metadata=(metadata)
|
101
|
+
@metadata = OpenStruct.new(metadata) if metadata.is_a?(Hash)
|
102
|
+
end
|
103
|
+
|
104
|
+
def created_at=(created_at)
|
105
|
+
@created_at = Time.parse(created_at.to_s)
|
106
|
+
end
|
107
|
+
|
108
|
+
def expires_at=(expires_at)
|
109
|
+
@expires_at = Time.parse(expires_at.to_s)
|
110
|
+
end
|
111
|
+
|
112
|
+
def expired_at=(expired_at)
|
113
|
+
@expired_at = Time.parse(expired_at.to_s)
|
114
|
+
end
|
115
|
+
|
116
|
+
def paid_at=(paid_at)
|
117
|
+
@paid_at = Time.parse(paid_at.to_s)
|
118
|
+
end
|
119
|
+
|
120
|
+
def authorized_at=(authorized_at)
|
121
|
+
@authorized_at = Time.parse(authorized_at.to_s)
|
122
|
+
end
|
123
|
+
|
124
|
+
def canceled_at=(canceled_at)
|
125
|
+
@canceled_at = Time.parse(canceled_at.to_s)
|
126
|
+
end
|
127
|
+
|
128
|
+
def completed_at=(completed_at)
|
129
|
+
@completed_at = Time.parse(completed_at.to_s)
|
130
|
+
end
|
131
|
+
|
132
|
+
def refunds(options = {})
|
133
|
+
Order::Refund.all(options.merge(order_id: id))
|
134
|
+
end
|
135
|
+
|
136
|
+
def refund!(options = {})
|
137
|
+
options[:order_id] = id
|
138
|
+
options[:lines] ||= []
|
139
|
+
Order::Refund.create(options)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|