tikkie-api 0.2.2 → 2.0.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -16
  3. data/.travis.yml +5 -5
  4. data/Gemfile +3 -2
  5. data/Gemfile.lock +23 -24
  6. data/LICENSE.txt +1 -1
  7. data/README.md +198 -69
  8. data/lib/tikkie/api.rb +52 -25
  9. data/lib/tikkie/api/amount.rb +35 -0
  10. data/lib/tikkie/api/client.rb +16 -8
  11. data/lib/tikkie/api/clients/base.rb +16 -0
  12. data/lib/tikkie/api/clients/payment_requests.rb +25 -0
  13. data/lib/tikkie/api/clients/payment_requests_subscription.rb +20 -0
  14. data/lib/tikkie/api/clients/payments.rb +20 -0
  15. data/lib/tikkie/api/clients/refunds.rb +20 -0
  16. data/lib/tikkie/api/clients/sandbox_apps.rb +15 -0
  17. data/lib/tikkie/api/configuration.rb +8 -47
  18. data/lib/tikkie/api/exception.rb +28 -8
  19. data/lib/tikkie/api/request.rb +51 -27
  20. data/lib/tikkie/api/resources/base.rb +66 -0
  21. data/lib/tikkie/api/{responses → resources}/error.rb +11 -9
  22. data/lib/tikkie/api/resources/list.rb +52 -0
  23. data/lib/tikkie/api/resources/payment.rb +68 -0
  24. data/lib/tikkie/api/resources/payment_request.rb +97 -0
  25. data/lib/tikkie/api/resources/payment_requests.rb +40 -0
  26. data/lib/tikkie/api/resources/payment_requests_subscription.rb +24 -0
  27. data/lib/tikkie/api/resources/payments.rb +48 -0
  28. data/lib/tikkie/api/resources/refund.rb +71 -0
  29. data/lib/tikkie/api/resources/sandbox_app.rb +20 -0
  30. data/lib/tikkie/api/response.rb +64 -0
  31. data/lib/tikkie/api/v1/access_token.rb +21 -0
  32. data/lib/tikkie/api/v1/authentication.rb +67 -0
  33. data/lib/tikkie/api/v1/client.rb +26 -0
  34. data/lib/tikkie/api/v1/configuration.rb +64 -0
  35. data/lib/tikkie/api/v1/exception.rb +24 -0
  36. data/lib/tikkie/api/v1/request.rb +59 -0
  37. data/lib/tikkie/api/v1/requests/payment_requests.rb +59 -0
  38. data/lib/tikkie/api/v1/requests/platforms.rb +34 -0
  39. data/lib/tikkie/api/v1/requests/users.rb +33 -0
  40. data/lib/tikkie/api/v1/responses/bank_account.rb +24 -0
  41. data/lib/tikkie/api/v1/responses/base.rb +69 -0
  42. data/lib/tikkie/api/v1/responses/error.rb +36 -0
  43. data/lib/tikkie/api/v1/responses/pagination.rb +22 -0
  44. data/lib/tikkie/api/v1/responses/payment.rb +50 -0
  45. data/lib/tikkie/api/v1/responses/payment_request.rb +68 -0
  46. data/lib/tikkie/api/v1/responses/payment_request_created.rb +24 -0
  47. data/lib/tikkie/api/v1/responses/payment_requests.rb +44 -0
  48. data/lib/tikkie/api/v1/responses/platform.rb +46 -0
  49. data/lib/tikkie/api/v1/responses/platforms.rb +34 -0
  50. data/lib/tikkie/api/v1/responses/user.rb +43 -0
  51. data/lib/tikkie/api/v1/responses/users.rb +38 -0
  52. data/lib/tikkie/api/v1/types/payment_request_status.rb +17 -0
  53. data/lib/tikkie/api/v1/types/payment_status.rb +16 -0
  54. data/lib/tikkie/api/v1/types/platform_status.rb +14 -0
  55. data/lib/tikkie/api/v1/types/platform_usage.rb +14 -0
  56. data/lib/tikkie/api/v1/types/user_status.rb +14 -0
  57. data/lib/tikkie/api/version.rb +1 -1
  58. data/lib/tikkie/notification.rb +23 -0
  59. data/lib/tikkie/notifications/bundle_notification.rb +28 -0
  60. data/lib/tikkie/notifications/payment_notification.rb +32 -0
  61. data/lib/tikkie/notifications/refund_notification.rb +36 -0
  62. data/tikkie-api.gemspec +3 -2
  63. metadata +69 -43
  64. data/lib/tikkie/api/access_token.rb +0 -19
  65. data/lib/tikkie/api/authentication.rb +0 -65
  66. data/lib/tikkie/api/requests/payment_requests.rb +0 -57
  67. data/lib/tikkie/api/requests/platforms.rb +0 -32
  68. data/lib/tikkie/api/requests/users.rb +0 -31
  69. data/lib/tikkie/api/responses/bank_account.rb +0 -22
  70. data/lib/tikkie/api/responses/base.rb +0 -67
  71. data/lib/tikkie/api/responses/pagination.rb +0 -20
  72. data/lib/tikkie/api/responses/payment.rb +0 -48
  73. data/lib/tikkie/api/responses/payment_request.rb +0 -66
  74. data/lib/tikkie/api/responses/payment_request_created.rb +0 -22
  75. data/lib/tikkie/api/responses/payment_requests.rb +0 -42
  76. data/lib/tikkie/api/responses/platform.rb +0 -44
  77. data/lib/tikkie/api/responses/platforms.rb +0 -32
  78. data/lib/tikkie/api/responses/user.rb +0 -41
  79. data/lib/tikkie/api/responses/users.rb +0 -36
  80. data/lib/tikkie/api/types/payment_request_status.rb +0 -15
  81. data/lib/tikkie/api/types/payment_status.rb +0 -14
  82. data/lib/tikkie/api/types/platform_status.rb +0 -12
  83. data/lib/tikkie/api/types/platform_usage.rb +0 -12
  84. data/lib/tikkie/api/types/user_status.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f4d893b32e4248abc8219002f82b11d0757bd059cc89553b80908bcbae03ba2
4
- data.tar.gz: 543b543363b0fe2b287349264e1804aae8b020f759d413d38d4093c2bc465f81
3
+ metadata.gz: c22db51585d284e809e24912acf561c023f9063da1669fdc49330dd223039f32
4
+ data.tar.gz: e7bf5498e81def5bbf47efa0800d9bb8dc1248cb154df1b227004ab7b2fc80f0
5
5
  SHA512:
6
- metadata.gz: 4405434842ba9fcfe8f3dba8f0d560b8b475271373b5c6106166b4fe7293a4f84a7b879d0ec5f3fd2f58fc2f9b68626de1e4fdfa25e525031b841e6539986d0e
7
- data.tar.gz: bc98a44e82d8545aa074e891847329de168fcbf889a3c94c7bbcbd158ced93509e367598f66f48d301c146af158a34b140e9a7381590c2ac811218d4a33b439d
6
+ metadata.gz: 1c99bc7d78ed22482810d6f12042fe0497ed298cee190c5a73404d9028ab408cf4770ad8650a6cab6bbe4b42b78c852b2e877fcdedc77c7d5a3ce5f778a1373b
7
+ data.tar.gz: b48d40c3a519e24a83582e5ccc1c66f882d09d16a5090f1ac628c4610c5c9e75ee2c5a8442d360adf13a60becf1f182424fe401186e2a07710e0004e37ea977c
@@ -1,49 +1,53 @@
1
- require: rubocop-rspec
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
2
4
 
3
5
  AllCops:
4
- TargetRubyVersion: 2.3
6
+ TargetRubyVersion: 2.4
5
7
  DisplayCopNames: true
6
8
  DisplayStyleGuide: true
9
+ Exclude:
10
+ - 'lib/tikkie/api/v1/**/*'
11
+ - 'spec/tikkie/api/v1/**/*'
12
+ - 'vendor/**/*'
13
+
14
+
15
+ Layout/LineLength:
16
+ Enabled: false
7
17
 
8
18
 
9
19
  Metrics/AbcSize:
10
- Max: 21
20
+ Max: 43
11
21
 
12
22
  Metrics/BlockLength:
13
23
  Exclude:
14
24
  - 'spec/**/*'
15
25
 
16
26
  Metrics/CyclomaticComplexity:
17
- Max: 7
18
-
19
- Metrics/LineLength:
20
- Enabled: false
27
+ Max: 11
21
28
 
22
29
  Metrics/MethodLength:
23
30
  Enabled: false
24
31
 
32
+ Metrics/PerceivedComplexity:
33
+ Max: 9
34
+
25
35
 
26
36
  RSpec/DescribedClass:
27
37
  EnforcedStyle: explicit
28
38
 
29
39
  RSpec/ExampleLength:
30
- Max: 8
40
+ Max: 12
31
41
 
32
42
  RSpec/MultipleExpectations:
33
- Max: 4
34
-
35
- RSpec/NamedSubject:
36
- Enabled: false
43
+ Max: 8
37
44
 
38
45
 
39
46
  Style/Documentation:
40
47
  Exclude:
41
48
  - 'spec/**/*'
42
49
 
43
- Style/GuardClause:
44
- Enabled: false
45
-
46
- Style/IfUnlessModifier:
50
+ Style/FormatStringToken:
47
51
  Enabled: false
48
52
 
49
53
  Style/SafeNavigation:
@@ -3,9 +3,9 @@ language: ruby
3
3
  cache: bundler
4
4
  before_install:
5
5
  - gem update --system
6
- - gem update bundler
6
+ - gem install bundler -v '< 2'
7
7
  rvm:
8
- - 2.3.8
9
- - 2.4.5
10
- - 2.5.3
11
- - 2.6.1
8
+ - 2.4.10
9
+ - 2.5.8
10
+ - 2.6.6
11
+ - 2.7.2
data/Gemfile CHANGED
@@ -7,5 +7,6 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
  # Specify your gem's dependencies in tikkie-api.gemspec
8
8
  gemspec
9
9
 
10
- gem 'rubocop', '~> 0.65.0'
11
- gem 'rubocop-rspec', '~> 1.32.0'
10
+ gem 'rubocop', '~> 0.79.0'
11
+ gem 'rubocop-performance', '~> 1.6.1'
12
+ gem 'rubocop-rspec', '~> 1.41.0'
@@ -1,29 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tikkie-api (0.2.2)
5
- jwt (>= 1.0)
4
+ tikkie-api (2.0.0)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
9
  addressable (2.6.0)
11
10
  public_suffix (>= 2.0.2, < 4.0)
12
- ast (2.4.0)
11
+ ast (2.4.1)
13
12
  crack (0.4.3)
14
13
  safe_yaml (~> 1.0.0)
15
14
  diff-lcs (1.3)
16
15
  hashdiff (0.3.8)
17
- jaro_winkler (1.5.2)
18
- jwt (2.1.0)
19
- parallel (1.14.0)
20
- parser (2.6.0.0)
21
- ast (~> 2.4.0)
22
- powerpack (0.1.2)
23
- psych (3.1.0)
16
+ jaro_winkler (1.5.4)
17
+ jwt (2.2.2)
18
+ parallel (1.19.2)
19
+ parser (2.7.2.0)
20
+ ast (~> 2.4.1)
24
21
  public_suffix (3.0.3)
25
22
  rainbow (3.0.0)
26
- rake (10.5.0)
23
+ rake (13.0.1)
27
24
  rspec (3.8.0)
28
25
  rspec-core (~> 3.8.0)
29
26
  rspec-expectations (~> 3.8.0)
@@ -37,21 +34,21 @@ GEM
37
34
  diff-lcs (>= 1.2.0, < 2.0)
38
35
  rspec-support (~> 3.8.0)
39
36
  rspec-support (3.8.0)
40
- rubocop (0.65.0)
37
+ rubocop (0.79.0)
41
38
  jaro_winkler (~> 1.5.1)
42
39
  parallel (~> 1.10)
43
- parser (>= 2.5, != 2.5.1.1)
44
- powerpack (~> 0.1)
45
- psych (>= 3.1.0)
40
+ parser (>= 2.7.0.1)
46
41
  rainbow (>= 2.2.2, < 4.0)
47
42
  ruby-progressbar (~> 1.7)
48
- unicode-display_width (~> 1.4.0)
49
- rubocop-rspec (1.32.0)
50
- rubocop (>= 0.60.0)
51
- ruby-progressbar (1.10.0)
43
+ unicode-display_width (>= 1.4.0, < 1.7)
44
+ rubocop-performance (1.6.1)
45
+ rubocop (>= 0.71.0)
46
+ rubocop-rspec (1.41.0)
47
+ rubocop (>= 0.68.1)
48
+ ruby-progressbar (1.10.1)
52
49
  safe_yaml (1.0.5)
53
50
  timecop (0.9.1)
54
- unicode-display_width (1.4.1)
51
+ unicode-display_width (1.6.1)
55
52
  webmock (2.3.2)
56
53
  addressable (>= 2.3.6)
57
54
  crack (>= 0.3.2)
@@ -62,13 +59,15 @@ PLATFORMS
62
59
 
63
60
  DEPENDENCIES
64
61
  bundler (~> 1.16)
65
- rake (~> 10.0)
62
+ jwt (>= 1.0)
63
+ rake (~> 13.0)
66
64
  rspec (~> 3.0)
67
- rubocop (~> 0.65.0)
68
- rubocop-rspec (~> 1.32.0)
65
+ rubocop (~> 0.79.0)
66
+ rubocop-performance (~> 1.6.1)
67
+ rubocop-rspec (~> 1.41.0)
69
68
  tikkie-api!
70
69
  timecop (~> 0.9)
71
70
  webmock (~> 2.3)
72
71
 
73
72
  BUNDLED WITH
74
- 1.17.2
73
+ 1.17.3
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Peter Postma
3
+ Copyright (c) 2018-2020 Kentaa BV
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,14 +4,41 @@
4
4
  [![Build Status](https://travis-ci.org/KentaaNL/tikkie-api.svg?branch=master)](https://travis-ci.org/KentaaNL/tikkie-api)
5
5
  [![Code Climate](https://codeclimate.com/github/KentaaNL/tikkie-api/badges/gpa.svg)](https://codeclimate.com/github/KentaaNL/tikkie-api)
6
6
 
7
- Unofficial Ruby library for communicating with the [Tikkie API](https://developer.abnamro.com/content/tikkie).
7
+ Unofficial Ruby library for communicating with the [Tikkie API](https://developer.abnamro.com/api-products/tikkie).
8
+
9
+ ## Table of Contents
10
+
11
+ - [Installation](#installation)
12
+ - [Usage](#usage)
13
+ - [Payment requests](#payment-requests)
14
+ - [Create a Payment request](#create-a-payment-request)
15
+ - [List Payment requests](#list-payment-requests)
16
+ - [Get Payment request](#get-payment-request)
17
+ - [Payments](#payments)
18
+ - [List Payments](#list-payments)
19
+ - [Get Payment](#get-payment)
20
+ - [Refunds](#refunds)
21
+ - [Create a Refund](#create-a-refund)
22
+ - [Get Refund](#get-refund)
23
+ - [Payment requests notification](#payment-requests-notification)
24
+ - [Create a subscription](#create-a-subscription)
25
+ - [Delete subscription](#delete-subscription)
26
+ - [Sandbox apps](#sandbox-apps)
27
+ - [Create a Sandbox app](#create-a-sandbox-app)
28
+ - [Error handling](#error-handling)
29
+ - [Notifications](#notifications)
30
+ - [API support](#api-support)
31
+ - [Development](#development)
32
+ - [Contributing](#contributing)
33
+ - [License](#license)
34
+
8
35
 
9
36
  ## Installation
10
37
 
11
38
  Add this line to your application's Gemfile:
12
39
 
13
40
  ```ruby
14
- gem 'tikkie-api'
41
+ gem 'tikkie-api', '~> 2.0'
15
42
  ```
16
43
 
17
44
  And then execute:
@@ -24,138 +51,240 @@ Or install it yourself as:
24
51
 
25
52
  ## Usage
26
53
 
27
- ### Preparation
54
+ Create a Tikkie client using your API key and an App token. If you don't have an App token yet, please read the [documentation about App tokens](https://developer.abnamro.com/api-products/tikkie/reference-documentation#section/Overview/App-token) or use the [Sandbox apps endpoint](#sandbox-apps) to create an App token in the sandbox environment.
28
55
 
29
- This library uses a JSON Web Token (JWT) as authentication method. You need to create a public/private key pair to sign the tokens.
30
- See the [developer documentation from ABN AMRO](https://developer.abnamro.com/get-started#authentication) to get started.
56
+ ```ruby
57
+ require 'tikkie/api'
58
+
59
+ client = Tikkie::Api::Client.new(api_key: "12345", app_token: "abcdef")
60
+ ```
61
+
62
+ The client is created for the production environment by default. If you want to use the sandbox environment, then add `sandbox: true`:
63
+
64
+ ```ruby
65
+ client = Tikkie::Api::Client.new(api_key: "12345", app_token: "abcdef", sandbox: true)
66
+ ```
31
67
 
32
- Make sure you have created an App in the developers portal with the Tikkie API product enabled. This App contains a Consumer Key (this is your API key), which you will need next.
68
+ ### Payment requests
33
69
 
34
- ### Initialization
70
+ #### Create a Payment request
35
71
 
36
- First create a Tikkie configuration and specify the API key of your App and the path to your private RSA key. Then use the configuration to initialize a Tikkie client:
72
+ Creates a new payment request. When the parameter `amount` is omitted, it will create a payment request with an open amount, where the payer can decide on the amount.
37
73
 
38
74
  ```ruby
39
- require 'tikkie/api'
75
+ payment_request = client.payment_requests.create(
76
+ description: "Test", # mandatory
77
+ amount: "12.50",
78
+ expiry_date: "2021-01-01",
79
+ reference_id: "Invoice 12345"
80
+ )
40
81
 
41
- config = Tikkie::Api::Configuration.new("your_api_key", "private_rsa.pem")
42
- client = Tikkie::Api::Client.new(config)
82
+ payment_request.payment_request_token # => "qzdnzr8hnVWTgXXcFRLUMc"
83
+ payment_request.url # => "https://tikkie.me/pay/Tikkie/qzdnzr8hnVWTgXXcFRLUMc"
84
+ payment_request.amount # => BigDecimal("12.50")
43
85
  ```
44
86
 
45
- The configuration is created for the production environment by default. If you want to use the sandbox testing environment, then add the option `test: true` when creating the configuration:
87
+ See [Tikkie::Api::Resources::PaymentRequest](lib/tikkie/api/resources/payment_request.rb) for all available properties.
88
+
89
+ #### List Payment requests
90
+
91
+ Retrieves all payment requests.
46
92
 
47
93
  ```ruby
48
- config = Tikkie::Api::Configuration.new("your_api_key", "private_rsa.pem", test: true)
94
+ payment_requests = client.payment_requests.list
49
95
  ```
50
96
 
51
- ### Platforms
97
+ The payments requests response is paginated. You can iterate through the pages using `payment_requests.next` and checking the result:
52
98
 
53
- Retrieve all platforms:
99
+ ```ruby
100
+ payment_requests = client.payment_requests.list
101
+
102
+ loop do
103
+ # Do something with payment requests
104
+
105
+ payment_requests = payment_requests.next
106
+ break if payment_requests.nil?
107
+ end
108
+ ```
109
+
110
+ See [Tikkie::Api::Resources::PaymentRequests](lib/tikkie/api/resources/payment_requests.rb) for all available properties.
111
+
112
+ #### Get Payment request
113
+
114
+ Retrieve details of a specific payment request.
54
115
 
55
116
  ```ruby
56
- platforms = client.platforms.list
117
+ payment_request = client.payment_requests.get("payment_request_token")
118
+
119
+ payment_request.payment_request_token # => "qzdnzr8hnVWTgXXcFRLUMc"
120
+ payment_request.url # => "https://tikkie.me/pay/Tikkie/qzdnzr8hnVWTgXXcFRLUMc"
121
+ payment_request.amount # => BigDecimal("12.50")
122
+ payment_request.payments # => Tikkie::Api::Resources::Payments
57
123
  ```
58
124
 
59
- Create a new platform:
125
+ See [Tikkie::Api::Resources::PaymentRequest](lib/tikkie/api/resources/payment_request.rb) for all available properties.
126
+
127
+
128
+ ### Payments
129
+
130
+ #### List Payments
131
+
132
+ Retrieves all payments for a specific payment request.
60
133
 
61
134
  ```ruby
62
- platform = client.platforms.create(
63
- name: "Kentaa",
64
- phone_number: "0601234567",
65
- platform_usage: Tikkie::Api::Types::PlatformUsage::FOR_MYSELF,
66
- email: "info@kentaa.nl", # optional
67
- notification_url: "https://kentaa.nl/tikkie" # optional
68
- )
135
+ payments = client.payments.list("payment_request_token")
136
+ ```
69
137
 
70
- platform_token = platform.platform_token
138
+ The payments requests response is paginated. You can iterate through the pages using `payments.next` and checking the result:
139
+
140
+ ```ruby
141
+ payments = client.payments.list("qzdnzr8hnVWTgXXcFRLUMc")
142
+
143
+ loop do
144
+ # Do something with payments
145
+
146
+ payments = payments.next
147
+ break if payments.nil?
148
+ end
71
149
  ```
72
150
 
73
- ### Users
151
+ See [Tikkie::Api::Resources::Payments](lib/tikkie/api/resources/payments.rb) for all available properties.
152
+
153
+ #### Get Payment
74
154
 
75
- Retrieve all users for a platform:
155
+ Retrieves details of specific payment based on the token value.
76
156
 
77
157
  ```ruby
78
- users = client.users.list("platform_token")
158
+ payment = client.payments.get("payment_request_token", "payment_token")
159
+
160
+ payment.payment_token # => "21ef7413-cc3c-4c80-9272-6710fada28e4"
161
+ payment.amount # => BigDecimal("12.50")
162
+ payment.description # => "Test"
163
+ payment.refunds # => Array[Tikkie::Api::Resources::Refund]
79
164
  ```
80
165
 
81
- Create a new user for a platform:
166
+ See [Tikkie::Api::Resources::Payment](lib/tikkie/api/resources/payment.rb) for all available properties.
167
+
168
+ ### Refunds
169
+
170
+ #### Create a Refund
171
+
172
+ Creates a refund for a specific payment.
82
173
 
83
174
  ```ruby
84
- user = client.users.create("platform_token",
85
- name: "Kentaa",
86
- phone_number: "0601234567",
87
- iban: "NL02ABNA0123456789",
88
- bank_account_label: "Personal account"
175
+ refund = client.refunds.create("payment_request_token", "payment_token",
176
+ description: "Test", # mandatory
177
+ amount: "10.00", # mandatory
178
+ reference_id: "Invoice 12345"
89
179
  )
90
180
 
91
- user_token = user.user_token
92
- bank_account_token = user.bank_accounts.first.bank_account_token
181
+ refund.refund_token # => "abcdzr8hnVWTgXXcFRLUMc"
182
+ refund.amount # => BigDecimal("10.00")
183
+ refund.paid? # => true
93
184
  ```
94
185
 
95
- ### Payment requests
186
+ See [Tikkie::Api::Resources::Refund](lib/tikkie/api/resources/refund.rb) for all available properties.
187
+
188
+ #### Get Refund
96
189
 
97
- Retrieve all payment requests for a user on a platform:
190
+ Retrieves details of a specific refund based on the token value.
98
191
 
99
192
  ```ruby
100
- payment_requests = client.payment_requests.list("platform_token", "user_token")
193
+ refund = client.refunds.get("payment_request_token", "payment_token", "refund_token")
194
+
195
+ refund.refund_token # => "abcdzr8hnVWTgXXcFRLUMc"
196
+ refund.amount # => BigDecimal("10.00")
197
+ refund.paid? # => true
101
198
  ```
102
199
 
103
- The payments requests response is paginated. You can use the method `more_elements?` to determine if there's more data to retrieve. In the next request, set the `offset` parameter to the new offset using the method `next_offset` from the previous response. For example:
200
+ See [Tikkie::Api::Resources::Refund](lib/tikkie/api/resources/refund.rb) for all available properties.
201
+
202
+ ### Payment requests notification
203
+
204
+ See [Notifications](#notifications) for information about parsing the callbacks.
205
+
206
+ #### Create a subscription
207
+
208
+ Subscribes to payment request related notifications.
104
209
 
105
210
  ```ruby
106
- options = {}
211
+ subscription = client.payment_requests_subscription.create(url: "https://www.example.com/notification")
107
212
 
108
- loop do
109
- payment_requests = client.payment_requests.list("platform_token", "user_token", options)
213
+ subscription.subscription_id # => "e0111835-e8df-4070-874a-f12cf3f77e39"
214
+ ```
110
215
 
111
- # Do something with payment requests
216
+ See [Tikkie::Api::Resources::PaymentRequestsSubscription](lib/tikkie/api/resources/payment_requests_subscription.rb) for all available properties.
112
217
 
113
- break unless payment_requests.more_elements?
218
+ #### Delete subscription
114
219
 
115
- options[:offset] = payment_requests.next_offset
116
- end
220
+ Deletes the current subscription.
221
+
222
+ ```ruby
223
+ client.payment_requests_subscription.delete
117
224
  ```
118
225
 
119
- To retrieve a single payment request:
226
+ ### Sandbox apps
227
+
228
+ A sandbox app is used to make API requests in the sandbox environment.
229
+
230
+ You must initialize the Tikkie client by omitting the App token and adding the option `sandbox: true`:
120
231
 
121
232
  ```ruby
122
- payment_request = client.payment_requests.get("platform_token", "user_token", "payment_request_token")
233
+ client = Tikkie::Api::Client.new(api_key: "12345", sandbox: true)
123
234
  ```
124
235
 
125
- Create a new payment request (i.e. Tikkie) for an existing user:
236
+ #### Create a Sandbox app
237
+
238
+ Creates an app in the sandbox. The returned `app_token` should be used for all other API operations.
126
239
 
127
240
  ```ruby
128
- payment_request = client.payment_requests.create("platform_token", "user_token", "bank_account_token",
129
- amount: "5.00", # optional
130
- currency: "EUR",
131
- description: "Test",
132
- external_id: "Invoice 12345" # mandatory only when platform_usage is set to `FOR_MYSELF`
133
- )
241
+ sandbox_app = client.sandbox_apps.create
134
242
 
135
- tikkie_url = payment_request.payment_request_url
136
- payment_request_token = payment_request.payment_request_token
243
+ sandbox_app.app_token # => "935059a6-58b3-4f8d-a021-7bdda0d8d6ad"
137
244
  ```
138
245
 
139
- The parameter `amount` is optional. When omitted, it will create a payment request with an open amount, where the payer can decide on the amount.
246
+ See [Tikkie::Api::Resources::SandboxApp](lib/tikkie/api/resources/sandbox_app.rb) for all available properties.
140
247
 
141
- ### Error handling
248
+ ## Error handling
142
249
 
143
- All responses to an API request include the methods `success?` and `error?` to determine whether the API call was successful or not. When the API request was not successful, the method `errors` will return details about the error response.
250
+ All responses that are not HTTP status 20x will result in a [Tikkie::Api::RequestError](lib/tikkie/api/exception.rb).
144
251
 
145
252
  ```ruby
146
- payment_request = client.payment_requests.create("platform_token", "user_token", "bank_account_token", ...)
253
+ begin
254
+ client.payment_requests.get("invalid")
255
+ rescue Tikkie::Api::RequestError => e
256
+ e.http_code # => 404
257
+ e.http_message # => Not Found
258
+ e.errors # => Array[Tikkie::Api::Resources::Error]
259
+ e.messages # => "No payment request was found for the specified paymentRequestToken."
260
+ end
261
+ ```
147
262
 
148
- if payment_request.success?
149
- # Success handling...
263
+ ## Notifications
150
264
 
151
- redirect_to payment_request.payment_request_url
152
- else
153
- # Error handling...
265
+ When subscribed to notifications, you can use `Tikkie::Notification.parse` to parse the payload of a callback.
154
266
 
155
- puts payment_request.errors.inspect
156
- end
267
+ ```ruby
268
+ require 'tikkie/notification'
269
+
270
+ notification = Tikkie::Notification.parse(request.raw_post)
271
+
272
+ notification # => Tikkie::Notifications::PaymentNotification
273
+ notification.subscription_id # => "e0111835-e8df-4070-874a-f12cf3f77e39"
274
+ notification.notification_type # => "PAYMENT"
275
+ notification.payment_request_token # => "qzdnzr8hnVWTgXXcFRLUMc"
276
+ notification.payment_token # => "21ef7413-cc3c-4c80-9272-6710fada28e4"
157
277
  ```
158
278
 
279
+ See [Tikkie::Notifications](lib/tikkie/notifications/) for all types of notifications.
280
+
281
+ ## API support
282
+
283
+ This gem supports [Tikkie API (v2)](https://developer.abnamro.com/api-products/tikkie) as of release 2.0.0.
284
+
285
+ The deprecated [Tikkie Payment Request API (v1)](https://developer.abnamro.com/api-products/tikkie-payment-request) is currently namespaced under [Tikkie::Api::V1](lib/tikkie/api/v1/) to allow migration to Tikkie v2. This code is not supported anymore and will be removed in a future release of this gem.
286
+ To use the Tikkie v1 code, make sure to include the [jwt gem](https://rubygems.org/gems/jwt) in your code.
287
+
159
288
  ## Development
160
289
 
161
290
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.