mollie-api-ruby 2.2.1 → 3.1.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.
Files changed (197) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +37 -8
  4. data/examples/apis/api_docs.rb +1 -1
  5. data/examples/apis/chargebacks.rb +17 -0
  6. data/examples/apis/connect.rb +1 -1
  7. data/examples/apis/customers.rb +7 -6
  8. data/examples/apis/invoices.rb +2 -2
  9. data/examples/apis/issuers.rb +2 -2
  10. data/examples/apis/mandates.rb +5 -5
  11. data/examples/apis/methods.rb +2 -2
  12. data/examples/apis/organizations.rb +1 -1
  13. data/examples/apis/payments.rb +43 -9
  14. data/examples/apis/permissions.rb +2 -2
  15. data/examples/apis/profiles.rb +7 -7
  16. data/examples/apis/refunds.rb +1 -1
  17. data/examples/apis/settlements.rb +5 -5
  18. data/examples/apis/subscriptions.rb +7 -7
  19. data/examples/config.ru +6 -7
  20. data/lib/{mollie/api/cacert.pem → cacert.pem} +0 -0
  21. data/lib/mollie-api-ruby.rb +1 -0
  22. data/lib/mollie.rb +39 -0
  23. data/lib/mollie/base.rb +91 -0
  24. data/lib/mollie/chargeback.rb +36 -0
  25. data/lib/mollie/client.rb +125 -0
  26. data/lib/mollie/customer.rb +36 -0
  27. data/lib/mollie/customer/mandate.rb +33 -0
  28. data/lib/mollie/customer/payment.rb +6 -0
  29. data/lib/mollie/customer/subscription.rb +65 -0
  30. data/lib/mollie/exception.rb +8 -0
  31. data/lib/mollie/invoice.rb +66 -0
  32. data/lib/mollie/issuer.rb +5 -0
  33. data/lib/mollie/list.rb +40 -0
  34. data/lib/mollie/method.rb +38 -0
  35. data/lib/mollie/organization.rb +24 -0
  36. data/lib/mollie/payment.rb +142 -0
  37. data/lib/mollie/payment/chargeback.rb +6 -0
  38. data/lib/mollie/payment/refund.rb +6 -0
  39. data/lib/mollie/permission.rb +26 -0
  40. data/lib/mollie/profile.rb +78 -0
  41. data/lib/mollie/profile/api_key.rb +19 -0
  42. data/lib/mollie/refund.rb +42 -0
  43. data/lib/mollie/relation.rb +36 -0
  44. data/lib/mollie/settlement.rb +36 -0
  45. data/lib/mollie/settlement/chargeback.rb +6 -0
  46. data/lib/mollie/settlement/payment.rb +6 -0
  47. data/lib/mollie/settlement/refund.rb +6 -0
  48. data/lib/mollie/util.rb +57 -0
  49. data/lib/mollie/version.rb +3 -0
  50. data/mollie.gemspec +2 -2
  51. data/test/helper.rb +5 -1
  52. data/test/mollie/base_test.rb +182 -0
  53. data/test/mollie/chargeback_test.rb +35 -0
  54. data/test/mollie/client_test.rb +122 -0
  55. data/test/mollie/customer/mandate_test.rb +43 -0
  56. data/test/mollie/customer/payment_test.rb +23 -0
  57. data/test/mollie/customer/subscription_test.rb +66 -0
  58. data/test/mollie/customer_test.rb +128 -0
  59. data/test/mollie/invoice_test.rb +55 -0
  60. data/test/mollie/issuer_test.rb +19 -0
  61. data/test/mollie/list_test.rb +40 -0
  62. data/test/mollie/method_test.rb +29 -0
  63. data/test/mollie/organization_test.rb +41 -0
  64. data/test/mollie/payment/chargeback_test.rb +22 -0
  65. data/test/mollie/payment/refund_test.rb +22 -0
  66. data/test/mollie/payment_test.rb +161 -0
  67. data/test/mollie/permission_test.rb +21 -0
  68. data/test/mollie/profile/apikey_test.rb +31 -0
  69. data/test/mollie/profile_test.rb +98 -0
  70. data/test/mollie/refund_test.rb +40 -0
  71. data/test/mollie/settlement/chargeback_test.rb +22 -0
  72. data/test/mollie/settlement/payment_test.rb +22 -0
  73. data/test/mollie/settlement/refund_test.rb +22 -0
  74. data/test/mollie/settlement_test.rb +156 -0
  75. data/website-docs/chargebacks/list-all.rb +12 -0
  76. data/website-docs/connect/authorize.rb +15 -0
  77. data/website-docs/connect/tokens.rb +14 -0
  78. data/website-docs/customers/create-payment.rb +13 -0
  79. data/website-docs/customers/create.rb +12 -0
  80. data/website-docs/customers/delete.rb +10 -0
  81. data/website-docs/customers/get.rb +10 -0
  82. data/website-docs/customers/list-payments.rb +10 -0
  83. data/website-docs/customers/list.rb +12 -0
  84. data/website-docs/customers/update.rb +11 -0
  85. data/website-docs/invoices/get.rb +10 -0
  86. data/website-docs/invoices/list.rb +12 -0
  87. data/website-docs/issuers/get.rb +10 -0
  88. data/website-docs/issuers/list.rb +12 -0
  89. data/website-docs/mandates/create.rb +16 -0
  90. data/website-docs/mandates/delete.rb +10 -0
  91. data/website-docs/mandates/get.rb +10 -0
  92. data/website-docs/mandates/list.rb +12 -0
  93. data/website-docs/methods/get.rb +10 -0
  94. data/website-docs/methods/list.rb +12 -0
  95. data/website-docs/organisations/get.rb +10 -0
  96. data/website-docs/payments/create-refund.rb +14 -0
  97. data/website-docs/payments/create.rb +16 -0
  98. data/website-docs/payments/delete-refund.rb +13 -0
  99. data/website-docs/payments/delete.rb +12 -0
  100. data/website-docs/payments/get-chargeback.rb +11 -0
  101. data/website-docs/payments/get-refund.rb +11 -0
  102. data/website-docs/payments/get.rb +10 -0
  103. data/website-docs/payments/list-chargeback.rb +13 -0
  104. data/website-docs/payments/list-refunds.rb +13 -0
  105. data/website-docs/payments/list.rb +12 -0
  106. data/website-docs/payments/payment-webhook.rb +21 -0
  107. data/website-docs/permissions/get.rb +10 -0
  108. data/website-docs/permissions/list.rb +12 -0
  109. data/website-docs/profiles/create.rb +15 -0
  110. data/website-docs/profiles/delete.rb +10 -0
  111. data/website-docs/profiles/get-key.rb +11 -0
  112. data/website-docs/profiles/get.rb +10 -0
  113. data/website-docs/profiles/list-keys.rb +13 -0
  114. data/website-docs/profiles/list.rb +12 -0
  115. data/website-docs/profiles/reset-key.rb +13 -0
  116. data/website-docs/profiles/update.rb +12 -0
  117. data/website-docs/refunds/list.rb +12 -0
  118. data/website-docs/settlements/get.rb +10 -0
  119. data/website-docs/settlements/list-chargebacks.rb +13 -0
  120. data/website-docs/settlements/list-payments.rb +13 -0
  121. data/website-docs/settlements/list-refunds.rb +13 -0
  122. data/website-docs/settlements/list.rb +12 -0
  123. data/website-docs/settlements/next.rb +9 -0
  124. data/website-docs/settlements/open.rb +9 -0
  125. data/website-docs/subscriptions/create.rb +14 -0
  126. data/website-docs/subscriptions/delete.rb +10 -0
  127. data/website-docs/subscriptions/get.rb +10 -0
  128. data/website-docs/subscriptions/list.rb +12 -0
  129. metadata +134 -104
  130. data/lib/mollie/api/client.rb +0 -161
  131. data/lib/mollie/api/client/version.rb +0 -7
  132. data/lib/mollie/api/exception.rb +0 -10
  133. data/lib/mollie/api/object/base.rb +0 -18
  134. data/lib/mollie/api/object/customer.rb +0 -28
  135. data/lib/mollie/api/object/customer/mandate.rb +0 -37
  136. data/lib/mollie/api/object/customer/subscription.rb +0 -69
  137. data/lib/mollie/api/object/invoice.rb +0 -70
  138. data/lib/mollie/api/object/issuer.rb +0 -9
  139. data/lib/mollie/api/object/list.rb +0 -44
  140. data/lib/mollie/api/object/method.rb +0 -42
  141. data/lib/mollie/api/object/organization.rb +0 -28
  142. data/lib/mollie/api/object/payment.rb +0 -137
  143. data/lib/mollie/api/object/payment/refund.rb +0 -47
  144. data/lib/mollie/api/object/permission.rb +0 -12
  145. data/lib/mollie/api/object/profile.rb +0 -78
  146. data/lib/mollie/api/object/profile/apikey.rb +0 -23
  147. data/lib/mollie/api/object/settlement.rb +0 -32
  148. data/lib/mollie/api/resource/base.rb +0 -53
  149. data/lib/mollie/api/resource/customers.rb +0 -11
  150. data/lib/mollie/api/resource/customers/mandates.rb +0 -27
  151. data/lib/mollie/api/resource/customers/payments.rb +0 -27
  152. data/lib/mollie/api/resource/customers/subscriptions.rb +0 -27
  153. data/lib/mollie/api/resource/invoices.rb +0 -11
  154. data/lib/mollie/api/resource/issuers.rb +0 -11
  155. data/lib/mollie/api/resource/methods.rb +0 -11
  156. data/lib/mollie/api/resource/organizations.rb +0 -11
  157. data/lib/mollie/api/resource/payments.rb +0 -11
  158. data/lib/mollie/api/resource/payments/refunds.rb +0 -27
  159. data/lib/mollie/api/resource/permissions.rb +0 -31
  160. data/lib/mollie/api/resource/profiles.rb +0 -11
  161. data/lib/mollie/api/resource/profiles/apikeys.rb +0 -33
  162. data/lib/mollie/api/resource/refunds.rb +0 -11
  163. data/lib/mollie/api/resource/settlements.rb +0 -19
  164. data/lib/mollie/api/resource/settlements/payments.rb +0 -27
  165. data/lib/mollie/api/util.rb +0 -53
  166. data/test/mollie/api/client_test.rb +0 -111
  167. data/test/mollie/api/object/base_test.rb +0 -21
  168. data/test/mollie/api/object/customer/mandate_test.rb +0 -47
  169. data/test/mollie/api/object/customer/subscription_test.rb +0 -70
  170. data/test/mollie/api/object/customer_test.rb +0 -35
  171. data/test/mollie/api/object/invoice_test.rb +0 -59
  172. data/test/mollie/api/object/issuer_test.rb +0 -23
  173. data/test/mollie/api/object/list_test.rb +0 -44
  174. data/test/mollie/api/object/method_test.rb +0 -33
  175. data/test/mollie/api/object/organization_test.rb +0 -45
  176. data/test/mollie/api/object/payment/refund_test.rb +0 -46
  177. data/test/mollie/api/object/payment_test.rb +0 -106
  178. data/test/mollie/api/object/permission_test.rb +0 -25
  179. data/test/mollie/api/object/profile/apikey_test.rb +0 -35
  180. data/test/mollie/api/object/profile_test.rb +0 -72
  181. data/test/mollie/api/object/settlement_test.rb +0 -140
  182. data/test/mollie/api/resource/base_test.rb +0 -83
  183. data/test/mollie/api/resource/customers/mandates_test.rb +0 -23
  184. data/test/mollie/api/resource/customers/payments_test.rb +0 -23
  185. data/test/mollie/api/resource/customers/subscriptions_test.rb +0 -23
  186. data/test/mollie/api/resource/customers_test.rb +0 -13
  187. data/test/mollie/api/resource/invoices_test.rb +0 -13
  188. data/test/mollie/api/resource/issuers_test.rb +0 -13
  189. data/test/mollie/api/resource/methods_test.rb +0 -13
  190. data/test/mollie/api/resource/organizations_test.rb +0 -13
  191. data/test/mollie/api/resource/payments/refunds_test.rb +0 -23
  192. data/test/mollie/api/resource/payments_test.rb +0 -13
  193. data/test/mollie/api/resource/permissions_test.rb +0 -13
  194. data/test/mollie/api/resource/profiles/apikeys_test.rb +0 -23
  195. data/test/mollie/api/resource/profiles_test.rb +0 -13
  196. data/test/mollie/api/resource/settlements_test.rb +0 -13
  197. data/test/mollie/api/util_test.rb +0 -47
@@ -1,59 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class InvoiceTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- resource: "invoice",
10
- id: "inv_xBEbP9rvAq",
11
- reference: "2016.10000",
12
- vat_number: "NL001234567B01",
13
- status: "open",
14
- issue_date: "2016-08-31",
15
- due_date: "2016-09-14",
16
- amount: {
17
- net: "45.00",
18
- vat: "9.45",
19
- gross: "54.45"
20
- },
21
- lines: [{
22
- period: "2016-09",
23
- description: "iDEAL transactiekosten",
24
- count: 100,
25
- vat_percentage: 21,
26
- amount: "45.00"
27
- }],
28
- links: {
29
- 'pdf' => "https://www.mollie.com/beheer/facturen/2016.10000/52981a39788e5e0acaf71bbf570e941f/"
30
- }
31
- }
32
-
33
- invoice = Invoice.new(attributes)
34
-
35
- assert_equal "invoice", invoice.resource
36
- assert_equal "inv_xBEbP9rvAq", invoice.id
37
- assert_equal "2016.10000", invoice.reference
38
- assert_equal "NL001234567B01", invoice.vat_number
39
- assert_equal "open", invoice.status
40
- assert_equal Time.parse("2016-08-31"), invoice.issue_date
41
- assert_equal Time.parse("2016-09-14"), invoice.due_date
42
- assert_equal 45.0, invoice.amount.net
43
- assert_equal BigDecimal.new(9.45, 3), invoice.amount.vat
44
- assert_equal 54.45, invoice.amount.gross
45
-
46
- line = invoice.lines.first
47
- assert_equal "2016-09", line.period
48
- assert_equal "iDEAL transactiekosten", line.description
49
- assert_equal 100, line.count
50
- assert_equal 21, line.vat_percentage
51
- assert_equal 45.0, line.amount
52
-
53
-
54
- assert_equal "https://www.mollie.com/beheer/facturen/2016.10000/52981a39788e5e0acaf71bbf570e941f/", invoice.pdf
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,23 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class IssuerTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- id: 'ideal_ABNANL2A',
10
- name: 'ABN AMRO',
11
- method: 'ideal'
12
- }
13
-
14
- customer = Issuer.new(attributes)
15
-
16
- assert_equal 'ideal_ABNANL2A', customer.id
17
- assert_equal 'ABN AMRO', customer.name
18
- assert_equal 'ideal', customer.method
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,44 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class ListTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- 'total_count' => 280,
10
- 'offset' => 0,
11
- 'count' => 10,
12
- 'data' => [
13
- { 'id' => "tr_1" },
14
- { 'id' => "tr_2" },
15
- ],
16
- 'links' => {
17
- 'first' => "https://api.mollie.nl/v1/payments?count=10&offset=0",
18
- 'previous' => nil,
19
- 'next' => "https://api.mollie.nl/v1/payments?count=10&offset=10",
20
- 'last' => "https://api.mollie.nl/v1/payments?count=10&offset=270"
21
- }
22
- }
23
-
24
- list = List.new(attributes, Payment)
25
-
26
- assert_equal 280, list.total_count
27
- assert_equal 0, list.offset
28
- assert_equal 10, list.count
29
-
30
- assert_kind_of Payment, list.to_a[0]
31
- assert_equal "tr_1", list.to_a[0].id
32
-
33
- assert_kind_of Payment, list.to_a[1]
34
- assert_equal "tr_2", list.to_a[1].id
35
-
36
- assert_equal "https://api.mollie.nl/v1/payments?count=10&offset=0", list.first_url
37
- assert_equal nil, list.previous_url
38
- assert_equal "https://api.mollie.nl/v1/payments?count=10&offset=10", list.next_url
39
- assert_equal "https://api.mollie.nl/v1/payments?count=10&offset=270", list.last_url
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,33 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class MethodTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- id: "creditcard",
10
- description: "Credit card",
11
- amount: {
12
- 'minimum' => "0.31",
13
- 'maximum' => "10000.00"
14
- },
15
- image: {
16
- 'normal' => "https://www.mollie.com/images/payscreen/methods/creditcard.png",
17
- 'bigger' => "https://www.mollie.com/images/payscreen/methods/creditcard@2x.png"
18
- }
19
- }
20
-
21
- method = Method.new(attributes)
22
-
23
- assert_equal "creditcard", method.id
24
- assert_equal "Credit card", method.description
25
- assert_equal BigDecimal.new("0.31"), method.minimum_amount
26
- assert_equal BigDecimal.new("10000.0"), method.maximum_amount
27
- assert_equal "https://www.mollie.com/images/payscreen/methods/creditcard.png", method.normal_image
28
- assert_equal "https://www.mollie.com/images/payscreen/methods/creditcard@2x.png", method.bigger_image
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,45 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class OrganizationTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- id: 'org_1234567',
10
- name: 'Mollie B.V.',
11
- email: 'info@mollie.com',
12
- address: 'Keizersgracht 313',
13
- postal_code: '1016EE',
14
- city: 'Amsterdam',
15
- country: 'Netherlands',
16
- country_code: 'NL',
17
- registration_type: 'bv',
18
- registration_number: '30204462',
19
- registration_datetime: '2004-04-01T09:41:00.0Z',
20
- verified_datetime: '2007-06-29T09:41:00.0Z'
21
- }
22
-
23
- organization = Organization.new(attributes)
24
-
25
- assert_equal 'org_1234567', organization.id
26
- assert_equal 'Mollie B.V.', organization.name
27
- assert_equal 'info@mollie.com', organization.email
28
- assert_equal 'Keizersgracht 313', organization.address
29
- assert_equal '1016EE', organization.postal_code
30
- assert_equal 'Amsterdam', organization.city
31
- assert_equal 'Netherlands', organization.country
32
- assert_equal 'NL', organization.country_code
33
- assert_equal 'bv', organization.registration_type
34
- assert_equal '30204462', organization.registration_number
35
- assert_equal Time.parse('2004-04-01T09:41:00.0Z'), organization.registration_datetime
36
- assert_equal Time.parse('2007-06-29T09:41:00.0Z'), organization.verified_datetime
37
- end
38
-
39
- def test_verified_datetime_optional
40
- assert_equal nil, Organization.new(verified_datetime: nil).verified_datetime
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,46 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class Payment
7
- class RefundTest < Test::Unit::TestCase
8
- def test_setting_attributes
9
- attributes = {
10
- id: "re_4qqhO89gsT",
11
- payment: {
12
- id: "tr_WDqYK6vllg",
13
- },
14
- amount: "5.95",
15
- refunded_datetime: "2016-10-08T07:59:53.0Z",
16
- status: "pending"
17
- }
18
-
19
- refund = Refund.new(attributes)
20
-
21
- assert_equal "re_4qqhO89gsT", refund.id
22
- assert_equal BigDecimal.new("5.95"), refund.amount
23
- assert_kind_of Payment, refund.payment
24
- assert_equal Time.parse("2016-10-08T07:59:53.0Z"), refund.refunded_datetime
25
- assert_equal Refund::STATUS_PENDING, refund.status
26
- end
27
-
28
- def test_pending?
29
- assert Refund.new(status: Refund::STATUS_PENDING).pending?
30
- assert !Refund.new(status: 'not-pending').pending?
31
- end
32
-
33
- def test_processing?
34
- assert Refund.new(status: Refund::STATUS_PROCESSING).processing?
35
- assert !Refund.new(status: 'not-processing').processing?
36
- end
37
-
38
- def test_refunded?
39
- assert Refund.new(status: Refund::STATUS_REFUNDED).refunded?
40
- assert !Refund.new(status: 'not-refunded').refunded?
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,106 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class PaymentTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- id: 'tr_WDqYK6vllg',
10
- mode: 'test',
11
- created_datetime: '2016-10-08T10:10:52.0Z',
12
- status: 'paid',
13
- paid_datetime: '2016-10-08T10:15:35.0Z',
14
- amount: 35.07,
15
- description: 'Order 33',
16
- method: 'ideal',
17
- metadata: {
18
- order_id: '33'
19
- },
20
- details: {
21
- consumer_name: "Hr E G H K\u00fcppers en\/of MW M.J. K\u00fcppers-Veeneman",
22
- consumer_account: 'NL53INGB0618365937',
23
- consumer_bic: 'INGBNL2A'
24
- },
25
- locale: 'nl',
26
- profile_id: 'pfl_QkEhN94Ba',
27
- links: {
28
- 'webhook_url' => 'https://webshop.example.org/payments/webhook',
29
- 'redirect_url' => 'https://webshop.example.org/order/33/',
30
- 'payment_url' => 'https://webshop.example.org/payment/tr_WDqYK6vllg',
31
- 'settlement' => 'https://webshop.example.org/payment/tr_WDqYK6vllg/settlement',
32
- 'refunds' => 'https://webshop.example.org/payment/tr_WDqYK6vllg/refunds',
33
- }
34
- }
35
-
36
- payment = Payment.new(attributes)
37
-
38
- assert_equal 'tr_WDqYK6vllg', payment.id
39
- assert_equal 'test', payment.mode
40
- assert_equal Time.parse('2016-10-08T10:10:52.0Z'), payment.created_datetime
41
- assert_equal 'paid', payment.status
42
- assert_equal Time.parse('2016-10-08T10:15:35.0Z'), payment.paid_datetime
43
- assert_equal 35.07, payment.amount
44
- assert_equal 'Order 33', payment.description
45
- assert_equal 'ideal', payment.method
46
- assert_equal '33', payment.metadata.order_id
47
- assert_equal "Hr E G H K\u00fcppers en\/of MW M.J. K\u00fcppers-Veeneman", payment.details.consumer_name
48
- assert_equal 'NL53INGB0618365937', payment.details.consumer_account
49
- assert_equal 'INGBNL2A', payment.details.consumer_bic
50
- assert_equal 'nl', payment.locale
51
- assert_equal 'pfl_QkEhN94Ba', payment.profile_id
52
- assert_equal 'https://webshop.example.org/payments/webhook', payment.webhook_url
53
- assert_equal 'https://webshop.example.org/order/33/', payment.redirect_url
54
- assert_equal 'https://webshop.example.org/payment/tr_WDqYK6vllg', payment.payment_url
55
- assert_equal 'https://webshop.example.org/payment/tr_WDqYK6vllg/settlement', payment.settlement
56
- assert_equal 'https://webshop.example.org/payment/tr_WDqYK6vllg/refunds', payment.refunds
57
- end
58
-
59
- def test_status_open
60
- assert Payment.new(status: Payment::STATUS_OPEN).open?
61
- assert !Payment.new(status: 'not-open').open?
62
- end
63
-
64
- def test_status_cancelled
65
- assert Payment.new(status: Payment::STATUS_CANCELLED).cancelled?
66
- assert !Payment.new(status: 'not-cancelled').cancelled?
67
- end
68
-
69
- def test_status_expired
70
- assert Payment.new(status: Payment::STATUS_EXPIRED).expired?
71
- assert !Payment.new(status: 'not-expired').expired?
72
- end
73
-
74
- def test_status_paidout
75
- assert Payment.new(status: Payment::STATUS_PAIDOUT).paidout?
76
- assert !Payment.new(status: 'not-paidout').paidout?
77
- end
78
-
79
- def test_status_refunded
80
- assert Payment.new(status: Payment::STATUS_REFUNDED).refunded?
81
- assert !Payment.new(status: 'not-refunded').refunded?
82
- end
83
-
84
- def test_status_paid
85
- assert Payment.new(paid_datetime: Time.now).paid?
86
- assert !Payment.new(paid_datetime: nil).paid?
87
- end
88
-
89
- def test_status_failed
90
- assert Payment.new(status: Payment::STATUS_FAILED).failed?
91
- assert !Payment.new(status: 'not-failed').failed?
92
- end
93
-
94
- def test_status_pending
95
- assert Payment.new(status: Payment::STATUS_PENDING).pending?
96
- assert !Payment.new(status: 'not-pending').pending?
97
- end
98
-
99
- def test_status_charged_back
100
- assert Payment.new(status: Payment::STATUS_CHARGED_BACK).charged_back?
101
- assert !Payment.new(status: 'not-charged-back').charged_back?
102
- end
103
- end
104
- end
105
- end
106
- end
@@ -1,25 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class PermissionTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- id: 'payments.read',
10
- description: 'View your payments',
11
- warning: nil,
12
- granted: true
13
- }
14
-
15
- permission = Permission.new(attributes)
16
-
17
- assert_equal 'payments.read', permission.id
18
- assert_equal 'View your payments', permission.description
19
- assert_equal nil, permission.warning
20
- assert_equal true, permission.granted
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,35 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class Profile
7
- class ApiKeyTest < Test::Unit::TestCase
8
- def test_setting_attributes
9
- attributes = {
10
- id: "live",
11
- key: "live_eSf9fQRwpsdfPY8y3tUFFmqjADRKyA",
12
- created_datetime: "2017-04-20T12:19:48.0Z"
13
- }
14
-
15
- api_key = ApiKey.new(attributes)
16
-
17
- assert_equal Mollie::API::Client::MODE_LIVE, api_key.id
18
- assert_equal "live_eSf9fQRwpsdfPY8y3tUFFmqjADRKyA", api_key.key
19
- assert_equal Time.parse("2017-04-20T12:19:48.0Z"), api_key.created_datetime
20
- end
21
-
22
- def test_testmode
23
- assert ApiKey.new(id: Mollie::API::Client::MODE_TEST).testmode?
24
- assert !ApiKey.new(id: 'not-test').testmode?
25
- end
26
-
27
- def test_livemode
28
- assert ApiKey.new(id: Mollie::API::Client::MODE_LIVE).livemode?
29
- assert !ApiKey.new(id: 'not-live').livemode?
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,72 +0,0 @@
1
- require 'helper'
2
-
3
- module Mollie
4
- module API
5
- module Object
6
- class ProfileTest < Test::Unit::TestCase
7
- def test_setting_attributes
8
- attributes = {
9
- id: 'pfl_v9hTwCvYqw',
10
- mode: 'live',
11
- name: 'My website name',
12
- website: 'https://www.mywebsite.com',
13
- email: 'info@mywebsite.com',
14
- phone: '31123456789',
15
- category_code: 5399,
16
- status: 'unverified',
17
- review: {
18
- status: 'pending'
19
- },
20
- created_datetime: '2017-04-20T09:03:58.0Z',
21
- updated_datetime: '2017-04-20T09:03:58.0Z',
22
- links: {
23
- 'apikeys' => 'https://api.mollie.nl/v1/profiles/pfl_v9hTwCvYqw/apikeys',
24
- 'checkout_preview_url' => 'https://www.mollie.com/beheer/account_profielen/preview-payscreen/1337',
25
- }
26
- }
27
-
28
- profile = Profile.new(attributes)
29
-
30
- assert_equal 'pfl_v9hTwCvYqw', profile.id
31
- assert_equal 'live', profile.mode
32
- assert_equal 'My website name', profile.name
33
- assert_equal 'https://www.mywebsite.com', profile.website
34
- assert_equal 'info@mywebsite.com', profile.email
35
- assert_equal '31123456789', profile.phone
36
- assert_equal 5399, profile.category_code
37
- assert_equal Profile::STATUS_UNVERIFIED, profile.status
38
- assert_equal Profile::REVIEW_STATUS_PENDING, profile.review.status
39
- assert_equal Time.parse('2017-04-20T09:03:58.0Z'), profile.created_datetime
40
- assert_equal Time.parse('2017-04-20T09:03:58.0Z'), profile.updated_datetime
41
- assert_equal 'https://api.mollie.nl/v1/profiles/pfl_v9hTwCvYqw/apikeys', profile.apikeys
42
- assert_equal 'https://www.mollie.com/beheer/account_profielen/preview-payscreen/1337', profile.checkout_preview_url
43
- end
44
-
45
- def test_status_unverified
46
- assert Profile.new(status: Profile::STATUS_UNVERIFIED).unverified?
47
- assert !Profile.new(status: 'not-unverified').unverified?
48
- end
49
-
50
- def test_status_verified
51
- assert Profile.new(status: Profile::STATUS_VERIFIED).verified?
52
- assert !Profile.new(status: 'not-verified').verified?
53
- end
54
-
55
- def test_status_blocked
56
- assert Profile.new(status: Profile::STATUS_BLOCKED).blocked?
57
- assert !Profile.new(status: 'not-blocked').blocked?
58
- end
59
-
60
- def test_review_status_pending
61
- assert Profile.new(review: {status: Profile::REVIEW_STATUS_PENDING}).review_pending?
62
- assert !Profile.new(review: {status: 'not-pending'}).review_pending?
63
- end
64
-
65
- def test_review_status_rejected
66
- assert Profile.new(review: {status: Profile::REVIEW_STATUS_REJECTED}).review_rejected?
67
- assert !Profile.new(review: {status: 'not-rejected'}).review_rejected?
68
- end
69
- end
70
- end
71
- end
72
- end