mollie-api-ruby 4.9.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daa3c6e8a7c880ce66a0207c1ea3785e013095d605ad0c3a39b52fe0675c0bab
4
- data.tar.gz: 67135ecb024b74073aa35a0235a929d0a17c2f2ddf495d74eb47afc098963653
3
+ metadata.gz: 1d80bc70f4fab363a9546ef3d08b7ce81d0d67a0bc9bfc4f5ae81f2e55fdb853
4
+ data.tar.gz: e10228e454d164a725c0d977cff690f17f4cdf8d2ad4f85c28c81059ae12bb6d
5
5
  SHA512:
6
- metadata.gz: 8b7deb45b0c8537e38f4f72640398eb93a9a90108fefa9930b2575f8cb9e3c03cbaacdab2e37062d318cedbabe73d4f37a662627440605c1967388026763c015
7
- data.tar.gz: 1d18195babbf2b7a4204849e1ff4fcaf57ce49fbaec01fe238d43cadb2319f01cab3fd08bdad56e745bbcac6748358e33730b564e2b5667f9f8ab3307780a252
6
+ metadata.gz: 313a6f14d2fd5f0ea96f3234a27eb8bbdd334ef7053fb290f416b5f13ceb29b8a9cf15809e37ec103db6d1721f334c39f1962eab3029814f3e404cc812a5b20a
7
+ data.tar.gz: 5fb49b6d256cc78d63c7ed41eaf9e1478c1a6ac8c413fb92e66cf2c3d2a58417b2c55435f228f0e600bcadaecd71f71a45c29d592f6d39e9659fa3ea21405ef0
@@ -0,0 +1,25 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0']
16
+
17
+ name: Ruby (${{ matrix.ruby-version }})
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ - name: Run tests
25
+ run: bundle install && bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ ## 4.10.0 - 2021-11-20
8
+
9
+ :warning: The `Profile#category_code` attribute is deprecated and will be removed in 2022. Please use the `business_category` parameter instead.
10
+
11
+ - (f0e695c) Order: add methods to retrieve embedded resources
12
+ - (e16864c) Order: add class to create order payments
13
+ - (5175cd3) Profile: add `business_category` attribute
14
+ - (3d2e370) Payment: add `amount_charged_back` attribute
15
+ - (3d6b403) Fix assignment method for `amount_captured`
16
+ - (37280c3) Migrate from Travis CI to GitHub Actions
17
+ - (33bb6bb) Add example to update orderlines
18
+ - (c70dbf6) fix: orderline update returns incorrect class
19
+ - (ca5935d) Add example to retrieve all available payment methods
20
+ - (457b853) Add "List all payment methods" API
21
+ - (9d8eebc) Method: add status attribute (#147)
22
+ - (506d52e) fix: Include parent resource in pagination calls
23
+ - (7e3b98d) Fix onboarding dashboard URL.
24
+
7
25
  ## 4.9.0 - 2020-05-17
8
26
 
9
27
  - Settlement: add `captures` helper method.
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  > LOOKING FOR VERSION v3.1.X README? [CLICK HERE](https://github.com/mollie/mollie-api-ruby/tree/v3.1.6)
11
11
 
12
12
  [![Gem Version](https://badge.fury.io/rb/mollie-api-ruby.svg)](https://badge.fury.io/rb/mollie-api-ruby)
13
- [![](https://travis-ci.org/mollie/mollie-api-ruby.png)](https://travis-ci.org/mollie/mollie-api-ruby)
13
+ [![Build Status](https://github.com/mollie/mollie-api-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/mollie/mollie-api-ruby/actions/workflows/build.yml)
14
14
 
15
15
  Accepting [iDEAL](https://www.mollie.com/en/payments/ideal), [Bancontact](https://www.mollie.com/en/payments/bancontact), [SOFORT Banking](https://www.mollie.com/en/payments/sofort), [Creditcard](https://www.mollie.com/en/payments/credit-card), [SEPA Bank transfer](https://www.mollie.com/en/payments/bank-transfer), [SEPA Direct debit](https://www.mollie.com/en/payments/direct-debit), [PayPal](https://www.mollie.com/en/payments/paypal), [KBC/CBC Payment Button](https://www.mollie.com/en/payments/kbc-cbc), [Belfius Direct Net](https://www.mollie.com/en/payments/belfius), [paysafecard](https://www.mollie.com/en/payments/paysafecard), [ING Home’Pay](https://www.mollie.com/en/payments/ing-homepay), [Gift cards](https://www.mollie.com/en/payments/gift-cards), [EPS](https://www.mollie.com/en/payments/eps), [Giropay](https://www.mollie.com/en/payments/giropay) and [Apple Pay](https://www.mollie.com/en/payments/apple-pay) online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.
16
16
 
@@ -2,3 +2,7 @@ methods = Mollie::Method.all
2
2
 
3
3
  # Filter by amount and currency
4
4
  methods = Mollie::Method.all(amount: { value: '100.00', currency: 'EUR' })
5
+
6
+ # Retrieve all payment methods that Mollie offers and can be activated by
7
+ # the Organization.
8
+ methods = Mollie::Method.all_available
@@ -0,0 +1 @@
1
+ payment = Mollie::Order::Payment.create(order_id: "ord_kEn1PlbGa")
@@ -1 +1,4 @@
1
- order = Mollie::Order.get('ord_kEn1PlbGa')
1
+ order = Mollie::Order.get("ord_kEn1PlbGa")
2
+
3
+ # Embed related resources
4
+ order = Mollie::Order.get("ord_kEn1PlbGa", embed: "payments,refunds,shipments")
@@ -0,0 +1,7 @@
1
+ orderline_id = "odl_dgtxyl"
2
+
3
+ order = Mollie::Order::Line.update(
4
+ orderline_id,
5
+ order_id: "ord_kEn1PlbGa",
6
+ sku: "new-sku-12345678"
7
+ )
@@ -1,8 +1,8 @@
1
1
  profile = Mollie::Profile.create(
2
- name: 'My website name',
3
- website: 'https://www.mywebsite.com',
4
- email: 'info@mywebsite.com',
5
- phone: '+31208202070',
6
- categoryCode: '5399',
7
- mode: 'live'
2
+ name: 'My website name',
3
+ website: 'https://www.mywebsite.com',
4
+ email: 'info@mywebsite.com',
5
+ phone: '+31208202070',
6
+ business_category: 'OTHER_MERCHANDISE',
7
+ mode: 'live'
8
8
  )
data/lib/mollie/list.rb CHANGED
@@ -38,7 +38,8 @@ module Mollie
38
38
  href = URI.parse(links['next']['href'])
39
39
  query = URI.decode_www_form(href.query).to_h
40
40
 
41
- klass.all(options.merge(query))
41
+ response = Mollie::Client.instance.perform_http_call('GET', links['next']['href'], nil, {}, options.merge(query))
42
+ self.class.new(response, klass)
42
43
  end
43
44
 
44
45
  def previous(options = {})
@@ -47,7 +48,8 @@ module Mollie
47
48
  href = URI.parse(links['previous']['href'])
48
49
  query = URI.decode_www_form(href.query).to_h
49
50
 
50
- klass.all(options.merge(query))
51
+ response = Mollie::Client.instance.perform_http_call('GET', links['previous']['href'], nil, {}, options.merge(query))
52
+ self.class.new(response, klass)
51
53
  end
52
54
  end
53
55
  end
data/lib/mollie/method.rb CHANGED
@@ -25,7 +25,13 @@ module Mollie
25
25
  :maximum_amount,
26
26
  :image,
27
27
  :issuers,
28
- :pricing
28
+ :pricing,
29
+ :status
30
+
31
+ def self.all_available(options = {})
32
+ response = Client.instance.perform_http_call("GET", "methods", "all", {}, options)
33
+ Mollie::List.new(response, Mollie::Method)
34
+ end
29
35
 
30
36
  def minimum_amount=(minimum_amount)
31
37
  @minimum_amount = Mollie::Amount.new(minimum_amount)
@@ -20,7 +20,7 @@ module Mollie
20
20
  end
21
21
 
22
22
  def dashboard
23
- Util.extract_url(links, 'onboarding')
23
+ Util.extract_url(links, 'dashboard')
24
24
  end
25
25
 
26
26
  def organization(options = {})
@@ -29,6 +29,10 @@ module Mollie
29
29
 
30
30
  alias links _links
31
31
 
32
+ def self.update(id, data = {})
33
+ request('PATCH', id, data) { |response| Order.new(response) }
34
+ end
35
+
32
36
  def cancelable?
33
37
  is_cancelable == true
34
38
  end
@@ -0,0 +1,6 @@
1
+ module Mollie
2
+ class Order
3
+ class Payment < ::Mollie::Payment
4
+ end
5
+ end
6
+ end
data/lib/mollie/order.rb CHANGED
@@ -130,8 +130,36 @@ module Mollie
130
130
  @completed_at = Time.parse(completed_at.to_s)
131
131
  end
132
132
 
133
+ def payments
134
+ resources = (attributes['_embedded']['payments'] if attributes['_embedded'])
135
+
136
+ if resources.nil?
137
+ List.new({}, Order::Payment)
138
+ else
139
+ List.new({ '_embedded' => { 'payments' => resources } }, Order::Payment)
140
+ end
141
+ end
142
+
133
143
  def refunds(options = {})
134
- Order::Refund.all(options.merge(order_id: id))
144
+ resources = (attributes['_embedded']['refunds'] if attributes['_embedded'])
145
+
146
+ if resources.nil?
147
+ # To avoid breaking changes, fallback to /v2/order/*orderId*/refunds
148
+ # if the order was retrieved without embedded refunds.
149
+ Order::Refund.all(options.merge(order_id: id))
150
+ else
151
+ List.new({ '_embedded' => { 'refunds' => resources } }, Order::Refund)
152
+ end
153
+ end
154
+
155
+ def shipments
156
+ resources = (attributes['_embedded']['shipments'] if attributes['_embedded'])
157
+
158
+ if resources.nil?
159
+ List.new({}, Order::Shipment)
160
+ else
161
+ List.new({ '_embedded' => { 'shipments' => resources } }, Order::Shipment)
162
+ end
135
163
  end
136
164
 
137
165
  def refund!(options = {})
@@ -25,6 +25,7 @@ module Mollie
25
25
  :failed_at,
26
26
  :amount,
27
27
  :amount_captured,
28
+ :amount_charged_back,
28
29
  :amount_refunded,
29
30
  :amount_remaining,
30
31
  :description,
@@ -167,10 +168,14 @@ module Mollie
167
168
  @settlement_amount = Mollie::Amount.new(settlement_amount)
168
169
  end
169
170
 
170
- def amount_captured
171
+ def amount_captured=(amount_captured)
171
172
  @amount_captured = Mollie::Amount.new(amount_captured)
172
173
  end
173
174
 
175
+ def amount_charged_back=(amount_charged_back)
176
+ @amount_charged_back = Mollie::Amount.new(amount_charged_back)
177
+ end
178
+
174
179
  def amount_remaining=(amount_remaining)
175
180
  @amount_remaining = Mollie::Amount.new(amount_remaining)
176
181
  end
@@ -24,7 +24,9 @@ module Mollie
24
24
  :website,
25
25
  :email,
26
26
  :phone,
27
- :category_code,
27
+ :business_category,
28
+ :category_code, # This parameter is deprecated and will be removed in 2022.
29
+ # Please use the businessCategory parameter instead.
28
30
  :status,
29
31
  :review,
30
32
  :created_at,
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.9.0'.freeze
2
+ VERSION = '4.10.0'.freeze
3
3
  end
data/lib/mollie.rb CHANGED
@@ -33,6 +33,7 @@ require 'mollie/customer/payment'
33
33
  require 'mollie/customer/subscription'
34
34
  require 'mollie/onboarding'
35
35
  require 'mollie/order/line'
36
+ require 'mollie/order/payment'
36
37
  require 'mollie/order/refund'
37
38
  require 'mollie/order/shipment'
38
39
  require 'mollie/payment/capture'
@@ -0,0 +1,36 @@
1
+ {
2
+ "resource": "customer",
3
+ "id": "cst_8wmqcHMN4U",
4
+ "mode": "test",
5
+ "name": "Customer A",
6
+ "email": "customer@example.org",
7
+ "locale": "nl_NL",
8
+ "metadata": null,
9
+ "createdAt": "2018-04-06T13:23:21.0Z",
10
+ "_links": {
11
+ "self": {
12
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U",
13
+ "type": "application/hal+json"
14
+ },
15
+ "dashboard": {
16
+ "href": "https://www.mollie.com/dashboard/org_123456789/customers/cst_8wmqcHMN4U",
17
+ "type": "text/html"
18
+ },
19
+ "mandates": {
20
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/mandates",
21
+ "type": "application/hal+json"
22
+ },
23
+ "subscriptions": {
24
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/subscriptions",
25
+ "type": "application/hal+json"
26
+ },
27
+ "payments": {
28
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments",
29
+ "type": "application/hal+json"
30
+ },
31
+ "documentation": {
32
+ "href": "https://docs.mollie.com/reference/v2/customers-api/get-customer",
33
+ "type": "text/html"
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "count": 2,
3
+ "_embedded": {
4
+ "payments": [
5
+ {
6
+ "resource": "payment",
7
+ "id":"tr_3"
8
+ },
9
+ {
10
+ "resource": "payment",
11
+ "id":"tr_4"
12
+ }
13
+ ]
14
+ },
15
+ "_links": {
16
+ "documentation": {
17
+ "href": "https://docs.mollie.com/reference/v2/customers-api/list-customer-payments",
18
+ "type": "text/html"
19
+ },
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_3&limit=2",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": {
25
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_1&limit=2",
26
+ "type": "application/hal+json"
27
+ },
28
+ "next": null
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "count": 2,
3
+ "_embedded": {
4
+ "payments": [
5
+ {
6
+ "resource": "payment",
7
+ "id":"tr_1"
8
+ },
9
+ {
10
+ "resource": "payment",
11
+ "id":"tr_2"
12
+ }
13
+ ]
14
+ },
15
+ "_links": {
16
+ "documentation": {
17
+ "href": "https://docs.mollie.com/reference/v2/customers-api/list-customer-payments",
18
+ "type": "text/html"
19
+ },
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?limit=2",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": null,
25
+ "next": {
26
+ "href": "https://api.mollie.com/v2/customers/cst_8wmqcHMN4U/payments?from=tr_3&limit=2",
27
+ "type": "application/hal+json"
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,92 @@
1
+ {
2
+ "count": 3,
3
+ "_embedded": {
4
+ "methods": [
5
+ {
6
+ "resource": "method",
7
+ "id": "ideal",
8
+ "description": "iDEAL",
9
+ "minimumAmount": {
10
+ "value": "0.01",
11
+ "currency": "EUR"
12
+ },
13
+ "maximumAmount": {
14
+ "value": "50000.00",
15
+ "currency": "EUR"
16
+ },
17
+ "image": {
18
+ "size1x": "https://www.mollie.com/external/icons/payment-methods/ideal.png",
19
+ "size2x": "https://www.mollie.com/external/icons/payment-methods/ideal%402x.png",
20
+ "svg": "https://www.mollie.com/external/icons/payment-methods/ideal.svg"
21
+ },
22
+ "status": "pending-boarding",
23
+ "_links": {
24
+ "self": {
25
+ "href": "https://api.mollie.com/v2/methods/ideal",
26
+ "type": "application/hal+json"
27
+ }
28
+ }
29
+ },
30
+ {
31
+ "resource": "method",
32
+ "id": "creditcard",
33
+ "description": "Credit card",
34
+ "minimumAmount": {
35
+ "value": "0.01",
36
+ "currency": "EUR"
37
+ },
38
+ "maximumAmount": {
39
+ "value": "2000.00",
40
+ "currency": "EUR"
41
+ },
42
+ "image": {
43
+ "size1x": "https://www.mollie.com/external/icons/payment-methods/creditcard.png",
44
+ "size2x": "https://www.mollie.com/external/icons/payment-methods/creditcard%402x.png",
45
+ "svg": "https://www.mollie.com/external/icons/payment-methods/creditcard.svg"
46
+ },
47
+ "status": "pending-boarding",
48
+ "_links": {
49
+ "self": {
50
+ "href": "https://api.mollie.com/v2/methods/creditcard",
51
+ "type": "application/hal+json"
52
+ }
53
+ }
54
+ },
55
+ {
56
+ "resource": "method",
57
+ "id": "bancontact",
58
+ "description": "Bancontact",
59
+ "minimumAmount": {
60
+ "value": "0.02",
61
+ "currency": "EUR"
62
+ },
63
+ "maximumAmount": {
64
+ "value": "50000.00",
65
+ "currency": "EUR"
66
+ },
67
+ "image": {
68
+ "size1x": "https://www.mollie.com/external/icons/payment-methods/bancontact.png",
69
+ "size2x": "https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png",
70
+ "svg": "https://www.mollie.com/external/icons/payment-methods/bancontact.svg"
71
+ },
72
+ "status": null,
73
+ "_links": {
74
+ "self": {
75
+ "href": "https://api.mollie.com/v2/methods/bancontact",
76
+ "type": "application/hal+json"
77
+ }
78
+ }
79
+ }
80
+ ]
81
+ },
82
+ "_links": {
83
+ "documentation": {
84
+ "href": "https://docs.mollie.com/reference/v2/methods-api/list-all-methods",
85
+ "type": "text/html"
86
+ },
87
+ "self": {
88
+ "href": "https://api.mollie.com/v2/methods/all",
89
+ "type": "application/hal+json"
90
+ }
91
+ }
92
+ }
@@ -10,7 +10,7 @@
10
10
  "href": "https://api.mollie.com/v2/onboarding/me",
11
11
  "type": "application/hal+json"
12
12
  },
13
- "onboarding": {
13
+ "dashboard": {
14
14
  "href": "https://www.mollie.com/dashboard/onboarding",
15
15
  "type": "text/html"
16
16
  },
@@ -0,0 +1,38 @@
1
+ {
2
+ "resource": "payment",
3
+ "id": "tr_ncaPcAhuUV",
4
+ "mode": "live",
5
+ "createdAt": "2018-09-07T12:00:05+00:00",
6
+ "amount": {
7
+ "value": "1027.99",
8
+ "currency": "EUR"
9
+ },
10
+ "description": "Order #1337 (Lego cars)",
11
+ "method": null,
12
+ "metadata": null,
13
+ "status": "open",
14
+ "isCancelable": false,
15
+ "locale": "nl_NL",
16
+ "profileId": "pfl_URR55HPMGx",
17
+ "orderId": "ord_kEn1PlbGa",
18
+ "sequenceType": "oneoff",
19
+ "redirectUrl": "https://example.org/redirect",
20
+ "_links": {
21
+ "self": {
22
+ "href": "https://api.mollie.com/v2/payments/tr_ncaPcAhuUV",
23
+ "type": "application/hal+json"
24
+ },
25
+ "checkout": {
26
+ "href": "https://www.mollie.com/payscreen/select-method/ncaPcAhuUV",
27
+ "type": "text/html"
28
+ },
29
+ "dashboard": {
30
+ "href": "https://www.mollie.com/dashboard/org_123456789/payments/tr_ncaPcAhuUV",
31
+ "type": "text/html"
32
+ },
33
+ "order": {
34
+ "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
35
+ "type": "application/hal+json"
36
+ }
37
+ }
38
+ }
@@ -171,44 +171,6 @@
171
171
  }
172
172
  }
173
173
  ],
174
- "_embedded": {
175
- "payments": [
176
- {
177
- "resource": "payment",
178
- "id": "tr_ncaPcAhuUV",
179
- "mode": "live",
180
- "createdAt": "2018-09-07T12:00:05+00:00",
181
- "amount": {
182
- "value": "1027.99",
183
- "currency": "EUR"
184
- },
185
- "description": "Order #1337 (Lego cars)",
186
- "method": null,
187
- "metadata": null,
188
- "status": "open",
189
- "isCancelable": false,
190
- "locale": "nl_NL",
191
- "profileId": "pfl_URR55HPMGx",
192
- "orderId": "ord_kEn1PlbGa",
193
- "sequenceType": "oneoff",
194
- "redirectUrl": "https://example.org/redirect",
195
- "_links": {
196
- "self": {
197
- "href": "https://api.mollie.com/v2/payments/tr_ncaPcAhuUV",
198
- "type": "application/hal+json"
199
- },
200
- "checkout": {
201
- "href": "https://www.mollie.com/payscreen/select-method/ncaPcAhuUV",
202
- "type": "text/html"
203
- },
204
- "order": {
205
- "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",
206
- "type": "application/hal+json"
207
- }
208
- }
209
- }
210
- ]
211
- },
212
174
  "_links": {
213
175
  "self": {
214
176
  "href": "https://api.mollie.com/v2/orders/ord_kEn1PlbGa",