mollie-api-ruby 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -2
  3. data/CHANGELOG.md +4 -0
  4. data/{README.mdown → README.md} +8 -8
  5. data/examples/1-new-payment.rb +4 -2
  6. data/examples/4-ideal-payment.rb +4 -2
  7. data/lib/mollie/api/client.rb +32 -13
  8. data/lib/mollie/api/client/version.rb +1 -1
  9. data/lib/mollie/api/object/customer/mandate.rb +37 -0
  10. data/lib/mollie/api/object/customer/subscription.rb +69 -0
  11. data/lib/mollie/api/object/organization.rb +28 -0
  12. data/lib/mollie/api/object/permission.rb +12 -0
  13. data/lib/mollie/api/object/profile.rb +78 -0
  14. data/lib/mollie/api/object/profile/apikey.rb +23 -0
  15. data/lib/mollie/api/object/settlement.rb +32 -0
  16. data/lib/mollie/api/resource/customers/mandates.rb +1 -1
  17. data/lib/mollie/api/resource/customers/subscriptions.rb +1 -1
  18. data/lib/mollie/api/resource/organizations.rb +11 -0
  19. data/lib/mollie/api/resource/permissions.rb +11 -0
  20. data/lib/mollie/api/resource/profiles.rb +11 -0
  21. data/lib/mollie/api/resource/profiles/apikeys.rb +27 -0
  22. data/lib/mollie/api/resource/settlements.rb +11 -0
  23. data/lib/mollie/api/util.rb +46 -30
  24. data/test/mollie/api/client_test.rb +9 -4
  25. data/test/mollie/api/object/customer/mandate_test.rb +47 -0
  26. data/test/mollie/api/object/customer/subscription_test.rb +70 -0
  27. data/test/mollie/api/object/organization_test.rb +51 -0
  28. data/test/mollie/api/object/permission_test.rb +25 -0
  29. data/test/mollie/api/object/profile/apikey_test.rb +35 -0
  30. data/test/mollie/api/object/profile_test.rb +72 -0
  31. data/test/mollie/api/object/settlement_test.rb +140 -0
  32. data/test/mollie/api/resource/customers/mandates_test.rb +1 -1
  33. data/test/mollie/api/resource/customers/subscriptions_test.rb +1 -1
  34. data/test/mollie/api/resource/organizations_test.rb +13 -0
  35. data/test/mollie/api/resource/permissions_test.rb +13 -0
  36. data/test/mollie/api/resource/profiles/apikeys_test.rb +23 -0
  37. data/test/mollie/api/resource/profiles_test.rb +13 -0
  38. data/test/mollie/api/resource/settlements_test.rb +13 -0
  39. data/test/mollie/api/util_test.rb +47 -0
  40. metadata +42 -10
  41. data/lib/mollie/api/object/mandate.rb +0 -35
  42. data/lib/mollie/api/object/subscription.rb +0 -67
  43. data/test/mollie/api/object/mandate_test.rb +0 -45
  44. data/test/mollie/api/object/subscription_test.rb +0 -68
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b228303449f153b39e3ee2ce64035412d17a8b0e
4
- data.tar.gz: 90fe25b682947ca412791365bf3dcfce87c64a47
3
+ metadata.gz: 719ea9fd2cb5e56072dc35c2f66efdd2c87e278b
4
+ data.tar.gz: 3c460d1338c55e3fb80449da019ad5702e65b0a7
5
5
  SHA512:
6
- metadata.gz: d6ef48f0f3aeb0fb19ad136f0fc64c06512ae509676775cfe81062a97d7e988a8a26e689248b4e835b234b379a42c15a487992edd2ee440b10c5f0710e5cefa6
7
- data.tar.gz: fd4dae4d7fd3ea510cb8890cf2ffcaf6dc1d478086b73b1810f0e4804f826de50a8718ccdb5614b16e66e001d20558bac7e8f56cbcc6898c4373298389dc4566
6
+ metadata.gz: 6035c6b84b160788f7f9ea14259bcc8ac1fe64e71e676e5227b8bf45f7dd0cad717b1fc7ed04a2a98b7655977e1c8d32863bcdf579beaeb312f0c5dc991b4665
7
+ data.tar.gz: d69710e8d191ed705a3b391f3d08bb29868d38d30e67f7e77741d1f329546605772b8da1de98c944e11404d1d3182e6ca49cbac6e2b1b95de015c3f6bd140621
@@ -5,8 +5,6 @@ rvm:
5
5
  - 2.1
6
6
  - 2.2
7
7
  - 2.3.0
8
- - jruby
9
8
  matrix:
10
9
  allow_failures:
11
10
  - rvm: 2.0.0
12
- - rvm: jruby
@@ -4,6 +4,10 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ #### 2.2.0 - 2017-04-21
8
+ - Add support for organizations, permissions, profiles, settlement and profiles/apikeys resources ([#54](https://github.com/mollie/mollie-api-ruby/issues/54)).
9
+ - Remove `jruby` from the build.
10
+
7
11
  #### 2.1.0 - 2017-02-06
8
12
  - Add pagination support to resources ([#25](https://github.com/mollie/mollie-api-ruby/issues/25)).
9
13
 
@@ -1,7 +1,8 @@
1
- ![Mollie](http://www.mollie.nl/files/Mollie-Logo-Style-Small.png)
1
+ ![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png)
2
2
 
3
3
  # Mollie API client for Ruby #
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/mollie-api-ruby.svg)](https://badge.fury.io/rb/mollie-api-ruby)
5
6
  [![](https://travis-ci.org/mollie/mollie-api-ruby.png)](https://travis-ci.org/mollie/mollie-api-ruby)
6
7
 
7
8
  Accepting [iDEAL](https://www.mollie.com/ideal/), [Bancontact/Mister Cash](https://www.mollie.com/mistercash/), [SOFORT Banking](https://www.mollie.com/sofort/), [Creditcard](https://www.mollie.com/creditcard/), [SEPA Bank transfer](https://www.mollie.com/overboeking/), [SEPA Direct debit](https://www.mollie.com/directdebit/), [Bitcoin](https://www.mollie.com/bitcoin/), [PayPal](https://www.mollie.com/paypal/), [KBC/CBC Payment Button](https://www.mollie.com/kbccbc/), [Belfius Direct Net](https://www.mollie.com/belfiusdirectnet/) and [paysafecard](https://www.mollie.com/paysafecard/) 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.
@@ -52,9 +53,10 @@ Creating a new payment.
52
53
 
53
54
  ```ruby
54
55
  payment = mollie.payments.create(
55
- amount: 10.00,
56
- description: 'My first API payment',
57
- redirect_url: 'https://webshop.example.org/order/12345/'
56
+ amount: 10.00,
57
+ description: 'My first API payment',
58
+ redirect_url: 'https://webshop.example.org/order/12345/',
59
+ webhook_url: 'https://webshop.example.org/mollie-webhook/'
58
60
  )
59
61
  ```
60
62
 
@@ -92,8 +94,8 @@ $ ruby examples/app.rb
92
94
  If you wish to learn more about our API, please visit the [Mollie Developer Portal](https://www.mollie.com/developer/). API Documentation is available in both Dutch and English.
93
95
 
94
96
  ## License ##
95
- [BSD (Berkeley Software Distribution) License](http://www.opensource.org/licenses/bsd-license.php).
96
- Copyright (c) 2014-2015, Mollie B.V.
97
+ [BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php).
98
+ Copyright (c) 2014-2017, Mollie B.V.
97
99
 
98
100
  ## Support ##
99
101
  Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20-612 88 55
@@ -109,5 +111,3 @@ Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20
109
111
  + [More information about KBC/CBC Payment Button via Mollie](https://www.mollie.com/kbccbc/)
110
112
  + [More information about Belfius Direct Net via Mollie](https://www.mollie.com/belfiusdirectnet/)
111
113
  + [More information about paysafecard via Mollie](https://www.mollie.com/paysafecard/)
112
-
113
- ![Powered By Mollie](https://www.mollie.com/images/badge-betaling-medium.png)
@@ -30,13 +30,15 @@ begin
30
30
  # Payment parameters:
31
31
  # amount Amount in EUROs. This example creates a € 10,- payment.
32
32
  # description Description of the payment.
33
- # redirectUrl Redirect location. The customer will be redirected there after the payment.
33
+ # redirect_url Redirect location. The customer will be redirected there after the payment.
34
+ # webhook_url Webhook location, used to report when the payment changes state.
34
35
  # metadata Custom metadata that is stored with the payment.
35
36
  #
36
37
  payment = mollie.payments.create \
37
38
  :amount => 10.00,
38
39
  :description => "My first API payment",
39
- :redirect_url => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
40
+ :redirect_url => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
41
+ :webhook_url => "#{protocol}://#{hostname}:#{port}#{path}/2-webhook-verification",
40
42
  :metadata => {
41
43
  :order_id => order_id
42
44
  }
@@ -47,7 +47,8 @@ begin
47
47
  # Payment parameters:
48
48
  # amount Amount in EUROs. This example creates a € 27,50 payment.
49
49
  # description Description of the payment.
50
- # redirectUrl Redirect location. The customer will be redirected there after the payment.
50
+ # redirect_url Redirect location. The customer will be redirected there after the payment.
51
+ # webhook_url Webhook location, used to report when the payment changes state.
51
52
  # metadata Custom metadata that is stored with the payment.
52
53
  # method Payment method "ideal".
53
54
  # issuer The customer's bank. If empty the customer can select it later.
@@ -55,7 +56,8 @@ begin
55
56
  payment = mollie.payments.create \
56
57
  :amount => 27.50,
57
58
  :description => "My first API payment",
58
- :redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
59
+ :redirect_url => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
60
+ :webhook_url => "#{protocol}://#{hostname}:#{port}#{path}/2-webhook-verification",
59
61
  :metadata => {
60
62
  :order_id => order_id
61
63
  },
@@ -8,22 +8,32 @@ require "bigdecimal"
8
8
  "client/version",
9
9
  "resource/base",
10
10
  "resource/customers",
11
- "resource/customers/payments",
12
11
  "resource/customers/mandates",
12
+ "resource/customers/payments",
13
13
  "resource/customers/subscriptions",
14
- "resource/payments",
15
- "resource/payments/refunds",
16
14
  "resource/issuers",
17
15
  "resource/methods",
16
+ "resource/organizations",
17
+ "resource/payments",
18
+ "resource/payments/refunds",
19
+ "resource/permissions",
20
+ "resource/profiles",
21
+ "resource/profiles/apikeys",
22
+ "resource/settlements",
18
23
  "object/base",
19
24
  "object/list",
20
25
  "object/customer",
21
- "object/mandate",
22
- "object/subscription",
26
+ "object/customer/mandate",
27
+ "object/customer/subscription",
28
+ "object/issuer",
29
+ "object/method",
30
+ "object/organization",
23
31
  "object/payment",
24
32
  "object/payment/refund",
25
- "object/issuer",
26
- "object/method"].each { |file| require File.expand_path file, File.dirname(__FILE__) }
33
+ "object/permission",
34
+ "object/profile",
35
+ "object/profile/apikey",
36
+ "object/settlement"].each { |file| require File.expand_path file, File.dirname(__FILE__) }
27
37
 
28
38
  module Mollie
29
39
  module API
@@ -31,20 +41,29 @@ module Mollie
31
41
  API_ENDPOINT = "https://api.mollie.nl"
32
42
  API_VERSION = "v1"
33
43
 
44
+ MODE_TEST = "test"
45
+ MODE_LIVE = "live"
46
+
34
47
  attr_accessor :api_key
35
- attr_reader :payments, :issuers, :methods, :payments_refunds,
36
- :customers, :customers_payments, :customers_mandates, :customers_subscriptions,
48
+ attr_reader :customers, :customers_payments, :customers_mandates, :customers_subscriptions,
49
+ :issuers, :methods, :organizations, :payments, :payments_refunds,
50
+ :permissions, :profiles, :profiles_api_keys, :settlements,
37
51
  :api_endpoint
38
52
 
39
53
  def initialize(api_key)
40
- @payments = Mollie::API::Resource::Payments.new self
41
- @issuers = Mollie::API::Resource::Issuers.new self
42
- @methods = Mollie::API::Resource::Methods.new self
43
- @payments_refunds = Mollie::API::Resource::Payments::Refunds.new self
44
54
  @customers = Mollie::API::Resource::Customers.new self
45
55
  @customers_payments = Mollie::API::Resource::Customers::Payments.new self
46
56
  @customers_mandates = Mollie::API::Resource::Customers::Mandates.new self
47
57
  @customers_subscriptions = Mollie::API::Resource::Customers::Subscriptions.new self
58
+ @issuers = Mollie::API::Resource::Issuers.new self
59
+ @methods = Mollie::API::Resource::Methods.new self
60
+ @organizations = Mollie::API::Resource::Organizations.new self
61
+ @payments = Mollie::API::Resource::Payments.new self
62
+ @payments_refunds = Mollie::API::Resource::Payments::Refunds.new self
63
+ @permissions = Mollie::API::Resource::Permissions.new self
64
+ @profiles = Mollie::API::Resource::Profiles.new self
65
+ @profiles_api_keys = Mollie::API::Resource::Profiles::ApiKeys.new self
66
+ @settlements = Mollie::API::Resource::Settlements.new self
48
67
 
49
68
  @api_endpoint = API_ENDPOINT
50
69
  @api_key = api_key
@@ -1,7 +1,7 @@
1
1
  module Mollie
2
2
  module API
3
3
  class Client
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,37 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Customer
5
+ class Mandate < Base
6
+ STATUS_VALID = "valid"
7
+ STATUS_INVALID = "invalid"
8
+
9
+ attr_accessor :id,
10
+ :status,
11
+ :method,
12
+ :customer_id,
13
+ :details,
14
+ :created_datetime,
15
+ :mandate_reference
16
+
17
+
18
+ def details=(details)
19
+ @details = OpenStruct.new(details) if details.is_a?(Hash)
20
+ end
21
+
22
+ def created_datetime=(created_datetime)
23
+ @created_datetime = Time.parse(created_datetime.to_s) rescue nil
24
+ end
25
+
26
+ def valid?
27
+ status == STATUS_VALID
28
+ end
29
+
30
+ def invalid?
31
+ status == STATUS_INVALID
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,69 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Customer
5
+ class Subscription < Base
6
+ STATUS_ACTIVE = "active"
7
+ STATUS_PENDING = "pending" # Waiting for a valid mandate.
8
+ STATUS_CANCELLED = "cancelled"
9
+ STATUS_SUSPENDED = "suspended" # Active, but mandate became invalid.
10
+ STATUS_COMPLETED = "completed"
11
+
12
+ attr_accessor :resource,
13
+ :id,
14
+ :customer_id,
15
+ :mode,
16
+ :created_datetime,
17
+ :status,
18
+ :amount,
19
+ :times,
20
+ :interval,
21
+ :description,
22
+ :method,
23
+ :cancelled_datetime,
24
+ :links
25
+
26
+ def active?
27
+ status == STATUS_ACTIVE
28
+ end
29
+
30
+ def pending?
31
+ status == STATUS_PENDING
32
+ end
33
+
34
+ def suspended?
35
+ status == STATUS_SUSPENDED
36
+ end
37
+
38
+ def cancelled?
39
+ status == STATUS_CANCELLED
40
+ end
41
+
42
+ def completed?
43
+ status == STATUS_COMPLETED
44
+ end
45
+
46
+ def created_datetime=(created_datetime)
47
+ @created_datetime = Time.parse(created_datetime.to_s) rescue nil
48
+ end
49
+
50
+ def cancelled_datetime=(cancelled_datetime)
51
+ @cancelled_datetime = Time.parse(cancelled_datetime.to_s) rescue nil
52
+ end
53
+
54
+ def amount=(amount)
55
+ @amount = BigDecimal.new(amount.to_s)
56
+ end
57
+
58
+ def times=(times)
59
+ @times = times.to_i
60
+ end
61
+
62
+ def webhook_url
63
+ links && links['webhook_url']
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,28 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Organization < Base
5
+ attr_accessor :id,
6
+ :name,
7
+ :email,
8
+ :address,
9
+ :postal_code,
10
+ :city,
11
+ :country,
12
+ :country_code,
13
+ :registration_type,
14
+ :registration_number,
15
+ :registration_datetime,
16
+ :verified_datetime
17
+
18
+ def registration_datetime=(registration_datetime)
19
+ @registration_datetime = Time.parse(registration_datetime.to_s)
20
+ end
21
+
22
+ def verified_datetime=(verified_datetime)
23
+ @verified_datetime = Time.parse(verified_datetime.to_s) rescue nil
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Permission < Base
5
+ attr_accessor :id,
6
+ :description,
7
+ :warning,
8
+ :granted
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,78 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Profile < Base
5
+ CATEGORY_CODE_GENERAL_MERCHANDISE = 5399
6
+ CATEGORY_CODE_ELECTRONICS_COMPUTERS_AND_SOFTWARE = 5732
7
+ CATEGORY_CODE_TRAVEL_RENTAL_AND_TRANSPORTATION = 4121
8
+ CATEGORY_CODE_FINANCIAL_SERVICES = 6012
9
+ CATEGORY_CODE_FOOD_AND_DRINKS = 5499
10
+ CATEGORY_CODE_EVENTS_FESTIVALS_AND_RECREATION = 7999
11
+ CATEGORY_CODE_BOOKS_MAGAZINES_AND_NEWSPAPERS = 5192
12
+ CATEGORY_CODE_PERSONAL_SERVICES = 7299
13
+ CATEGORY_CODE_CHARITY_AND_DONATIONS = 8398
14
+ CATEGORY_CODE_OTHER = 0
15
+
16
+ STATUS_UNVERIFIED = "unverified"
17
+ STATUS_VERIFIED = "verified"
18
+ STATUS_BLOCKED = "blocked"
19
+
20
+ REVIEW_STATUS_PENDING = "pending"
21
+ REVIEW_STATUS_REJECTED = "rejected"
22
+
23
+ attr_accessor :id,
24
+ :mode,
25
+ :name,
26
+ :website,
27
+ :email,
28
+ :phone,
29
+ :category_code,
30
+ :status,
31
+ :review,
32
+ :created_datetime,
33
+ :updated_datetime,
34
+ :links
35
+
36
+ def unverified?
37
+ status == STATUS_UNVERIFIED
38
+ end
39
+
40
+ def verified?
41
+ status == STATUS_VERIFIED
42
+ end
43
+
44
+ def blocked?
45
+ status == STATUS_BLOCKED
46
+ end
47
+
48
+ def review=(review)
49
+ @review = OpenStruct.new(review) if review.is_a?(Hash)
50
+ end
51
+
52
+ def review_pending?
53
+ @review && @review.status == REVIEW_STATUS_PENDING
54
+ end
55
+
56
+ def review_rejected?
57
+ @review && @review.status == REVIEW_STATUS_REJECTED
58
+ end
59
+
60
+ def created_datetime=(created_datetime)
61
+ @created_datetime = Time.parse(created_datetime.to_s) rescue nil
62
+ end
63
+
64
+ def updated_datetime=(updated_datetime)
65
+ @updated_datetime = Time.parse(updated_datetime.to_s) rescue nil
66
+ end
67
+
68
+ def apikeys
69
+ links && links['apikeys']
70
+ end
71
+
72
+ def checkout_preview_url
73
+ links && links['checkout_preview_url']
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,23 @@
1
+ module Mollie
2
+ module API
3
+ module Object
4
+ class Profile
5
+ class ApiKey < Base
6
+ attr_accessor :id, :key, :created_datetime
7
+
8
+ def testmode?
9
+ id == Mollie::API::Client::MODE_TEST
10
+ end
11
+
12
+ def livemode?
13
+ id == Mollie::API::Client::MODE_LIVE
14
+ end
15
+
16
+ def created_datetime=(created_datetime)
17
+ @created_datetime = Time.parse(created_datetime)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end