mollie-api-ruby 3.1.5 → 4.0.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +0 -3
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +63 -119
  5. data/bin/console +15 -0
  6. data/bin/setup +8 -0
  7. data/docs/migration_v2_2_x.md +67 -0
  8. data/docs/migration_v3_x.md +227 -0
  9. data/examples/chargebacks/get.rb +4 -0
  10. data/examples/chargebacks/list.rb +1 -0
  11. data/{website-docs → examples}/connect/authorize.rb +3 -2
  12. data/{website-docs → examples}/connect/tokens.rb +1 -1
  13. data/examples/customers/create-payment.rb +6 -0
  14. data/examples/customers/create.rb +5 -0
  15. data/examples/customers/delete.rb +1 -0
  16. data/examples/customers/get.rb +1 -0
  17. data/examples/customers/list-payments.rb +1 -0
  18. data/examples/customers/list.rb +1 -0
  19. data/examples/customers/update.rb +4 -0
  20. data/examples/invoices/get.rb +1 -0
  21. data/examples/invoices/list.rb +1 -0
  22. data/examples/mandates/create.rb +9 -0
  23. data/examples/mandates/delete.rb +1 -0
  24. data/examples/mandates/get.rb +1 -0
  25. data/examples/mandates/list.rb +1 -0
  26. data/examples/methods/get.rb +4 -0
  27. data/examples/methods/list.rb +4 -0
  28. data/examples/organisations/get-current.rb +1 -0
  29. data/examples/organisations/get.rb +1 -0
  30. data/examples/payments/create.rb +9 -0
  31. data/examples/payments/delete.rb +1 -0
  32. data/examples/payments/get-customer.rb +2 -0
  33. data/examples/payments/get-mandate.rb +2 -0
  34. data/examples/payments/get-settlement.rb +2 -0
  35. data/examples/payments/get-subscription.rb +2 -0
  36. data/examples/payments/get.rb +1 -0
  37. data/examples/payments/list.rb +1 -0
  38. data/examples/payments/webhook.rb +12 -0
  39. data/examples/permissions/get.rb +1 -0
  40. data/examples/permissions/list.rb +1 -0
  41. data/examples/profiles/create.rb +8 -0
  42. data/examples/profiles/delete.rb +1 -0
  43. data/examples/profiles/get.rb +1 -0
  44. data/examples/profiles/list-chargebacks.rb +2 -0
  45. data/examples/profiles/list-methods.rb +2 -0
  46. data/examples/profiles/list-payments.rb +2 -0
  47. data/examples/profiles/list-refunds.rb +2 -0
  48. data/examples/profiles/list.rb +1 -0
  49. data/examples/profiles/update.rb +5 -0
  50. data/examples/refunds/create.rb +5 -0
  51. data/examples/refunds/delete.rb +4 -0
  52. data/examples/refunds/get-payment.rb +2 -0
  53. data/examples/refunds/get.rb +4 -0
  54. data/examples/refunds/list.rb +1 -0
  55. data/examples/settlements/get.rb +1 -0
  56. data/examples/settlements/list-chargebacks.rb +1 -0
  57. data/examples/settlements/list-payments.rb +1 -0
  58. data/examples/settlements/list-refunds.rb +1 -0
  59. data/examples/settlements/list.rb +1 -0
  60. data/examples/settlements/next.rb +1 -0
  61. data/examples/settlements/open.rb +1 -0
  62. data/examples/subscriptions/create.rb +8 -0
  63. data/examples/subscriptions/delete.rb +4 -0
  64. data/examples/subscriptions/get.rb +4 -0
  65. data/examples/subscriptions/list.rb +1 -0
  66. data/examples/subscriptions/update.rb +5 -0
  67. data/lib/cacert.pem +168 -48
  68. data/lib/mollie.rb +1 -3
  69. data/lib/mollie/amount.rb +20 -0
  70. data/lib/mollie/base.rb +9 -8
  71. data/lib/mollie/chargeback.rb +25 -15
  72. data/lib/mollie/client.rb +33 -13
  73. data/lib/mollie/customer.rb +9 -14
  74. data/lib/mollie/customer/mandate.rb +17 -5
  75. data/lib/mollie/customer/subscription.rb +14 -15
  76. data/lib/mollie/exception.rb +15 -3
  77. data/lib/mollie/invoice.rb +30 -26
  78. data/lib/mollie/list.rb +27 -18
  79. data/lib/mollie/method.rb +17 -25
  80. data/lib/mollie/organization.rb +5 -11
  81. data/lib/mollie/payment.rb +89 -61
  82. data/lib/mollie/permission.rb +0 -1
  83. data/lib/mollie/profile.rb +18 -13
  84. data/lib/mollie/refund.rb +27 -7
  85. data/lib/mollie/settlement.rb +50 -9
  86. data/lib/mollie/util.rb +11 -0
  87. data/lib/mollie/version.rb +1 -1
  88. data/mollie-api-ruby.gemspec +0 -7
  89. data/test/mollie/amount_test.rb +30 -0
  90. data/test/mollie/base_test.rb +44 -44
  91. data/test/mollie/chargeback_test.rb +78 -17
  92. data/test/mollie/client_test.rb +29 -12
  93. data/test/mollie/customer/mandate_test.rb +85 -9
  94. data/test/mollie/customer/payment_test.rb +2 -2
  95. data/test/mollie/customer/subscription_test.rb +71 -20
  96. data/test/mollie/customer_test.rb +17 -89
  97. data/test/mollie/invoice_test.rb +40 -24
  98. data/test/mollie/list_test.rb +62 -18
  99. data/test/mollie/method_test.rb +2 -8
  100. data/test/mollie/organization_test.rb +28 -23
  101. data/test/mollie/payment/chargeback_test.rb +2 -3
  102. data/test/mollie/payment/refund_test.rb +2 -3
  103. data/test/mollie/payment_test.rb +272 -86
  104. data/test/mollie/permission_test.rb +0 -2
  105. data/test/mollie/profile_test.rb +129 -35
  106. data/test/mollie/refund_test.rb +90 -10
  107. data/test/mollie/settlement/chargeback_test.rb +2 -4
  108. data/test/mollie/settlement/payment_test.rb +2 -2
  109. data/test/mollie/settlement/refund_test.rb +2 -3
  110. data/test/mollie/settlement_test.rb +199 -98
  111. data/test/mollie/util_test.rb +31 -0
  112. metadata +96 -239
  113. data/examples/apis/api_docs.rb +0 -37
  114. data/examples/apis/chargebacks.rb +0 -17
  115. data/examples/apis/connect.rb +0 -58
  116. data/examples/apis/customers.rb +0 -116
  117. data/examples/apis/invoices.rb +0 -38
  118. data/examples/apis/issuers.rb +0 -35
  119. data/examples/apis/mandates.rb +0 -83
  120. data/examples/apis/methods.rb +0 -50
  121. data/examples/apis/organizations.rb +0 -16
  122. data/examples/apis/payments.rb +0 -174
  123. data/examples/apis/permissions.rb +0 -32
  124. data/examples/apis/profiles.rb +0 -126
  125. data/examples/apis/refunds.rb +0 -17
  126. data/examples/apis/settlements.rb +0 -84
  127. data/examples/apis/subscriptions.rb +0 -165
  128. data/examples/config.ru +0 -57
  129. data/examples/public/images/collapse.gif +0 -0
  130. data/examples/public/images/expand.gif +0 -0
  131. data/examples/public/images/explorer_icons.png +0 -0
  132. data/examples/public/images/favicon-16x16.png +0 -0
  133. data/examples/public/images/favicon-32x32.png +0 -0
  134. data/examples/public/images/favicon.ico +0 -0
  135. data/examples/public/images/logo_small.png +0 -0
  136. data/examples/public/images/pet_store_api.png +0 -0
  137. data/examples/public/images/throbber.gif +0 -0
  138. data/examples/public/images/wordnik_api.png +0 -0
  139. data/examples/public/index.html +0 -101
  140. data/examples/public/javascripts/lib/backbone-min.js +0 -1
  141. data/examples/public/javascripts/lib/es5-shim.js +0 -1
  142. data/examples/public/javascripts/lib/handlebars-4.0.5.js +0 -3
  143. data/examples/public/javascripts/lib/highlight.9.1.0.pack.js +0 -1
  144. data/examples/public/javascripts/lib/highlight.9.1.0.pack_extended.js +0 -1
  145. data/examples/public/javascripts/lib/jquery-1.8.0.min.js +0 -3
  146. data/examples/public/javascripts/lib/jquery.ba-bbq.min.js +0 -1
  147. data/examples/public/javascripts/lib/jquery.slideto.min.js +0 -1
  148. data/examples/public/javascripts/lib/jquery.wiggle.min.js +0 -1
  149. data/examples/public/javascripts/lib/js-yaml.min.js +0 -2
  150. data/examples/public/javascripts/lib/jsoneditor.min.js +0 -5
  151. data/examples/public/javascripts/lib/lodash.min.js +0 -2
  152. data/examples/public/javascripts/lib/marked.js +0 -1
  153. data/examples/public/javascripts/lib/object-assign-pollyfill.js +0 -1
  154. data/examples/public/javascripts/lib/sanitize-html.min.js +0 -4
  155. data/examples/public/javascripts/lib/swagger-oauth.js +0 -1
  156. data/examples/public/javascripts/swagger-ui.js +0 -25378
  157. data/examples/public/javascripts/swagger-ui.min.js +0 -15
  158. data/examples/public/javascripts/swagger_docs.js +0 -14
  159. data/examples/public/o2c.html +0 -20
  160. data/examples/public/stylesheets/reset.css +0 -1
  161. data/examples/public/stylesheets/screen.css +0 -1545
  162. data/examples/public/stylesheets/swagger_docs.css +0 -4
  163. data/examples/public/stylesheets/typography.css +0 -0
  164. data/lib/mollie/issuer.rb +0 -5
  165. data/lib/mollie/profile/api_key.rb +0 -19
  166. data/lib/mollie/relation.rb +0 -36
  167. data/test/mollie/issuer_test.rb +0 -19
  168. data/test/mollie/profile/apikey_test.rb +0 -31
  169. data/website-docs/chargebacks/list-all.rb +0 -12
  170. data/website-docs/customers/create-payment.rb +0 -13
  171. data/website-docs/customers/create.rb +0 -12
  172. data/website-docs/customers/delete.rb +0 -10
  173. data/website-docs/customers/get.rb +0 -10
  174. data/website-docs/customers/list-payments.rb +0 -10
  175. data/website-docs/customers/list.rb +0 -12
  176. data/website-docs/customers/update.rb +0 -11
  177. data/website-docs/invoices/get.rb +0 -10
  178. data/website-docs/invoices/list.rb +0 -12
  179. data/website-docs/issuers/get.rb +0 -10
  180. data/website-docs/issuers/list.rb +0 -12
  181. data/website-docs/mandates/create.rb +0 -16
  182. data/website-docs/mandates/delete.rb +0 -10
  183. data/website-docs/mandates/get.rb +0 -10
  184. data/website-docs/mandates/list.rb +0 -12
  185. data/website-docs/methods/get.rb +0 -10
  186. data/website-docs/methods/list.rb +0 -12
  187. data/website-docs/organisations/get.rb +0 -10
  188. data/website-docs/payments/create-refund.rb +0 -14
  189. data/website-docs/payments/create.rb +0 -16
  190. data/website-docs/payments/delete-refund.rb +0 -13
  191. data/website-docs/payments/delete.rb +0 -12
  192. data/website-docs/payments/get-chargeback.rb +0 -11
  193. data/website-docs/payments/get-refund.rb +0 -11
  194. data/website-docs/payments/get.rb +0 -10
  195. data/website-docs/payments/list-chargeback.rb +0 -13
  196. data/website-docs/payments/list-refunds.rb +0 -13
  197. data/website-docs/payments/list.rb +0 -12
  198. data/website-docs/payments/payment-webhook.rb +0 -21
  199. data/website-docs/permissions/get.rb +0 -10
  200. data/website-docs/permissions/list.rb +0 -12
  201. data/website-docs/profiles/create.rb +0 -15
  202. data/website-docs/profiles/delete.rb +0 -10
  203. data/website-docs/profiles/get-key.rb +0 -11
  204. data/website-docs/profiles/get.rb +0 -10
  205. data/website-docs/profiles/list-keys.rb +0 -13
  206. data/website-docs/profiles/list.rb +0 -12
  207. data/website-docs/profiles/reset-key.rb +0 -13
  208. data/website-docs/profiles/update.rb +0 -12
  209. data/website-docs/refunds/list.rb +0 -12
  210. data/website-docs/settlements/get.rb +0 -10
  211. data/website-docs/settlements/list-chargebacks.rb +0 -13
  212. data/website-docs/settlements/list-payments.rb +0 -13
  213. data/website-docs/settlements/list-refunds.rb +0 -13
  214. data/website-docs/settlements/list.rb +0 -12
  215. data/website-docs/settlements/next.rb +0 -9
  216. data/website-docs/settlements/open.rb +0 -9
  217. data/website-docs/subscriptions/create.rb +0 -14
  218. data/website-docs/subscriptions/delete.rb +0 -10
  219. data/website-docs/subscriptions/get.rb +0 -10
  220. data/website-docs/subscriptions/list.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: d4dd143310a3cb0cac754c9fe18a688c9c2c11823cf5b24a2a1fcae781051614
4
- data.tar.gz: '026965173ffbe4a828adb04c4c4be8222987c482db21d75f6098d1e4aa8af2ae'
2
+ SHA1:
3
+ metadata.gz: 2139d0d55616baeeaf00a1ae05206e2ec5db8da5
4
+ data.tar.gz: 61184bdd17e9cef70da234a3c5561403c13929b7
5
5
  SHA512:
6
- metadata.gz: baee58a7d1c413f720adec1e7f1d98b7c952958947bf53a6828517d33855edadd1a2f376383a5dd32a2cad54bc38edf684da39f52f1169bd14815d3ef8b05ea3
7
- data.tar.gz: a58d95cbdf3057ca82d9ac1a3c3b651950aa2475b321fa314ca0373ef989b4f4e696f0f7caa716e93cf3ffc33e962f2cf46379c08dd85fb560e4cca364276e2f
6
+ metadata.gz: e143c49e7e9f03d70a46a826f1704856544237b0d9848cfeb2e3ee8ee1ab26f4c12e43818e1d8f58cfd8b7864d2e97c958ed15ebcc5c92d45b9869ba5fdfb081
7
+ data.tar.gz: 21414570b0a4dca58b1add62a8765e6c7463e791b5d6b7540e1047e0a77f87815f36673be9b30c8b7ed6c3fe2d25af01ca2f11e84773a51c786920ca0f7d3c91
data/.travis.yml CHANGED
@@ -1,13 +1,10 @@
1
1
  language: ruby
2
2
  before_install: gem install bundler
3
3
  rvm:
4
- - 2.0.0
5
4
  - 2.1
6
5
  - 2.2
7
6
  - 2.3.0
8
7
  matrix:
9
- allow_failures:
10
- - rvm: 2.0.0
11
8
  deploy:
12
9
  provider: rubygems
13
10
  api_key:
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  All notable changes to this project will be documented in this file.
6
6
 
7
+ #### 4.0 - 2018-07-23
8
+
9
+ - Migrated to the v2 API
10
+ Refer to the [migration guide](/docs/migration_v3_x.md) for a complete list of changes
11
+ - Dropped Ruby 2.0.0 support.
12
+
7
13
  #### 3.1.0 - ....
8
14
  - Removed old api
9
15
 
data/README.md CHANGED
@@ -1,23 +1,25 @@
1
1
  ![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png)
2
2
 
3
- # LOOKING FOR VERSION v2.2.X README [CLICK HERE](https://github.com/mollie/mollie-api-ruby/tree/2.2.x) #
3
+ # Mollie API client for Ruby
4
4
 
5
- # Mollie API client for Ruby #
5
+ > LOOKING FOR VERSION v2.2.X README? [CLICK HERE](https://github.com/mollie/mollie-api-ruby/tree/2.2.x)
6
+
7
+ > LOOKING FOR VERSION v3.1.X README? [CLICK HERE](https://github.com/mollie/mollie-api-ruby/tree/3.1.x)
6
8
 
7
9
  [![Gem Version](https://badge.fury.io/rb/mollie-api-ruby.svg)](https://badge.fury.io/rb/mollie-api-ruby)
8
10
  [![](https://travis-ci.org/mollie/mollie-api-ruby.png)](https://travis-ci.org/mollie/mollie-api-ruby)
9
11
 
10
- 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/), [paysafecard](https://www.mollie.com/paysafecard/) and [ING Home’Pay](https://www.mollie.com/ing-homepay/) 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.
12
+ 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), [Bitcoin](https://www.mollie.com/en/payments/bitcoin), [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) and [Giropay](https://www.mollie.com/en/payments/giropay) 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.
11
13
 
12
- ## Requirements ##
14
+ ## Requirements
13
15
  To use the Mollie API client, the following things are required:
14
16
 
15
- + Get yourself a free [Mollie account](https://www.mollie.nl/aanmelden). No sign up costs.
16
- + Create a new [Website profile](https://www.mollie.nl/beheer/account/profielen/) to generate API keys (live and test mode) and setup your webhook.
17
+ + Get yourself a free [Mollie account](https://www.mollie.com/dashboard/signup). No sign up costs.
18
+ + Create a new [Website profile](https://www.mollie.com/dashboard/settings/profiles) to generate API keys (live and test mode) and setup your webhook.
17
19
  + Now you're ready to use the Mollie API client in test mode.
18
20
  + In order to accept payments in live mode, payment methods must be activated in your account. Follow [a few of steps](https://www.mollie.nl/beheer/diensten), and let us handle the rest.
19
21
 
20
- ## Installation ##
22
+ ## Installation
21
23
 
22
24
  By far the easiest way to install the Mollie API client is to install it with [gem](http://rubygems.org/).
23
25
 
@@ -30,7 +32,7 @@ $ gem install mollie-api-ruby
30
32
 
31
33
  You may also git checkout or [download all the files](https://github.com/mollie/mollie-api-ruby/archive/master.zip), and include the Mollie API client manually.
32
34
 
33
- ## How to receive payments ##
35
+ ## How to receive payments
34
36
 
35
37
  To successfully receive a payment, these steps should be implemented:
36
38
 
@@ -40,9 +42,9 @@ To successfully receive a payment, these steps should be implemented:
40
42
 
41
43
  3. The customer returns, and should be satisfied to see that the order was paid and is now being processed.
42
44
 
43
- ## Getting started ##
45
+ ## Getting started
44
46
 
45
- Requiring the Mollie API Client. *Not required when used with a Gemfile*
47
+ Require the Mollie API Client. *Not required when used with a Gemfile*
46
48
 
47
49
  ```ruby
48
50
  require 'mollie-api-ruby'
@@ -56,20 +58,20 @@ Mollie::Client.configure do |config|
56
58
  end
57
59
  ```
58
60
 
59
- You can also include the API Key in each request you make, for instance if you are using the Connect API
61
+ You can also include the API Key in each request you make, for instance if you are using the Connect API:
60
62
 
61
63
  ```ruby
62
- Mollie::Payment.get("pay-id", api_key: '<your-api-key>')
64
+ Mollie::Payment.get('pay-id', api_key: '<your-api-key>')
63
65
  ```
64
66
 
65
- If you need to do multiple calls with the same API Key, use the following helper
67
+ If you need to do multiple calls with the same API Key, use the following helper:
66
68
 
67
69
  ```ruby
68
70
  Mollie::Client.with_api_key('<your-api-key>') do
69
71
  mandates = Mollie::Customer::Mandate.all(customer_id: params[:customer_id])
70
72
  if mandates.any?
71
73
  payment = Mollie::Payment.create(
72
- amount: 10.00,
74
+ amount: { value: '10.00', currency: 'EUR' },
73
75
  description: 'My first API payment',
74
76
  redirect_url: 'https://webshop.example.org/order/12345/',
75
77
  webhook_url: 'https://webshop.example.org/mollie-webhook/'
@@ -78,18 +80,23 @@ Mollie::Client.with_api_key('<your-api-key>') do
78
80
  end
79
81
  ```
80
82
 
81
- Creating a new payment.
83
+ ### Creating a new payment
82
84
 
83
85
  ```ruby
84
86
  payment = Mollie::Payment.create(
85
- amount: 10.00,
87
+ amount: { value: '10.00', currency: 'EUR' },
86
88
  description: 'My first API payment',
87
89
  redirect_url: 'https://webshop.example.org/order/12345/',
88
90
  webhook_url: 'https://webshop.example.org/mollie-webhook/'
89
91
  )
90
92
  ```
91
93
 
92
- Retrieving a payment.
94
+ **Note**: If you specify an `amount`, you must specify the *correct* number of decimals.
95
+ We strongly recommend sending `value `as a string. Note that even though most currencies
96
+ use two decimals, some use three or none, like `JPY`. All amounts returned in the v2
97
+ API will use this format.
98
+
99
+ ### Retrieving a payment
93
100
 
94
101
  ```ruby
95
102
  payment = Mollie::Payment.get(payment.id)
@@ -99,127 +106,64 @@ if payment.paid?
99
106
  end
100
107
  ```
101
108
 
102
- ### Refunding payments ###
109
+ ### Refunding payments
103
110
 
104
111
  The API also supports refunding payments. Note that there is no confirmation and that all refunds are immediate and
105
- definitive. Refunds are only supported for iDEAL, credit card and Bank Transfer payments. Other types of payments cannot
106
- be refunded through our API at the moment.
112
+ definitive. Refunds are only supported for [certain payment methods](https://help.mollie.com/hc/en-us/articles/115000014489-How-do-I-refund-a-payment-to-one-of-my-consumers-).
107
113
 
108
114
  ```ruby
109
115
  payment = Mollie::Payment.get(payment.id)
110
- refund = payment.refunds.create
116
+ refund = payment.refund!(amount: { value: '10.00', currency: 'EUR' })
111
117
  ```
112
118
 
113
- ## Examples ##
114
-
115
- In order to run the examples first run `bundle install`
119
+ ### Pagination
116
120
 
117
- ```
118
- $ cd mollie-api-ruby
119
- $ bundle install
120
- $ cd examples
121
- $ rackup
122
- ```
121
+ Fetching all objects of a resource can be convenient. At the same time,
122
+ returning too many objects at once can be unpractical from a performance
123
+ perspective. Doing so might be too much work for the Mollie API to generate, or
124
+ for your website to process. The maximum number of objects returned is 250.
123
125
 
124
- ## API documentation ##
125
- If you wish to learn more about the Ruby API, download the source code and run the Example app as follows:
126
-
127
- ```
128
- $ git clone git@github.com:mollie/mollie-api-ruby.git
129
- $ cd mollie-api-ruby
130
- $ bundle
131
- $ cd examples
132
- $ API_KEY=test_xxxxxx rackup
133
- ```
134
- You can then browse the swagger documentation on [http://localhost:9292](http://localhost:9292)
135
-
136
- 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.
137
-
138
- ## Migration from v2.2.x ##
139
-
140
- The version 2.2.x used a client that contained methods to call API methods on the mollie servers.
141
- The responses were converted in to Mollie objects and attributes could be retrieved.
142
- Version 3.1.x uses a more Resource oriented approach that fits better with the Active Record principle.
143
- Instead of calling the methods on the client, you now use the Resource class or instance to call the API methods.
144
-
145
- You can now require the mollie client by using the gem name.
146
- If you are using bundler and Rails you don't even need to require it anymore
126
+ For this reason the Mollie API only returns a subset of the requested set of
127
+ objects. In other words, the Mollie API chops the result of a certain API method
128
+ call into pages you’re able to programmatically scroll through.
147
129
 
148
130
  ```ruby
149
- # require 'mollie/api/client'
150
- require 'mollie-api-ruby'
131
+ payments = Mollie::Payment.all
132
+ payments.next
133
+ payments.previous
151
134
  ```
152
135
 
153
- Instead of creating a client with an API key, the client is now stored as a threadsafe singleton object.
154
- Configuration can now be simplified by adding a global configure block in a Rails initializer or a Rack loader file.
136
+ ## Upgrading
155
137
 
138
+ * [Migration from v2.2.x](docs/migration_v2_2_x.md)
139
+ * [Migration from v3.x](docs/migration_v3_x.md)
156
140
 
157
- ```ruby
158
- # mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
159
-
160
- # config/initializers/mollie.rb or in your app.rb
161
- Mollie::Client.configure do |config|
162
- config.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
163
- end
164
-
165
- # You may also pass a specific API key in the params for each request.
166
- payment = Mollie::Payment.get(api_key: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
167
-
168
- # Or in a Rails around filter
169
- around_action :set_mollie_key
170
-
171
- def set_mollie_key
172
- Mollie::Client.with_api_key('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM') do
173
- yield
174
- end
175
- end
176
-
177
- ```
178
-
179
- Change the client calls to Resource calls
141
+ ## API documentation ##
180
142
 
181
- ```ruby
182
- # mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
183
- # payment = mollie.payments.create(
184
- # amount: 10.00,
185
- # description: 'My first API payment',
186
- # redirect_url: 'https://webshop.example.org/order/12345/',
187
- # webhook_url: 'https://webshop.example.org/mollie-webhook/'
188
- #)
189
-
190
- payment = Mollie::Payment.create(
191
- amount: 10.00,
192
- description: 'My first API payment',
193
- redirect_url: 'https://webshop.example.org/order/12345/',
194
- webhook_url: 'https://webshop.example.org/mollie-webhook/'
195
- )
196
- ```
143
+ If you wish to learn more about our API, please visit the [Mollie API Documentation](https://docs.mollie.com).
197
144
 
198
- The resources created are similar to the old resources but have an extra option to retrieve nested resources
145
+ ## Want to help us make our API client even better?
199
146
 
200
- ```ruby
201
- # payment = mollie.payments.get(payment.id)
202
- # refund = mollie.payments_refunds.with(payment).create
203
- payment = Mollie::Payment.get("id")
204
- refund = payment.refunds.create
205
- ```
147
+ Want to help us make our API client even better? We take [pull requests](https://github.com/mollie/mollie-api-ruby/pulls?utf8=%E2%9C%93&q=is%3Apr), sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. [Check out our vacancies](https://jobs.mollie.com/) or [get in touch](mailto:recruitment@mollie.com).
206
148
 
207
- ## License ##
208
- [BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php).
209
- Copyright (c) 2014-2018, Mollie B.V.
149
+ ## License
150
+ [BSD (Berkeley Software Distribution) License](https://opensource.org/licenses/bsd-license.php). Copyright (c) 2014-2018, Mollie B.V.
210
151
 
211
- ## Support ##
152
+ ## Support
212
153
  Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20-612 88 55
213
154
 
214
- + [More information about iDEAL via Mollie](https://www.mollie.com/ideal/)
215
- + [More information about credit card via Mollie](https://www.mollie.com/creditcard/)
216
- + [More information about Bancontact/Mister Cash via Mollie](https://www.mollie.com/mistercash/)
217
- + [More information about SOFORT Banking via Mollie](https://www.mollie.com/sofort/)
218
- + [More information about SEPA Bank transfer via Mollie](https://www.mollie.com/banktransfer/)
219
- + [More information about SEPA Direct debit via Mollie](https://www.mollie.com/directdebit/)
220
- + [More information about Bitcoin via Mollie](https://www.mollie.com/bitcoin/)
221
- + [More information about PayPal via Mollie](https://www.mollie.com/paypal/)
222
- + [More information about KBC/CBC Payment Button via Mollie](https://www.mollie.com/kbccbc/)
223
- + [More information about Belfius Direct Net via Mollie](https://www.mollie.com/belfiusdirectnet/)
224
- + [More information about paysafecard via Mollie](https://www.mollie.com/paysafecard/)
225
- + [More information about ING Home’Pay via Mollie](https://www.mollie.com/ing-homepay/)
155
+ + [More information about iDEAL via Mollie](https://www.mollie.com/en/payments/ideal/)
156
+ + [More information about Credit card via Mollie](https://www.mollie.com/en/payments/credit-card/)
157
+ + [More information about Bancontact via Mollie](https://www.mollie.com/en/payments/bancontact/)
158
+ + [More information about SOFORT Banking via Mollie](https://www.mollie.com/en/payments/sofort/)
159
+ + [More information about SEPA Bank transfer via Mollie](https://www.mollie.com/en/payments/bank-transfer/)
160
+ + [More information about SEPA Direct debit via Mollie](https://www.mollie.com/en/payments/direct-debit/)
161
+ + [More information about Bitcoin via Mollie](https://www.mollie.com/en/payments/bitcoin/)
162
+ + [More information about PayPal via Mollie](https://www.mollie.com/en/payments/paypal/)
163
+ + [More information about KBC/CBC Payment Button via Mollie](https://www.mollie.com/en/payments/kbc-cbc/)
164
+ + [More information about Belfius Direct Net via Mollie](https://www.mollie.com/en/payments/belfius)
165
+ + [More information about paysafecard via Mollie](https://www.mollie.com/en/payments/paysafecard/)
166
+ + [More information about ING Home’Pay via Mollie](https://www.mollie.com/en/payments/ing-homepay/)
167
+ + [More information about Gift cards via Mollie](https://www.mollie.com/en/payments/gift-cards)
168
+ + [More information about EPS via Mollie](https://www.mollie.com/en/payments/eps)
169
+ + [More information about Giropay via Mollie](https://www.mollie.com/en/payments/giropay)
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mollie"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ require "pp"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,67 @@
1
+ # Migration from v2.2.x
2
+
3
+ The version 2.2.x used a client that contained methods to call API methods on the mollie servers.
4
+ The responses were converted in to Mollie objects and attributes could be retrieved.
5
+ Version 3.1.x uses a more Resource oriented approach that fits better with the Active Record principle.
6
+ Instead of calling the methods on the client, you now use the Resource class or instance to call the API methods.
7
+
8
+ You can now require the mollie client by using the gem name.
9
+ If you are using bundler and Rails you don't even need to require it anymore.
10
+
11
+ ```ruby
12
+ # require 'mollie/api/client'
13
+ require 'mollie-api-ruby'
14
+ ```
15
+
16
+ Instead of creating a client with an API key, the client is now stored as a threadsafe singleton object.
17
+ Configuration can now be simplified by adding a global configure block in a Rails initializer or a Rack loader file.
18
+
19
+ ```ruby
20
+ # mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
21
+
22
+ # config/initializers/mollie.rb or in your app.rb
23
+ Mollie::Client.configure do |config|
24
+ config.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
25
+ end
26
+
27
+ # You may also pass a specific API key in the params for each request.
28
+ payment = Mollie::Payment.get(api_key: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
29
+
30
+ # Or in a Rails around filter
31
+ around_action :set_mollie_key
32
+
33
+ def set_mollie_key
34
+ Mollie::Client.with_api_key('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM') do
35
+ yield
36
+ end
37
+ end
38
+
39
+ ```
40
+
41
+ Change the client calls to Resource calls
42
+
43
+ ```ruby
44
+ # mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
45
+ # payment = mollie.payments.create(
46
+ # amount: 10.00,
47
+ # description: 'My first API payment',
48
+ # redirect_url: 'https://webshop.example.org/order/12345/',
49
+ # webhook_url: 'https://webshop.example.org/mollie-webhook/'
50
+ #)
51
+
52
+ payment = Mollie::Payment.create(
53
+ amount: { amount: '10.00', currency: 'EUR' },
54
+ description: 'My first API payment',
55
+ redirect_url: 'https://webshop.example.org/order/12345/',
56
+ webhook_url: 'https://webshop.example.org/mollie-webhook/'
57
+ )
58
+ ```
59
+
60
+ The resources created are similar to the old resources but have an extra option to retrieve nested resources
61
+
62
+ ```ruby
63
+ # payment = mollie.payments.get(payment.id)
64
+ # refund = mollie.payments_refunds.with(payment).create
65
+ payment = Mollie::Payment.get("id")
66
+ refund = payment.refunds.create({ amount: '10.00', currency: 'EUR' })
67
+ ```
@@ -0,0 +1,227 @@
1
+ # Migration from v3.x
2
+
3
+ Please refer to [Migrating from v1 to v2](https://docs.mollie.com/migrating-v1-to-v2)
4
+ for a general overview of the switch to Mollie v2 API.
5
+
6
+ Code examples can be found in the [/examples](/examples) folder.
7
+
8
+ ## Nested resources
9
+
10
+ Several helper methods were added to retrieve nested resources. Nested resources
11
+ now return a collection or the object itself:
12
+
13
+ ```ruby
14
+ payment = Mollie::Payment.get('tr_7UhSN1zuXS')
15
+ refunds = payment.refunds # => Mollie::List
16
+ customer = payment.customer # => Mollie::Customer
17
+ ```
18
+
19
+ ## Multi-currency
20
+
21
+ The Ruby client v4 adds support for multi-currency. All amounts are parsed as a
22
+ `Mollie::Amount` object.
23
+
24
+ ```ruby
25
+ payment = Mollie::Payment.create(
26
+ amount: { value: '42.10', currency: 'EUR' },
27
+ description: 'My first payment'
28
+ )
29
+
30
+ payment = Mollie::Payment.get('tr_7UhSN1zuXS')
31
+ payment.amount # => Mollie::Amount
32
+ payment.amount.value # => 42.10 # BigDecimal
33
+ payment.amount.currency # => 'EUR'
34
+ ```
35
+
36
+ **Note**: If you specify an amount, you must specify the *correct* number of decimals.
37
+ We strongly recommend sending value as a string. Note that even though most currencies
38
+ use two decimals, some use three or none, like JPY. All amounts returned in the v2
39
+ API will use this format.
40
+
41
+ ## Error handling
42
+
43
+ A `RequestError` is raised for all API error responses. The `RequestError` object
44
+ contains the following details:
45
+
46
+ * `status`: HTTP status code of the response
47
+ * `title`: Title of the error
48
+ * `detail`: Extra information about the error
49
+ * `field`: Field of your request that is likely causing the error. Only available in case of 422 Unprocessable Entity errors.
50
+ * `links`: Links to relevant API documentation
51
+
52
+ # Changes in Mollie API v2
53
+
54
+ * The identifier for the payment method Bancontact has been renamed from `mistercash` to `bancontact`
55
+ * Some resources support embedding of related sub-resources. For instance, when retrieving a payment
56
+ any refunds can be embedded by using the `embed: 'refunds'` option. See the
57
+ [Get payment documentation](https://docs.mollie.com/reference/v2/payments-api/get-payment) for more information.
58
+
59
+ ## Locale changes
60
+
61
+ Only full locales with both the language and the country code are supported,
62
+ e.g. `nl_NL`. Locales are always returned as full locales.
63
+
64
+ ## Combined date and time fields
65
+
66
+ Formatting of fields such as `created_at` has been updated to be strictly
67
+ compliant to ISO-8601 formatting. Example value: `2018-03-05T12:30:10+00:00`.
68
+
69
+ ## Changes in the Payments API
70
+
71
+ The following changes have been made in regards to the status of payments:
72
+
73
+ * The statuses `paidout`, `refunded` and `charged_back` have been removed
74
+ * The status `cancelled` has been renamed to `canceled` (US English spelling)
75
+ * The individual billing and shipping address parameters that can be used when
76
+ creating a credit card or PayPal payment have been replaced by address objects.
77
+ Instead of passing `billing_address`, `billing_postal`, `billing_city`, `billing_region`
78
+ and/or `billing_country` (or the equivalent fields starting with `shipping`), one
79
+ should now pass a `billing_address` (and/or `shipping_address`) object, as follows:
80
+
81
+ ```ruby
82
+ {
83
+ amount: { value: '100.00', currency: 'USD' },
84
+ description: 'My first payment',
85
+ billing_address: {
86
+ street_and_number: 'Dorpstraat 1',
87
+ postal_code: '1122 AA',
88
+ city: 'Amsterdam',
89
+ region: 'Noord-Holland',
90
+ country: 'NL'
91
+ }
92
+ }
93
+ ```
94
+
95
+ The following fields have been changed, renamed or moved:
96
+
97
+ * `cancelled_datetime` has been renamed to `canceled_at`
98
+ * `created_datetime` has been renamed to `created_at`
99
+ * `expired_datetime` has been renamed to `expired_at`
100
+ * `failed_datetime` has been renamed to `failed_at`
101
+ * `paid_datetime` has been renamed to `paid_at`
102
+ * `recurring_type` has been renamed to `sequence_type`. This field is now always present. A one-off payment (not the start of a recurring sequence and not a recurring payment) will have the value `oneoff`.
103
+ * `failure_reason` has been moved from the Payment resource to the credit card detail object, and no longer available for Bancontact payments.
104
+ * `details.bitcoin_amount` is now an amount object in the XBT currency
105
+
106
+ The following fields have been removed:
107
+
108
+ * `expiry_period` has been removed from the Payment resource. You can use `expires_at` which contains the same information.
109
+ * `issuer` has been removed from the Payment resource. You can however, still pass it to the Create payment API.
110
+ * `details.bitcoin_rate` has been removed from the Bitcoin detail object
111
+ * `details.card_country` has been removed from the credit card detail object
112
+ * The option to include the settlement using the `include` query string parameter has been removed
113
+
114
+ These new fields have been added:
115
+
116
+ * `settlement_amount` has been added to the responses of the Payments API, the Refunds API and the Chargebacks API. This optional field will contain the amount that will be settled to your account, converted to the currency your account is settled in. It follows the same syntax as the `amount` property.
117
+ * Note that for refunds and chargebacks, the `value` key of `settlement_amount` will be negative.
118
+ * Any amounts not settled by Mollie will not be reflected in this amount, e.g. PayPal or gift cards.
119
+ * `links['status']` has been added to the responses for `banktransfer` payments. Your customer can check the status of their transfer at this URL.
120
+ * `links['pay_online']` has been added to the responses for `banktransfer` payments. At this URL your customer can finish the payment using an alternative payment method also activated on your website profile.
121
+
122
+ ## Changes in the Refunds API
123
+
124
+ The following fields have been changed, renamed or moved:
125
+
126
+ * `amount` is now mandatory when creating a refund. You must specify both `amount.currency` and `amount.value`.
127
+ * The `amount` field is now of the `amount` type and contains a `value` and a `currency`
128
+ * `payment`, which contained the payment resource related to the refund, is no longer returned. Instead, the payment ID
129
+ is returned by default, in the `payment_id` field. The payment resource can still easily be accessed using the `payment`
130
+ helper method.
131
+
132
+ These new fields have been added:
133
+
134
+ * `settlement_amount` has been added. See the explanation of the [settlementAmount](https://docs.mollie.com/migrating-v1-to-v2#settlementamount) for the Payments API.
135
+
136
+ ## Changes in the Chargebacks API
137
+
138
+ The following fields have been changed, renamed or moved:
139
+
140
+ * The `amount` field is now of the `amount` type and contains a `value` and a `currency`
141
+ * `chargeback_datetime` has been renamed to `created_at`
142
+ * `reversed_datetime` has been renamed to `reversed_at`. This field is now only returned if the chargeback is reversed.
143
+ * `payment`, which contained the payment ID related to the chargeback, has been renamed to `payment_id`. The payment resource can easily be accessed using the `payment` helper method.
144
+ * Pagination has been removed, so all fields related to pagination are not available anymore. The list method will now return all chargebacks.
145
+
146
+ These new fields have been added:
147
+
148
+ * `settlement_amount` has been added. See the explanation of the [settlementAmount](https://docs.mollie.com/migrating-v1-to-v2#settlementamount) for the Payments API.
149
+
150
+ ## Changes in the Methods API
151
+
152
+ The following fields have been changed, renamed or moved:
153
+
154
+ * `amount` including `minimum` and `maximum` have been removed
155
+ * Pagination has been removed, so all fields related to pagination are not available anymore. The list method will now return all payment methods.
156
+
157
+ The following parameters have been changed or added:
158
+
159
+ * The parameter `recurring_type` has been renamed to `sequence_type`. Possible values are `oneoff`, `first` or `recurring`.
160
+ * The parameter `amount` has been added. This should be an object containing `value` and `currency`. Only payment methods that
161
+ support the amount/currency will be returned.
162
+
163
+ ## Changes in the Issuers API
164
+
165
+ The issuers API has been removed. Instead, you can get the issuers via the Get Method API using the `issuers` include.
166
+
167
+ ## Changes in the Customers API
168
+
169
+ The following fields have been changed, renamed or moved:
170
+
171
+ * `created_datetime` has been renamed to `created_at`
172
+ * `recently_used_methods` has been removed
173
+
174
+ ## Changes in the Subscriptions API
175
+
176
+ The following changes have been made in regards to the status of subscriptions:
177
+
178
+ * Subscriptions that are canceled can be retrieved from the API
179
+ * The `canceled` status is changed from British English to American English
180
+
181
+ The following fields have been changed, renamed or moved:
182
+
183
+ * `created_datetime` has been renamed to `created_at`
184
+ * `cancelled_datetime` has been renamed to `canceled_at`, and is now only returned when the subscription is canceled
185
+
186
+ ## Changes in the Profiles API
187
+
188
+ The following fields have been changed, renamed or removed:
189
+
190
+ * `created_datetime` has been renamed to `created_at`
191
+ * `updated_datetime` has been removed
192
+ * `phone` is now formatted in E.164 formatting
193
+ * The API keys subresource has been removed
194
+
195
+ ## Changes in the Settlements API
196
+
197
+ The following fields have been changed, renamed or moved:
198
+
199
+ * `created_datetime` has been renamed to `created_at`
200
+ * `settled_datetime` has been renamed to `settled_at`
201
+ * The fields `payment_ids`, `refund_ids` and `chargeback_ids` has been removed
202
+ * All amounts have been changed to the `amount` type. Note that the `costs.amount`* fields can have more decimals than you would expect. The same goes for `rate.fixed`, which can contain fractional cents.
203
+ * `amount.net`, `amount.vat` and `amount.gross` have been moved one level up as `amount_net`, `amount_vat` and `amount_gross`
204
+
205
+ ## Changes in the Mandates API
206
+
207
+ The following fields have been changed, renamed or moved:
208
+
209
+ * `created_datetime` has been renamed to `created_at`
210
+
211
+ ## Changes in the Organizations API
212
+
213
+ The fields `country`, `registration_date` and `registration_type` have been removed.
214
+ The field `address` is now an `OpenStruct` with address details. See
215
+ [Address object](https://docs.mollie.com/guides/common-data-types#address-object).
216
+
217
+ ## Changes in the Permissions API
218
+
219
+ The field `warning` has been removed.
220
+
221
+ ## Changes in the Invoice API
222
+
223
+ * `issued_date` has been renamed to `issued_at`
224
+ * `paid_date` has been renamed to `paid_at`
225
+ * `due_date` has been renamed to `due_at`
226
+ * `amount.net`, `amount.vat` and `amount.gross` have been moved one level up as
227
+ `amount_net`, `amount_vat` and `amountGross`