mollie-api-ruby 4.12.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74f551510fa882249e3224bd53e50334ccce5d9f4538b0c9fdf94cd86eb25bd1
4
- data.tar.gz: 2208eac855cb783b5183c4b64f604ce9981b2196eeaa92cdfd71061b0e98a56a
3
+ metadata.gz: 727393f8a67630c11c052da7b282456a2ca751cbbd23b39825bca74bbbe5192d
4
+ data.tar.gz: c0c66af4d34388f7ce8648d33a1cb94b8ff0ac433e419ce2996aa55b1f727b0f
5
5
  SHA512:
6
- metadata.gz: 50eb679501ae91cdf624127d13d5e45be32624864c166c3ff75fff563e0accc9e24874142b279c019b48f848f061e87c18f3c8092a34120588ca869de7e01498
7
- data.tar.gz: 54cd23ca6361f723a622d00b05724373632f2ab395dcb51d8343e37467c0a14d7da23b758cd127fc7340c0e7bdd57fea837a1cfaa0b18eb0fb0a8889d1fd3c7c
6
+ metadata.gz: 9d99d066f8f1a02e06158680e5bdef30f329fada43091e49eda123534cb9e7449a0792ae30a30a2ffc0efe1b7c0da587dba14c6bf82e8bd4810cdd025038e93d
7
+ data.tar.gz: 2f6998f5f91999f5c794d2d3479c26552e6487f006221b9e51149f165ec80b7ea392c636e3f2b328e8e0bd13e47bdbcfcc967e5fed67257f33b7ad321ff88768
@@ -12,7 +12,7 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  strategy:
14
14
  matrix:
15
- ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0']
15
+ ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
16
16
 
17
17
  name: Ruby (${{ matrix.ruby-version }})
18
18
  steps:
@@ -0,0 +1,27 @@
1
+ name: Publish gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v[0-9]+.[0-9]+.[0-9]+*
7
+
8
+ jobs:
9
+ publish:
10
+ name: Push gem to RubyGems.org
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
16
+
17
+ steps:
18
+ # Set up
19
+ - uses: actions/checkout@v4
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ bundler-cache: true
24
+ ruby-version: ruby
25
+
26
+ # Release
27
+ - uses: rubygems/release-gem@v1
data/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ ## 4.14.0 - 2024-11-02
8
+
9
+ - (0876f2b) Add Payment Links API
10
+ - (9ab5e1b) Fix dependency warnings (#176)
11
+ - (87a6c9a) Update supported payment methods
12
+ - (afb6251) IMP-610: Use correct authorize URL
13
+ - (002708c) changelog_uri to gemspec
14
+
15
+ ## 4.13.0 - 2024-05-22
16
+
17
+ - (09489be) Add HTTP response details to RequestError
18
+ - (fe5d114) Add Terminals API
19
+
7
20
  ## 4.12.0 - 2023-01-29
8
21
 
9
22
  - (f180b47) Add support for idempotency keys
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  <p align="center">
2
- <img src="https://info.mollie.com/hubfs/github/ruby/logo.png" width="128" height="128"/>
2
+ <img src="https://github.com/mollie/mollie-api-ruby/assets/39294/5d35df48-e5c0-4de6-8541-159d9d8aa6f6.png" width="128" height="128"/>
3
3
  </p>
4
4
  <h1 align="center">Mollie API client for Ruby</h1>
5
5
 
6
- <img src="https://info.mollie.com/hubfs/github/ruby/editor.png" />
6
+ <img src="https://github.com/mollie/mollie-api-ruby/assets/39294/4838e149-4707-41c7-9aeb-bb86e68adc2c.png" />
7
7
 
8
8
  > LOOKING FOR VERSION v2.2.X README? [CLICK HERE](https://github.com/mollie/mollie-api-ruby/tree/v2.2.1)
9
9
 
@@ -24,11 +24,11 @@ To use the Mollie API client, the following things are required:
24
24
 
25
25
  ## Installation
26
26
 
27
- By far the easiest way to install the Mollie API client is to install it with [gem](http://rubygems.org/). Note: v4.8.0 and higher are not published on rubygems.org, see [GH-140](https://github.com/mollie/mollie-api-ruby/issues/140) for details.
27
+ By far the easiest way to install the Mollie API client is to install it with [gem](http://rubygems.org/).
28
28
 
29
29
  ```
30
30
  # Gemfile
31
- gem "mollie-api-ruby", github: "mollie/mollie-api-ruby", tag: "v4.11.0"
31
+ gem "mollie-api-ruby"
32
32
 
33
33
  $ gem install mollie-api-ruby
34
34
  ```
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+
1
3
  task default: %w[test]
2
4
 
3
5
  task :test do
@@ -5,7 +5,7 @@ client = Rack::OAuth2::Client.new(
5
5
  secret: secret,
6
6
  state: 'some_state',
7
7
  redirect_uri: redirect_url,
8
- authorization_endpoint: 'https://www.mollie.com/oauth2/authorize',
8
+ authorization_endpoint: 'https://my.mollie.com/oauth2/authorize',
9
9
  token_endpoint: 'https://api.mollie.com/oauth2/tokens'
10
10
  )
11
11
 
@@ -5,7 +5,7 @@ client = Rack::OAuth2::Client.new(
5
5
  secret: secret,
6
6
  state: 'some_state',
7
7
  redirect_uri: redirect_url,
8
- authorization_endpoint: 'https://www.mollie.com/oauth2/authorize',
8
+ authorization_endpoint: 'https://my.mollie.com/oauth2/authorize',
9
9
  token_endpoint: 'https://api.mollie.com/oauth2/tokens'
10
10
  )
11
11
 
@@ -0,0 +1,5 @@
1
+ payment_link = Mollie::PaymentLink.create(
2
+ description: "Bicycle tires",
3
+ amount: { currency: "EUR", value: "24.95" }
4
+ )
5
+
@@ -0,0 +1 @@
1
+ Mollie::PaymentLink.delete("pl_4Y0eZitmBnQ6IDoMqZQKh")
@@ -0,0 +1 @@
1
+ payment_link = Mollie::PaymentLink.get("pl_4Y0eZitmBnQ6IDoMqZQKh")
@@ -0,0 +1,2 @@
1
+ payment_link = Mollie::PaymentLink.get("pl_4Y0eZitmBnQ6IDoMqZQKh")
2
+ payments = payment_link.payments
@@ -0,0 +1 @@
1
+ payment_links = Mollie::PaymentLink.all
@@ -0,0 +1,5 @@
1
+ payment_link = Mollie::PaymentLink.update(
2
+ "pl_4Y0eZitmBnQ6IDoMqZQKh",
3
+ description: "Bicycle tires",
4
+ archived: true
5
+ )
@@ -0,0 +1 @@
1
+ terminal = Mollie::Terminal.get("term_7MgL4wea46qkRcoTZjWEH")
@@ -0,0 +1 @@
1
+ terminals = Mollie::Terminal.all
data/lib/mollie/base.rb CHANGED
@@ -71,6 +71,8 @@ module Mollie
71
71
  path.last
72
72
  end
73
73
  end
74
+
75
+ alias_method :embedded_resource_name, :resource_name
74
76
  end
75
77
 
76
78
  def update(data = {})
data/lib/mollie/client.rb CHANGED
@@ -130,11 +130,11 @@ module Mollie
130
130
  {} # No Content
131
131
  when 404
132
132
  json = JSON.parse(response.body)
133
- exception = ResourceNotFoundError.new(json)
133
+ exception = ResourceNotFoundError.new(json, response)
134
134
  raise exception
135
135
  else
136
136
  json = JSON.parse(response.body)
137
- exception = Mollie::RequestError.new(json)
137
+ exception = Mollie::RequestError.new(json, response)
138
138
  raise exception
139
139
  end
140
140
  end
@@ -5,17 +5,30 @@ module Mollie
5
5
  class RequestError < Mollie::Exception
6
6
  attr_accessor :status, :title, :detail, :field, :links
7
7
 
8
- def initialize(error)
8
+ def initialize(error, response = nil)
9
9
  exception.status = error['status']
10
10
  exception.title = error['title']
11
11
  exception.detail = error['detail']
12
12
  exception.field = error['field']
13
13
  exception.links = error['_links']
14
+ self.response = response
14
15
  end
15
16
 
16
17
  def to_s
17
18
  "#{status} #{title}: #{detail}"
18
19
  end
20
+
21
+ def http_headers
22
+ response.to_hash if response
23
+ end
24
+
25
+ def http_body
26
+ response.body if response
27
+ end
28
+
29
+ private
30
+
31
+ attr_accessor :response
19
32
  end
20
33
 
21
34
  class ResourceNotFoundError < RequestError
data/lib/mollie/list.rb CHANGED
@@ -9,7 +9,7 @@ module Mollie
9
9
  @klass = klass
10
10
 
11
11
  list_attributes['items'] ||= if list_attributes['_embedded']
12
- list_attributes['_embedded'].fetch(klass.resource_name, [])
12
+ list_attributes['_embedded'].fetch(klass.embedded_resource_name, [])
13
13
  else
14
14
  []
15
15
  end
data/lib/mollie/method.rb CHANGED
@@ -1,21 +1,33 @@
1
1
  module Mollie
2
2
  class Method < Base
3
+ ALMA = 'alma'.freeze
3
4
  APPLEPAY = 'applepay'.freeze
4
5
  BANCONTACT = 'bancontact'.freeze
6
+ BANCOMAT_PAY = 'bancomatpay'.freeze
5
7
  BANKTRANSFER = 'banktransfer'.freeze
6
8
  BELFIUS = 'belfius'.freeze
9
+ BILLIE = 'billie'.freeze
10
+ BLIK = 'bilk'.freeze
7
11
  CREDITCARD = 'creditcard'.freeze
8
12
  DIRECTDEBIT = 'directdebit'.freeze
9
13
  EPS = 'eps'.freeze
10
14
  GIFTCARD = 'giftcard'.freeze
11
15
  GIROPAY = 'giropay'.freeze
12
16
  IDEAL = 'ideal'.freeze
17
+ IN3 = 'in3'.freeze
13
18
  INGHOMEPAY = 'inghomepay'.freeze
14
19
  KBC = 'kbc'.freeze
20
+ MYBANK = 'mybank'.freeze
15
21
  PAYPAL = 'paypal'.freeze
16
22
  PAYSAFECARD = 'paysafecard'.freeze
17
23
  PRZELEWY24 = 'przelewy24'.freeze
24
+ RIVERTY = 'riverty'.freeze
18
25
  SOFORT = 'sofort'.freeze
26
+ SATISPAY = 'satispay'.freeze
27
+ TRUSTLY = 'trustly'.freeze
28
+ TWINT = 'twint'.freeze
29
+ VOUCHER = 'voucher'.freeze
30
+ KLARNA = 'klarna'.freeze
19
31
  KLARNASLICEIT = 'klarnasliceit'.freeze
20
32
  KLARNAPAYLATER = 'klarnapaylater'.freeze
21
33
 
@@ -0,0 +1,70 @@
1
+ module Mollie
2
+ class PaymentLink < Base
3
+ attr_accessor :id,
4
+ :mode,
5
+ :description,
6
+ :archived,
7
+ :redirect_url,
8
+ :webhook_url,
9
+ :profile_id,
10
+ :_links
11
+
12
+ attr_reader :amount,
13
+ :created_at,
14
+ :paid_at,
15
+ :updated_at,
16
+ :expires_at
17
+
18
+ alias_method :links, :_links
19
+
20
+ def self.embedded_resource_name(_parent_id = nil)
21
+ "payment_links"
22
+ end
23
+
24
+ def self.resource_name(_parent_id = nil)
25
+ "payment-links"
26
+ end
27
+
28
+ def amount=(amount)
29
+ @amount = Mollie::Amount.new(amount)
30
+ end
31
+
32
+ def archived?
33
+ archived
34
+ end
35
+
36
+ def created_at=(created_at)
37
+ @created_at = Time.parse(created_at.to_s)
38
+ end
39
+
40
+ def paid_at=(paid_at)
41
+ @paid_at = Time.parse(paid_at.to_s)
42
+ rescue
43
+ nil
44
+ end
45
+
46
+ def updated_at=(updated_at)
47
+ @updated_at = Time.parse(updated_at.to_s)
48
+ rescue
49
+ nil
50
+ end
51
+
52
+ def expires_at=(expires_at)
53
+ @expires_at = Time.parse(expires_at.to_s)
54
+ rescue
55
+ nil
56
+ end
57
+
58
+ def payment_link
59
+ Util.extract_url(links, "payment_link")
60
+ end
61
+
62
+ def payments(options = {})
63
+ resource_url = Util.extract_url(links, "self")
64
+ payments_url = File.join(resource_url, "/payments")
65
+
66
+ response = Mollie::Client.instance.perform_http_call("GET", payments_url, nil, {}, options)
67
+ Mollie::List.new(response, Mollie::Payment)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,59 @@
1
+ module Mollie
2
+ class Terminal < Base
3
+
4
+ STATUS_PENDING = "pending".freeze
5
+ STATUS_ACTIVE = "active".freeze
6
+ STATUS_INACTIVE = "inactive".freeze
7
+
8
+ attr_accessor :id,
9
+ :profile_id,
10
+ :status,
11
+ :brand,
12
+ :model,
13
+ :serial_number,
14
+ :currency,
15
+ :description,
16
+ :created_at,
17
+ :updated_at,
18
+ :deactivated_at,
19
+ :_links
20
+
21
+ alias links _links
22
+
23
+ def pending?
24
+ status == STATUS_PENDING
25
+ end
26
+
27
+ def active?
28
+ status == STATUS_ACTIVE
29
+ end
30
+
31
+ def inactive?
32
+ status == STATUS_INACTIVE
33
+ end
34
+
35
+ def created_at=(created_at)
36
+ @created_at = begin
37
+ Time.parse(created_at.to_s)
38
+ rescue StandardError
39
+ nil
40
+ end
41
+ end
42
+
43
+ def updated_at=(updated_at)
44
+ @updated_at = begin
45
+ Time.parse(updated_at.to_s)
46
+ rescue StandardError
47
+ nil
48
+ end
49
+ end
50
+
51
+ def deactivated_at=(deactivated_at)
52
+ @deactivated_at = begin
53
+ Time.parse(deactivated_at.to_s)
54
+ rescue StandardError
55
+ nil
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.12.0'.freeze
2
+ VERSION = '4.14.0'.freeze
3
3
  end
data/lib/mollie.rb CHANGED
@@ -23,11 +23,13 @@ require 'mollie/order'
23
23
  require 'mollie/organization'
24
24
  require 'mollie/partner'
25
25
  require 'mollie/payment'
26
+ require 'mollie/payment_link'
26
27
  require 'mollie/permission'
27
28
  require 'mollie/profile'
28
29
  require 'mollie/refund'
29
30
  require 'mollie/settlement'
30
31
  require 'mollie/subscription'
32
+ require 'mollie/terminal'
31
33
 
32
34
  require 'mollie/customer/mandate'
33
35
  require 'mollie/customer/payment'
@@ -16,11 +16,18 @@ Gem::Specification.new do |s|
16
16
  s.email = ['info@mollie.com']
17
17
  s.homepage = 'https://github.com/mollie/mollie-api-ruby'
18
18
  s.license = 'BSD'
19
- s.required_ruby_version = '>= 2.3.8'
19
+ s.metadata = {
20
+ 'changelog_uri' => 'https://github.com/mollie/mollie-api-ruby/blob/master/CHANGELOG.md'
21
+ }
22
+
23
+ s.required_ruby_version = '>= 2.5'
20
24
 
21
25
  s.files = `git ls-files`.split("\n")
22
26
  s.test_files = Dir['test/**/*']
23
27
 
28
+ s.add_dependency('ostruct', '~> 0.6.0')
29
+ s.add_dependency('bigdecimal', '~> 3.1', '>= 3.1.8')
30
+
24
31
  s.add_development_dependency('rake')
25
32
  s.add_development_dependency('rubocop', '~> 0.57.2')
26
33
  s.add_development_dependency('test-unit')
@@ -0,0 +1,7 @@
1
+ {
2
+ "description": "Bicycle tires",
3
+ "amount": {
4
+ "currency": "EUR",
5
+ "value": "24.95"
6
+ }
7
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "resource": "payment-link",
3
+ "id": "pl_4Y0eZitmBnQ6IDoMqZQKh",
4
+ "mode": "test",
5
+ "description": "Bicycle tires",
6
+ "archived": false,
7
+ "profile_id": "pfl_QkEhN94Ba",
8
+ "amount": {
9
+ "currency": "EUR",
10
+ "value": "24.95"
11
+ },
12
+ "webhook_url": "https://webshop.example.org/payment-links/webhook",
13
+ "redirect_url": "https://webshop.example.org/thanks",
14
+ "created_at": "2024-09-24T12:16:44+00:00",
15
+ "paid_at": null,
16
+ "updated_at": null,
17
+ "expires_at": null,
18
+ "_links": {
19
+ "self": {
20
+ "href": "https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh",
21
+ "type": "application/hal+json"
22
+ },
23
+ "paymentLink": {
24
+ "href": "https://paymentlink.mollie.com/payment/4Y0eZitmBnQ6IDoMqZQKh",
25
+ "type": "text/html"
26
+ },
27
+ "documentation": {
28
+ "href": "https://docs.mollie.com/reference/v2/payment-links-api/get-payment-link",
29
+ "type": "text/html"
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "count": 3,
3
+ "_embedded": {
4
+ "payments": [
5
+ {
6
+ "resource": "payment",
7
+ "id": "tr_one"
8
+ },
9
+ {
10
+ "resource": "payment",
11
+ "id": "tr_two"
12
+ },
13
+ {
14
+ "resource": "payment",
15
+ "id": "tr_three"
16
+ }
17
+ ]
18
+ },
19
+ "_links": {
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh/payments?limit=50",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": null,
25
+ "next": null,
26
+ "documentation": {
27
+ "href": "https://docs.mollie.com/reference/get-payment-link-payments",
28
+ "type": "text/html"
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "count": 3,
3
+ "_embedded": {
4
+ "payment_links": [
5
+ {
6
+ "resource": "payment-link",
7
+ "id": "pl_one"
8
+ },
9
+ {
10
+ "resource": "payment-link",
11
+ "id": "pl_two"
12
+ },
13
+ {
14
+ "resource": "payment-link",
15
+ "id": "pl_three"
16
+ }
17
+ ]
18
+ },
19
+ "_links": {
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/payment-links?limit=50",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": null,
25
+ "next": null,
26
+ "documentation": {
27
+ "href": "https://docs.mollie.com/reference/v2/payment-links-api/list-payment-links",
28
+ "type": "text/html"
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "description": "Car tires",
3
+ "archived": true
4
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "id": "term_7MgL4wea46qkRcoTZjWEH",
3
+ "profileId": "pfl_QkEhN94Ba",
4
+ "status": "active",
5
+ "brand": "PAX",
6
+ "model": "A920",
7
+ "serialNumber": "1234567890",
8
+ "currency": "EUR",
9
+ "description": "Terminal #12345",
10
+ "createdAt": "2022-02-12T11:58:35.0Z",
11
+ "updatedAt": "2022-11-15T13:32:11+00:00",
12
+ "deactivatedAt": "2022-02-12T12:13:35.0Z",
13
+ "_links": {
14
+ "self": {
15
+ "href": "https://api.mollie.com/v2/terminals/term_7MgL4wea46qkRcoTZjWEH",
16
+ "type": "application/hal+json"
17
+ },
18
+ "documentation": {
19
+ "href": "https://docs.mollie.com/reference/v2/terminals-api/get-terminal",
20
+ "type": "text/html"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "count": 3,
3
+ "_embedded": {
4
+ "terminals": [
5
+ {
6
+ "resource": "terminal",
7
+ "id": "terminal_one"
8
+ },
9
+ {
10
+ "resource": "terminal",
11
+ "id": "terminal_two"
12
+ },
13
+ {
14
+ "resource": "terminal",
15
+ "id": "terminal_three"
16
+ }
17
+ ]
18
+ },
19
+ "_links": {
20
+ "self": {
21
+ "href": "https://api.mollie.com/v2/terminals",
22
+ "type": "application/hal+json"
23
+ },
24
+ "previous": null,
25
+ "next": {
26
+ "href": "https://api.mollie.com/v2/terminals?from=term_7MgL4wea46qkRcoTZjWEH",
27
+ "type": "application/hal+json"
28
+ },
29
+ "documentation": {
30
+ "href": "https://docs.mollie.com/reference/v2/terminals-api/list-terminals",
31
+ "type": "text/html"
32
+ }
33
+ }
34
+ }
@@ -44,6 +44,7 @@ module Mollie
44
44
  assert_equal 'my-id', resource.id
45
45
  assert_equal 'object-id', resource.testobject_id
46
46
  end
47
+
47
48
  def test_get_with_invalid_identifiers
48
49
  assert_raises(Mollie::Exception) { TestObject.get(nil) }
49
50
  assert_raises(Mollie::Exception) { TestObject.get(" ") }
@@ -0,0 +1,87 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class ExceptionTest < Test::Unit::TestCase
5
+ def test_attributes
6
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
7
+ .to_return(status: 422, headers: { "Content-Type" => "application/hal+json}" }, body: %(
8
+ {
9
+ "status": 422,
10
+ "title": "Unprocessable Entity",
11
+ "detail": "The amount is higher than the maximum",
12
+ "field": "amount",
13
+ "_links": {
14
+ "documentation": {
15
+ "href": "https://docs.mollie.com/errors",
16
+ "type": "text/html"
17
+ }
18
+ }
19
+ }
20
+ ))
21
+
22
+ exception = assert_raise(Mollie::RequestError) do
23
+ Mollie::Payment.create(
24
+ amount: { value: "1000000000.00", currency: "EUR" },
25
+ description: "Order #66",
26
+ redirect_url: "https://www.example.org/payment/completed",
27
+ )
28
+ end
29
+
30
+ assert_equal 422, exception.status
31
+ assert_equal "Unprocessable Entity", exception.title
32
+ assert_equal "The amount is higher than the maximum", exception.detail
33
+ assert_equal "amount", exception.field
34
+ assert_equal "https://docs.mollie.com/errors", exception.links["documentation"]["href"]
35
+ assert_equal "text/html", exception.links["documentation"]["type"]
36
+ end
37
+
38
+ def test_exception_message
39
+ stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
40
+ .to_return(status: 401, headers: { "Content-Type" => "application/hal+json}" }, body: %(
41
+ {
42
+ "status": 401,
43
+ "title": "Unauthorized Request",
44
+ "detail": "Missing authentication, or failed to authenticate",
45
+ "_links": {
46
+ "documentation": {
47
+ "href": "https://docs.mollie.com/overview/authentication",
48
+ "type": "text/html"
49
+ }
50
+ }
51
+ }
52
+ ))
53
+
54
+ exception = assert_raise(Mollie::RequestError) { Payment.get('tr_WDqYK6vllg') }
55
+ assert_equal '401 Unauthorized Request: Missing authentication, or failed to authenticate', exception.message
56
+ end
57
+
58
+ def test_http_attributes
59
+ body = %({
60
+ "status": 422,
61
+ "title": "Unprocessable Entity",
62
+ "detail": "The amount is higher than the maximum",
63
+ "field": "amount",
64
+ "_links": {
65
+ "documentation": {
66
+ "href": "https://docs.mollie.com/errors",
67
+ "type": "text/html"
68
+ }
69
+ }
70
+ })
71
+
72
+ stub_request(:post, 'https://api.mollie.com/v2/payments')
73
+ .to_return(status: 422, headers: { "Content-Type" => "application/hal+json" }, body: body)
74
+
75
+ exception = assert_raise(Mollie::RequestError) do
76
+ Mollie::Payment.create(
77
+ amount: { value: "1000000000.00", currency: "EUR" },
78
+ description: "Order #66",
79
+ redirect_url: "https://www.example.org/payment/completed",
80
+ )
81
+ end
82
+
83
+ assert_equal({ "content-type" => ["application/hal+json"] }, exception.http_headers)
84
+ assert_equal(body, exception.http_body)
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,100 @@
1
+ require "helper"
2
+
3
+ module Mollie
4
+ class PaymentLinkTest < Test::Unit::TestCase
5
+ CREATE_PAYMENT_LINK = read_fixture("payment_links/create.json")
6
+ GET_PAYMENT_LINK = read_fixture("payment_links/get.json")
7
+ UPDATE_PAYMENT_LINK = read_fixture("payment_links/update.json")
8
+ LIST_PAYMENT_LINKS = read_fixture("payment_links/list.json")
9
+ LIST_PAYMENT_LINK_PAYMENTS = read_fixture("payment_links/list-payments.json")
10
+
11
+ def test_archived?
12
+ assert PaymentLink.new(archived: true).archived?
13
+ assert_false PaymentLink.new(archived: false).archived?
14
+ end
15
+
16
+ def test_create_payment
17
+ minified_body = JSON.parse(CREATE_PAYMENT_LINK).to_json
18
+ stub_request(:post, "https://api.mollie.com/v2/payment-links")
19
+ .with(body: minified_body)
20
+ .to_return(status: 201, body: GET_PAYMENT_LINK, headers: {})
21
+
22
+ payment_link = PaymentLink.create(
23
+ description: "Bicycle tires",
24
+ amount: {currency: "EUR", value: "24.95"}
25
+ )
26
+
27
+ assert_kind_of PaymentLink, payment_link
28
+ assert_equal "pl_4Y0eZitmBnQ6IDoMqZQKh", payment_link.id
29
+ end
30
+
31
+ def test_get_payment_link
32
+ stub_request(:get, "https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh")
33
+ .to_return(status: 200, body: GET_PAYMENT_LINK, headers: {})
34
+
35
+ payment_link = PaymentLink.get("pl_4Y0eZitmBnQ6IDoMqZQKh")
36
+
37
+ assert_equal "pl_4Y0eZitmBnQ6IDoMqZQKh", payment_link.id
38
+ assert_equal "test", payment_link.mode
39
+ assert_equal "Bicycle tires", payment_link.description
40
+ assert_false payment_link.archived
41
+ assert_equal "pfl_QkEhN94Ba", payment_link.profile_id
42
+ assert_equal 24.95, payment_link.amount.value
43
+ assert_equal "EUR", payment_link.amount.currency
44
+ assert_equal "https://webshop.example.org/payment-links/webhook", payment_link.webhook_url
45
+ assert_equal "https://webshop.example.org/thanks", payment_link.redirect_url
46
+ assert_equal Time.parse("2024-09-24T12:16:44+00:00"), payment_link.created_at
47
+ assert_equal "https://paymentlink.mollie.com/payment/4Y0eZitmBnQ6IDoMqZQKh", payment_link.payment_link
48
+ assert_nil payment_link.paid_at
49
+ assert_nil payment_link.updated_at
50
+ assert_nil payment_link.expires_at
51
+ end
52
+
53
+ def test_update_payment_link
54
+ minified_body = JSON.parse(UPDATE_PAYMENT_LINK).to_json
55
+ stub_request(:patch, 'https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh')
56
+ .with(body: minified_body)
57
+ .to_return(status: 200, body: GET_PAYMENT_LINK, headers: {})
58
+
59
+ payment_link = PaymentLink.update("pl_4Y0eZitmBnQ6IDoMqZQKh", JSON.parse(UPDATE_PAYMENT_LINK))
60
+
61
+ assert_kind_of PaymentLink, payment_link
62
+ assert_equal "pl_4Y0eZitmBnQ6IDoMqZQKh", payment_link.id
63
+ end
64
+
65
+ def test_delete_payment_link
66
+ stub_request(:delete, 'https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh')
67
+ .to_return(status: 204, body: GET_PAYMENT_LINK, headers: {})
68
+
69
+ payment_link = PaymentLink.delete("pl_4Y0eZitmBnQ6IDoMqZQKh")
70
+ assert_nil payment_link
71
+ end
72
+
73
+ def test_list_payment_links
74
+ stub_request(:get, "https://api.mollie.com/v2/payment-links")
75
+ .to_return(status: 200, body: LIST_PAYMENT_LINKS, headers: {})
76
+
77
+ payment_links = PaymentLink.all
78
+ assert_equal 3, payment_links.size
79
+ assert_equal "pl_one", payment_links[0].id
80
+ assert_equal "pl_two", payment_links[1].id
81
+ assert_equal "pl_three", payment_links[2].id
82
+ end
83
+
84
+ def test_list_payment_link_payments
85
+ stub_request(:get, "https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh")
86
+ .to_return(status: 200, body: GET_PAYMENT_LINK, headers: {})
87
+
88
+ stub_request(:get, "https://api.mollie.com/v2/payment-links/pl_4Y0eZitmBnQ6IDoMqZQKh/payments")
89
+ .to_return(status: 200, body: LIST_PAYMENT_LINK_PAYMENTS, headers: {})
90
+
91
+ payment_link = PaymentLink.get("pl_4Y0eZitmBnQ6IDoMqZQKh")
92
+ payments = payment_link.payments
93
+
94
+ assert_equal 3, payments.size
95
+ assert_equal "tr_one", payments[0].id
96
+ assert_equal "tr_two", payments[1].id
97
+ assert_equal "tr_three", payments[2].id
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,54 @@
1
+ require 'helper'
2
+
3
+ module Mollie
4
+ class TerminalTest < Test::Unit::TestCase
5
+ GET_TERMINAL = read_fixture('terminals/get.json')
6
+ LIST_TERMINALS = read_fixture('terminals/list.json')
7
+
8
+ def test_get_terminal
9
+ stub_request(:get, "https://api.mollie.com/v2/terminals/term_7MgL4wea46qkRcoTZjWEH")
10
+ .to_return(status: 200, body: GET_TERMINAL, headers: {})
11
+
12
+ terminal = Terminal.get("term_7MgL4wea46qkRcoTZjWEH")
13
+
14
+ assert_equal "term_7MgL4wea46qkRcoTZjWEH", terminal.id
15
+ assert_equal "pfl_QkEhN94Ba", terminal.profile_id
16
+ assert_equal "active", terminal.status
17
+ assert_equal "PAX", terminal.brand
18
+ assert_equal "A920", terminal.model
19
+ assert_equal "1234567890", terminal.serial_number
20
+ assert_equal "EUR", terminal.currency
21
+ assert_equal "Terminal #12345", terminal.description
22
+ assert_equal Time.parse("2022-02-12T11:58:35.0Z"), terminal.created_at
23
+ assert_equal Time.parse("2022-11-15T13:32:11+00:00"), terminal.updated_at
24
+ assert_equal Time.parse("2022-02-12T12:13:35.0Z"), terminal.deactivated_at
25
+ end
26
+
27
+ def test_status_pending
28
+ assert Terminal.new(status: Terminal::STATUS_PENDING).pending?
29
+ assert !Terminal.new(status: "not-pending").pending?
30
+ end
31
+
32
+ def test_status_active
33
+ assert Terminal.new(status: Terminal::STATUS_ACTIVE).active?
34
+ assert !Terminal.new(status: "not-active").active?
35
+ end
36
+
37
+ def test_status_inactive
38
+ assert Terminal.new(status: Terminal::STATUS_INACTIVE).inactive?
39
+ assert !Terminal.new(status: "not-inactive").inactive?
40
+ end
41
+
42
+ def test_list_terminals
43
+ stub_request(:get, "https://api.mollie.com/v2/terminals")
44
+ .to_return(status: 200, body: LIST_TERMINALS, headers: {})
45
+
46
+ terminals = Terminal.all
47
+
48
+ assert_equal 3, terminals.size
49
+ assert_equal "terminal_one", terminals[0].id
50
+ assert_equal "terminal_two", terminals[1].id
51
+ assert_equal "terminal_three", terminals[2].id
52
+ end
53
+ end
54
+ end
metadata CHANGED
@@ -1,15 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mollie-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mollie B.V.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-25 00:00:00.000000000 Z
11
+ date: 2024-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ostruct
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bigdecimal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.1.8
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.1'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.1.8
13
47
  - !ruby/object:Gem::Dependency
14
48
  name: rake
15
49
  requirement: !ruby/object:Gem::Requirement
@@ -81,10 +115,10 @@ extra_rdoc_files: []
81
115
  files:
82
116
  - ".github/workflows/build.yml"
83
117
  - ".github/workflows/codeql.yml"
118
+ - ".github/workflows/push.yml"
84
119
  - ".gitignore"
85
120
  - ".rubocop.yml"
86
121
  - ".rubocop_todo.yml"
87
- - ".travis.yml"
88
122
  - CHANGELOG.md
89
123
  - Gemfile
90
124
  - LICENSE
@@ -134,6 +168,12 @@ files:
134
168
  - examples/organisations/get-current.rb
135
169
  - examples/organisations/get-partner.rb
136
170
  - examples/organisations/get.rb
171
+ - examples/payment-links/create.rb
172
+ - examples/payment-links/delete.rb
173
+ - examples/payment-links/get.rb
174
+ - examples/payment-links/list-payments.rb
175
+ - examples/payment-links/list.rb
176
+ - examples/payment-links/update.rb
137
177
  - examples/payments/create.rb
138
178
  - examples/payments/delete.rb
139
179
  - examples/payments/get-customer.rb
@@ -180,6 +220,8 @@ files:
180
220
  - examples/subscriptions/get.rb
181
221
  - examples/subscriptions/list.rb
182
222
  - examples/subscriptions/update.rb
223
+ - examples/terminals/get.rb
224
+ - examples/terminals/list.rb
183
225
  - lib/cacert.pem
184
226
  - lib/mollie-api-ruby.rb
185
227
  - lib/mollie.rb
@@ -207,6 +249,7 @@ files:
207
249
  - lib/mollie/payment/capture.rb
208
250
  - lib/mollie/payment/chargeback.rb
209
251
  - lib/mollie/payment/refund.rb
252
+ - lib/mollie/payment_link.rb
210
253
  - lib/mollie/permission.rb
211
254
  - lib/mollie/profile.rb
212
255
  - lib/mollie/refund.rb
@@ -216,6 +259,7 @@ files:
216
259
  - lib/mollie/settlement/payment.rb
217
260
  - lib/mollie/settlement/refund.rb
218
261
  - lib/mollie/subscription.rb
262
+ - lib/mollie/terminal.rb
219
263
  - lib/mollie/util.rb
220
264
  - lib/mollie/version.rb
221
265
  - mollie-api-ruby.gemspec
@@ -242,6 +286,11 @@ files:
242
286
  - test/fixtures/orders/update.json
243
287
  - test/fixtures/orders/update_line.json
244
288
  - test/fixtures/organizations/partner.json
289
+ - test/fixtures/payment_links/create.json
290
+ - test/fixtures/payment_links/get.json
291
+ - test/fixtures/payment_links/list-payments.json
292
+ - test/fixtures/payment_links/list.json
293
+ - test/fixtures/payment_links/update.json
245
294
  - test/fixtures/payments/get.json
246
295
  - test/fixtures/refunds/get.json
247
296
  - test/fixtures/shipments/create.json
@@ -250,6 +299,8 @@ files:
250
299
  - test/fixtures/shipments/update.json
251
300
  - test/fixtures/subscriptions/get.json
252
301
  - test/fixtures/subscriptions/get_payments.json
302
+ - test/fixtures/terminals/get.json
303
+ - test/fixtures/terminals/list.json
253
304
  - test/helper.rb
254
305
  - test/mollie/amount_test.rb
255
306
  - test/mollie/base_test.rb
@@ -259,6 +310,7 @@ files:
259
310
  - test/mollie/customer/payment_test.rb
260
311
  - test/mollie/customer/subscription_test.rb
261
312
  - test/mollie/customer_test.rb
313
+ - test/mollie/exception_test.rb
262
314
  - test/mollie/invoice_test.rb
263
315
  - test/mollie/list_test.rb
264
316
  - test/mollie/method_test.rb
@@ -272,6 +324,7 @@ files:
272
324
  - test/mollie/payment/capture_test.rb
273
325
  - test/mollie/payment/chargeback_test.rb
274
326
  - test/mollie/payment/refund_test.rb
327
+ - test/mollie/payment_link_test.rb
275
328
  - test/mollie/payment_test.rb
276
329
  - test/mollie/permission_test.rb
277
330
  - test/mollie/profile_test.rb
@@ -280,13 +333,15 @@ files:
280
333
  - test/mollie/settlement/payment_test.rb
281
334
  - test/mollie/settlement/refund_test.rb
282
335
  - test/mollie/settlement_test.rb
336
+ - test/mollie/terminal_test.rb
283
337
  - test/mollie/util_test.rb
284
338
  - test/run-test.rb
285
339
  homepage: https://github.com/mollie/mollie-api-ruby
286
340
  licenses:
287
341
  - BSD
288
- metadata: {}
289
- post_install_message:
342
+ metadata:
343
+ changelog_uri: https://github.com/mollie/mollie-api-ruby/blob/master/CHANGELOG.md
344
+ post_install_message:
290
345
  rdoc_options: []
291
346
  require_paths:
292
347
  - lib
@@ -294,15 +349,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
349
  requirements:
295
350
  - - ">="
296
351
  - !ruby/object:Gem::Version
297
- version: 2.3.8
352
+ version: '2.5'
298
353
  required_rubygems_version: !ruby/object:Gem::Requirement
299
354
  requirements:
300
355
  - - ">="
301
356
  - !ruby/object:Gem::Version
302
357
  version: '0'
303
358
  requirements: []
304
- rubygems_version: 3.5.10
305
- signing_key:
359
+ rubygems_version: 3.5.16
360
+ signing_key:
306
361
  specification_version: 4
307
362
  summary: Official Mollie API Client for Ruby
308
363
  test_files:
@@ -329,6 +384,11 @@ test_files:
329
384
  - test/fixtures/orders/update.json
330
385
  - test/fixtures/orders/update_line.json
331
386
  - test/fixtures/organizations/partner.json
387
+ - test/fixtures/payment_links/create.json
388
+ - test/fixtures/payment_links/get.json
389
+ - test/fixtures/payment_links/list-payments.json
390
+ - test/fixtures/payment_links/list.json
391
+ - test/fixtures/payment_links/update.json
332
392
  - test/fixtures/payments/get.json
333
393
  - test/fixtures/refunds/get.json
334
394
  - test/fixtures/shipments/create.json
@@ -337,6 +397,8 @@ test_files:
337
397
  - test/fixtures/shipments/update.json
338
398
  - test/fixtures/subscriptions/get.json
339
399
  - test/fixtures/subscriptions/get_payments.json
400
+ - test/fixtures/terminals/get.json
401
+ - test/fixtures/terminals/list.json
340
402
  - test/helper.rb
341
403
  - test/mollie/amount_test.rb
342
404
  - test/mollie/base_test.rb
@@ -346,6 +408,7 @@ test_files:
346
408
  - test/mollie/customer/payment_test.rb
347
409
  - test/mollie/customer/subscription_test.rb
348
410
  - test/mollie/customer_test.rb
411
+ - test/mollie/exception_test.rb
349
412
  - test/mollie/invoice_test.rb
350
413
  - test/mollie/list_test.rb
351
414
  - test/mollie/method_test.rb
@@ -359,6 +422,7 @@ test_files:
359
422
  - test/mollie/payment/capture_test.rb
360
423
  - test/mollie/payment/chargeback_test.rb
361
424
  - test/mollie/payment/refund_test.rb
425
+ - test/mollie/payment_link_test.rb
362
426
  - test/mollie/payment_test.rb
363
427
  - test/mollie/permission_test.rb
364
428
  - test/mollie/profile_test.rb
@@ -367,5 +431,6 @@ test_files:
367
431
  - test/mollie/settlement/payment_test.rb
368
432
  - test/mollie/settlement/refund_test.rb
369
433
  - test/mollie/settlement_test.rb
434
+ - test/mollie/terminal_test.rb
370
435
  - test/mollie/util_test.rb
371
436
  - test/run-test.rb
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.8
4
- - 2.4.5
5
- - 2.5.3
6
- - 2.6.1
7
- deploy:
8
- gem: mollie-api-ruby
9
- provider: rubygems
10
- api_key:
11
- secure: "OQobSXpfwELzuh5prnwADPGwt3LHyD/EMuKlJ7aJ6CNveGQzvgGOtK52Cn3X9X8yAkX/PNJVXnPeFaKSQopcAJB30ySJMnPYGjQvIoiUOglMB8lJDFxcLtZ/21NXDf2f3cxYPmZkBGtFQeb/EEYBg4/vwjgWlJ/mcwnesLpwj5A="
12
- on:
13
- tags: true
14
- repo: mollie/mollie-api-ruby
15
- rvm: 2.6.1