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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +6 -0
  3. data/examples/captures/get-payment.rb +2 -0
  4. data/examples/captures/get-settlement.rb +2 -0
  5. data/examples/captures/get-shipment.rb +2 -0
  6. data/examples/captures/get.rb +4 -0
  7. data/examples/captures/list.rb +1 -0
  8. data/examples/orders/cancel-lines.rb +2 -0
  9. data/examples/orders/cancel.rb +5 -0
  10. data/examples/orders/create-refund.rb +15 -0
  11. data/examples/orders/create.rb +88 -0
  12. data/examples/orders/get.rb +1 -0
  13. data/examples/orders/list-refunds.rb +1 -0
  14. data/examples/orders/list.rb +1 -0
  15. data/examples/orders/update.rb +15 -0
  16. data/examples/payments/get-order.rb +2 -0
  17. data/examples/refunds/get-order.rb +2 -0
  18. data/examples/shipments/create.rb +17 -0
  19. data/examples/shipments/get-order.rb +2 -0
  20. data/examples/shipments/get.rb +4 -0
  21. data/examples/shipments/list.rb +1 -0
  22. data/examples/shipments/update.rb +9 -0
  23. data/lib/mollie.rb +5 -0
  24. data/lib/mollie/base.rb +2 -0
  25. data/lib/mollie/exception.rb +1 -1
  26. data/lib/mollie/list.rb +8 -0
  27. data/lib/mollie/order.rb +142 -0
  28. data/lib/mollie/order/line.rb +95 -0
  29. data/lib/mollie/order/refund.rb +6 -0
  30. data/lib/mollie/order/shipment.rb +34 -0
  31. data/lib/mollie/payment.rb +17 -6
  32. data/lib/mollie/payment/capture.rb +43 -0
  33. data/lib/mollie/refund.rb +11 -0
  34. data/lib/mollie/version.rb +1 -1
  35. data/test/fixtures/captures/get.json +39 -0
  36. data/test/fixtures/captures/list.json +58 -0
  37. data/test/fixtures/orders/cancel_line.json +8 -0
  38. data/test/fixtures/orders/cancel_line_qty.json +8 -0
  39. data/test/fixtures/orders/create.json +88 -0
  40. data/test/fixtures/orders/create_refund.json +9 -0
  41. data/test/fixtures/orders/get.json +218 -0
  42. data/test/fixtures/orders/list.json +34 -0
  43. data/test/fixtures/orders/list_refunds.json +85 -0
  44. data/test/fixtures/orders/refund.json +63 -0
  45. data/test/fixtures/orders/refund_all.json +3 -0
  46. data/test/fixtures/orders/update.json +14 -0
  47. data/test/fixtures/refunds/get.json +111 -0
  48. data/test/fixtures/shipments/create.json +16 -0
  49. data/test/fixtures/shipments/get.json +101 -0
  50. data/test/fixtures/shipments/list.json +74 -0
  51. data/test/fixtures/shipments/update.json +7 -0
  52. data/test/helper.rb +4 -0
  53. data/test/mollie/list_test.rb +3 -0
  54. data/test/mollie/order/line_test.rb +45 -0
  55. data/test/mollie/order/shipment_test.rb +143 -0
  56. data/test/mollie/order_test.rb +289 -0
  57. data/test/mollie/payment/capture_test.rb +77 -0
  58. data/test/mollie/payment_test.rb +33 -0
  59. data/test/mollie/refund_test.rb +64 -0
  60. metadata +101 -34
@@ -0,0 +1,9 @@
1
+ {
2
+ "lines": [
3
+ {
4
+ "id": "odl_dgtxyl",
5
+ "quantity": 1
6
+ }
7
+ ],
8
+ "description": "Required quantity not in stock, refunding one photo book."
9
+ }
@@ -0,0 +1,218 @@
1
+ {
2
+ "resource": "order",
3
+ "id": "ord_kEn1PlbGa",
4
+ "profileId": "pfl_URR55HPMGx",
5
+ "method": "ideal",
6
+ "amount": {
7
+ "value": "1027.99",
8
+ "currency": "EUR"
9
+ },
10
+ "amountCaptured": {
11
+ "value": "1002.99",
12
+ "currency": "EUR"
13
+ },
14
+ "amountRefunded": {
15
+ "value": "25.00",
16
+ "currency": "EUR"
17
+ },
18
+ "status": "created",
19
+ "isCancelable": true,
20
+ "metadata": {
21
+ "order_id": "1337",
22
+ "description": "Lego cars"
23
+ },
24
+ "createdAt": "2018-08-02T09:29:56+00:00",
25
+ "expiresAt": "2018-08-30T09:29:56+00:00",
26
+ "mode": "live",
27
+ "locale": "nl_NL",
28
+ "billingAddress": {
29
+ "streetAndNumber": "Keizersgracht 313",
30
+ "postalCode": "1016 EE",
31
+ "city": "Amsterdam",
32
+ "country": "nl",
33
+ "givenName": "Luke",
34
+ "familyName": "Skywalker",
35
+ "email": "luke@skywalker.com"
36
+ },
37
+ "orderNumber": "18475",
38
+ "shippingAddress": {
39
+ "streetAndNumber": "Keizersgracht 313",
40
+ "postalCode": "1016 EE",
41
+ "city": "Amsterdam",
42
+ "country": "nl",
43
+ "givenName": "Luke",
44
+ "familyName": "Skywalker",
45
+ "email": "luke@skywalker.com"
46
+ },
47
+ "redirectUrl": "https://example.org/redirect",
48
+ "webhookUrl": "https://example.org/webhook",
49
+ "expiredAt": "2018-08-30T09:29:56+00:02",
50
+ "paidAt": "2018-08-26T09:29:56+00:00",
51
+ "authorizedAt": "2018-08-25T09:29:56+00:00",
52
+ "canceledAt": "2018-08-27T09:29:56+00:00",
53
+ "completedAt": "2018-08-28T09:29:56+00:00",
54
+ "lines": [
55
+ {
56
+ "resource": "orderline",
57
+ "id": "odl_dgtxyl",
58
+ "orderId": "ord_kEn1PlbGa",
59
+ "name": "LEGO 42083 Bugatti Chiron",
60
+ "sku": "5702016116977",
61
+ "type": "physical",
62
+ "status": "created",
63
+ "isCancelable": true,
64
+ "quantity": 2,
65
+ "quantityShipped": 0,
66
+ "amountShipped": {
67
+ "value": "0.00",
68
+ "currency": "EUR"
69
+ },
70
+ "quantityRefunded": 0,
71
+ "amountRefunded": {
72
+ "value": "0.00",
73
+ "currency": "EUR"
74
+ },
75
+ "quantityCanceled": 0,
76
+ "amountCanceled": {
77
+ "value": "0.00",
78
+ "currency": "EUR"
79
+ },
80
+ "shippableQuantity": 0,
81
+ "refundableQuantity": 0,
82
+ "cancelableQuantity": 2,
83
+ "unitPrice": {
84
+ "value": "399.00",
85
+ "currency": "EUR"
86
+ },
87
+ "vatRate": "21.00",
88
+ "vatAmount": {
89
+ "value": "121.14",
90
+ "currency": "EUR"
91
+ },
92
+ "discountAmount": {
93
+ "value": "100.00",
94
+ "currency": "EUR"
95
+ },
96
+ "totalAmount": {
97
+ "value": "698.00",
98
+ "currency": "EUR"
99
+ },
100
+ "createdAt": "2018-08-02T09:29:56+00:00",
101
+ "_links": {
102
+ "productUrl": {
103
+ "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
104
+ "type": "text/html"
105
+ },
106
+ "imageUrl": {
107
+ "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
108
+ "type": "text/html"
109
+ }
110
+ }
111
+ },
112
+ {
113
+ "resource": "orderline",
114
+ "id": "odl_jp31jz",
115
+ "orderId": "ord_kEn1PlbGa",
116
+ "name": "LEGO 42056 Porsche 911 GT3 RS",
117
+ "sku": "5702015594028",
118
+ "type": "physical",
119
+ "status": "created",
120
+ "isCancelable": false,
121
+ "quantity": 1,
122
+ "quantityShipped": 0,
123
+ "amountShipped": {
124
+ "value": "0.00",
125
+ "currency": "EUR"
126
+ },
127
+ "quantityRefunded": 0,
128
+ "amountRefunded": {
129
+ "value": "0.00",
130
+ "currency": "EUR"
131
+ },
132
+ "quantityCanceled": 0,
133
+ "amountCanceled": {
134
+ "value": "0.00",
135
+ "currency": "EUR"
136
+ },
137
+ "shippableQuantity": 0,
138
+ "refundableQuantity": 0,
139
+ "cancelableQuantity": 0,
140
+ "unitPrice": {
141
+ "value": "329.99",
142
+ "currency": "EUR"
143
+ },
144
+ "vatRate": "21.00",
145
+ "vatAmount": {
146
+ "value": "57.27",
147
+ "currency": "EUR"
148
+ },
149
+ "totalAmount": {
150
+ "value": "329.99",
151
+ "currency": "EUR"
152
+ },
153
+ "createdAt": "2018-08-02T09:29:56+00:00",
154
+ "_links": {
155
+ "productUrl": {
156
+ "href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
157
+ "type": "text/html"
158
+ },
159
+ "imageUrl": {
160
+ "href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
161
+ "type": "text/html"
162
+ }
163
+ }
164
+ }
165
+ ],
166
+ "_embedded": {
167
+ "payments": [
168
+ {
169
+ "resource": "payment",
170
+ "id": "tr_ncaPcAhuUV",
171
+ "mode": "live",
172
+ "createdAt": "2018-09-07T12:00:05+00:00",
173
+ "amount": {
174
+ "value": "1027.99",
175
+ "currency": "EUR"
176
+ },
177
+ "description": "Order #1337 (Lego cars)",
178
+ "method": null,
179
+ "metadata": null,
180
+ "status": "open",
181
+ "isCancelable": false,
182
+ "locale": "nl_NL",
183
+ "profileId": "pfl_URR55HPMGx",
184
+ "orderId": "ord_kEn1PlbGa",
185
+ "sequenceType": "oneoff",
186
+ "redirectUrl": "https://example.org/redirect",
187
+ "_links": {
188
+ "self": {
189
+ "href": "https://api.mollie.com/v2/payments/tr_ncaPcAhuUV",
190
+ "type": "application/hal+json"
191
+ },
192
+ "checkout": {
193
+ "href": "https://www.mollie.com/payscreen/select-method/ncaPcAhuUV",
194
+ "type": "text/html"
195
+ },
196
+ "order": {
197
+ "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
198
+ "type": "application/hal+json"
199
+ }
200
+ }
201
+ }
202
+ ]
203
+ },
204
+ "_links": {
205
+ "self": {
206
+ "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
207
+ "type": "application/hal+json"
208
+ },
209
+ "checkout": {
210
+ "href": "https://www.mollie.com/payscreen/order/checkout/kEn1PlbGa",
211
+ "type": "text/html"
212
+ },
213
+ "documentation": {
214
+ "href": "https://docs.mollie.com/reference/v2/orders-api/get-order",
215
+ "type": "text/html"
216
+ }
217
+ }
218
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "count": 3,
3
+ "_embedded": {
4
+ "orders": [
5
+ {
6
+ "resource": "order",
7
+ "id": "ord_one"
8
+ },
9
+ {
10
+ "resource": "order",
11
+ "id": "ord_two"
12
+ },
13
+ {
14
+ "resource": "order",
15
+ "id": "ord_three"
16
+ }
17
+ ]
18
+ },
19
+ "_links": {
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/orders",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": null,
25
+ "next": {
26
+ "href": "https://api.mollie.com/v2/orders?from=ord_stTC2WHAuS",
27
+ "type": "application/hal+json"
28
+ },
29
+ "documentation": {
30
+ "href": "https://docs.mollie.com/reference/v2/orders-api/list-orders",
31
+ "type": "text/html"
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,85 @@
1
+ {
2
+ "count": 1,
3
+ "_embedded": {
4
+ "refunds": [
5
+ {
6
+ "resource": "refund",
7
+ "id": "re_4qqhO89gsT",
8
+ "amount": {
9
+ "currency": "EUR",
10
+ "value": "698.00"
11
+ },
12
+ "status": "processing",
13
+ "createdAt": "2018-03-14T17:09:02.0Z",
14
+ "description": "Required quantity not in stock, refunding one photo book.",
15
+ "paymentId": "tr_WDqYK6vllg",
16
+ "orderId": "ord_kEn1PlbGa",
17
+ "lines": [
18
+ {
19
+ "resource": "orderline",
20
+ "id": "odl_dgtxyl",
21
+ "orderId": "ord_kEn1PlbGa",
22
+ "name": "LEGO 42083 Bugatti Chiron",
23
+ "productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
24
+ "imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
25
+ "sku": "5702016116977",
26
+ "type": "physical",
27
+ "status": "refunded",
28
+ "quantity": 2,
29
+ "unitPrice": {
30
+ "value": "399.00",
31
+ "currency": "EUR"
32
+ },
33
+ "vatRate": "21.00",
34
+ "vatAmount": {
35
+ "value": "121.14",
36
+ "currency": "EUR"
37
+ },
38
+ "discountAmount": {
39
+ "value": "100.00",
40
+ "currency": "EUR"
41
+ },
42
+ "totalAmount": {
43
+ "value": "698.00",
44
+ "currency": "EUR"
45
+ },
46
+ "createdAt": "2018-08-02T09:29:56+00:00"
47
+ }
48
+ ],
49
+ "_links": {
50
+ "self": {
51
+ "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT",
52
+ "type": "application/hal+json"
53
+ },
54
+ "payment": {
55
+ "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
56
+ "type": "application/hal+json"
57
+ },
58
+ "order": {
59
+ "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
60
+ "type": "application/hal+json"
61
+ },
62
+ "documentation": {
63
+ "href": "https://docs.mollie.com/reference/v2/refunds-api/get-refund",
64
+ "type": "text/html"
65
+ }
66
+ }
67
+ }
68
+ ]
69
+ },
70
+ "_links": {
71
+ "self": {
72
+ "href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS/refunds?limit=5",
73
+ "type": "application/hal+json"
74
+ },
75
+ "previous": null,
76
+ "next": {
77
+ "href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS/refunds?from=re_APBiGPH2vV&limit=5",
78
+ "type": "application/hal+json"
79
+ },
80
+ "documentation": {
81
+ "href": "https://docs.mollie.com/reference/v2/orders-api/list-order-refunds",
82
+ "type": "text/html"
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "resource": "refund",
3
+ "id": "re_4qqhO89gsT",
4
+ "amount": {
5
+ "currency": "EUR",
6
+ "value": "698.00"
7
+ },
8
+ "status": "pending",
9
+ "createdAt": "2018-03-14T17:09:02.0Z",
10
+ "description": "Required quantity not in stock, refunding one photo book.",
11
+ "paymentId": "tr_WDqYK6vllg",
12
+ "orderId": "ord_kEn1PlbGa",
13
+ "lines": [
14
+ {
15
+ "resource": "orderline",
16
+ "id": "odl_dgtxyl",
17
+ "orderId": "ord_kEn1PlbGa",
18
+ "name": "LEGO 42083 Bugatti Chiron",
19
+ "productUrl": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
20
+ "imageUrl": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
21
+ "sku": "5702016116977",
22
+ "type": "physical",
23
+ "status": "refunded",
24
+ "quantity": 2,
25
+ "unitPrice": {
26
+ "value": "399.00",
27
+ "currency": "EUR"
28
+ },
29
+ "vatRate": "21.00",
30
+ "vatAmount": {
31
+ "value": "121.14",
32
+ "currency": "EUR"
33
+ },
34
+ "discountAmount": {
35
+ "value": "100.00",
36
+ "currency": "EUR"
37
+ },
38
+ "totalAmount": {
39
+ "value": "698.00",
40
+ "currency": "EUR"
41
+ },
42
+ "createdAt": "2018-08-02T09:29:56+00:00"
43
+ }
44
+ ],
45
+ "_links": {
46
+ "self": {
47
+ "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT",
48
+ "type": "application/hal+json"
49
+ },
50
+ "payment": {
51
+ "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
52
+ "type": "application/hal+json"
53
+ },
54
+ "order": {
55
+ "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
56
+ "type": "application/hal+json"
57
+ },
58
+ "documentation": {
59
+ "href": "https://docs.mollie.com/reference/v2/orders-api/create-order-refund",
60
+ "type": "text/html"
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "lines": []
3
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "billingAddress": {
3
+ "city": "Amsterdam",
4
+ "country": "NL",
5
+ "email": "piet@mondriaan.com",
6
+ "familyName": "Mondriaan",
7
+ "givenName": "Piet",
8
+ "phone": "+31208202070",
9
+ "postalCode": "1234AB",
10
+ "region": "Noord-Holland",
11
+ "streetAndNumber": "Keizersgracht 313",
12
+ "title": "Dhr"
13
+ }
14
+ }
@@ -0,0 +1,111 @@
1
+ {
2
+ "resource": "refund",
3
+ "id": "re_4qqhO89gsT",
4
+ "amount": {
5
+ "value": "1027.99",
6
+ "currency": "EUR"
7
+ },
8
+ "status": "pending",
9
+ "createdAt": "2018-09-25T17:40:23+00:00",
10
+ "description": "Required quantity not in stock, refunding one photo book.",
11
+ "orderId": "ord_stTC2WHAuS",
12
+ "paymentId": "tr_WDqYK6vllg",
13
+ "settlementAmount": {
14
+ "value": "-1027.99",
15
+ "currency": "EUR"
16
+ },
17
+ "lines": [
18
+ {
19
+ "resource": "orderline",
20
+ "id": "odl_d1ec55",
21
+ "orderId": "ord_stTC2WHAuS",
22
+ "name": "LEGO 42083 Bugatti Chiron",
23
+ "sku": "5702016116977",
24
+ "type": "physical",
25
+ "status": "completed",
26
+ "isCancelable": false,
27
+ "quantity": 2,
28
+ "unitPrice": {
29
+ "value": "399.00",
30
+ "currency": "EUR"
31
+ },
32
+ "vatRate": "21.00",
33
+ "vatAmount": {
34
+ "value": "121.14",
35
+ "currency": "EUR"
36
+ },
37
+ "totalAmount": {
38
+ "value": "698.00",
39
+ "currency": "EUR"
40
+ },
41
+ "createdAt": "2018-09-23T17:23:13+00:00",
42
+ "discountAmount": {
43
+ "value": "100.00",
44
+ "currency": "EUR"
45
+ },
46
+ "_links": {
47
+ "productUrl": {
48
+ "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083",
49
+ "type": "text/html"
50
+ },
51
+ "imageUrl": {
52
+ "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$",
53
+ "type": "text/html"
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "resource": "orderline",
59
+ "id": "odl_j3eusr",
60
+ "orderId": "ord_stTC2WHAuS",
61
+ "name": "LEGO 42056 Porsche 911 GT3 RS",
62
+ "sku": "5702015594028",
63
+ "type": "physical",
64
+ "status": "completed",
65
+ "isCancelable": false,
66
+ "quantity": 1,
67
+ "unitPrice": {
68
+ "value": "329.99",
69
+ "currency": "EUR"
70
+ },
71
+ "vatRate": "21.00",
72
+ "vatAmount": {
73
+ "value": "57.27",
74
+ "currency": "EUR"
75
+ },
76
+ "totalAmount": {
77
+ "value": "329.99",
78
+ "currency": "EUR"
79
+ },
80
+ "createdAt": "2018-09-23T17:23:13+00:00",
81
+ "_links": {
82
+ "productUrl": {
83
+ "href": "https://shop.lego.com/nl-NL/Porsche-911-GT3-RS-42056",
84
+ "type": "text/html"
85
+ },
86
+ "imageUrl": {
87
+ "href": "https://sh-s7-live-s.legocdn.com/is/image/LEGO/42056?$PDPDefault$",
88
+ "type": "text/html"
89
+ }
90
+ }
91
+ }
92
+ ],
93
+ "_links": {
94
+ "self": {
95
+ "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg/refunds/re_4qqhO89gsT",
96
+ "type": "application/hal+json"
97
+ },
98
+ "payment": {
99
+ "href": "https://api.mollie.com/v2/payments/tr_WDqYK6vllg",
100
+ "type": "application/hal+json"
101
+ },
102
+ "order": {
103
+ "href": "https://api.mollie.com/v2/orders/ord_stTC2WHAuS",
104
+ "type": "application/hal+json"
105
+ },
106
+ "documentation": {
107
+ "href": "https://docs.mollie.com/reference/v2/refunds-api/get-refund",
108
+ "type": "text/html"
109
+ }
110
+ }
111
+ }