paystack-gateway 0.1.1 → 0.2.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -2
  3. data/CHANGELOG.md +57 -0
  4. data/README.md +81 -102
  5. data/lib/paystack_gateway/api_error.rb +3 -1
  6. data/lib/paystack_gateway/apple_pay.rb +92 -0
  7. data/lib/paystack_gateway/balance.rb +62 -0
  8. data/lib/paystack_gateway/bank.rb +181 -0
  9. data/lib/paystack_gateway/bulk_charge.rb +197 -0
  10. data/lib/paystack_gateway/charge.rb +346 -0
  11. data/lib/paystack_gateway/configuration.rb +13 -2
  12. data/lib/paystack_gateway/customer.rb +498 -0
  13. data/lib/paystack_gateway/customers.rb +1 -42
  14. data/lib/paystack_gateway/dedicated_virtual_account.rb +353 -0
  15. data/lib/paystack_gateway/dedicated_virtual_accounts.rb +1 -64
  16. data/lib/paystack_gateway/direct_debit.rb +64 -0
  17. data/lib/paystack_gateway/dispute.rb +380 -0
  18. data/lib/paystack_gateway/extensions/customer_extensions.rb +14 -0
  19. data/lib/paystack_gateway/extensions/plan_extensions.rb +36 -0
  20. data/lib/paystack_gateway/extensions/refund_extensions.rb +43 -0
  21. data/lib/paystack_gateway/extensions/transaction_extensions.rb +40 -0
  22. data/lib/paystack_gateway/extensions/transaction_response_extension.rb +31 -0
  23. data/lib/paystack_gateway/extensions/transfer_extensions.rb +34 -0
  24. data/lib/paystack_gateway/integration.rb +60 -0
  25. data/lib/paystack_gateway/legacy/customers.rb +48 -0
  26. data/lib/paystack_gateway/legacy/dedicated_virtual_accounts.rb +70 -0
  27. data/lib/paystack_gateway/legacy/miscellaneous.rb +30 -0
  28. data/lib/paystack_gateway/legacy/plans.rb +86 -0
  29. data/lib/paystack_gateway/legacy/refunds.rb +65 -0
  30. data/lib/paystack_gateway/legacy/subaccounts.rb +41 -0
  31. data/lib/paystack_gateway/legacy/transaction_response.rb +37 -0
  32. data/lib/paystack_gateway/legacy/transactions.rb +91 -0
  33. data/lib/paystack_gateway/legacy/transfer_recipients.rb +27 -0
  34. data/lib/paystack_gateway/legacy/transfers.rb +63 -0
  35. data/lib/paystack_gateway/legacy/verification.rb +37 -0
  36. data/lib/paystack_gateway/miscellaneous.rb +75 -13
  37. data/lib/paystack_gateway/order.rb +259 -0
  38. data/lib/paystack_gateway/page.rb +317 -0
  39. data/lib/paystack_gateway/payment_request.rb +454 -0
  40. data/lib/paystack_gateway/plan.rb +247 -0
  41. data/lib/paystack_gateway/plans.rb +1 -80
  42. data/lib/paystack_gateway/product.rb +303 -0
  43. data/lib/paystack_gateway/refund.rb +197 -0
  44. data/lib/paystack_gateway/refunds.rb +1 -59
  45. data/lib/paystack_gateway/request_module.rb +12 -11
  46. data/lib/paystack_gateway/settlement.rb +60 -0
  47. data/lib/paystack_gateway/split.rb +286 -0
  48. data/lib/paystack_gateway/storefront.rb +329 -0
  49. data/lib/paystack_gateway/subaccount.rb +263 -0
  50. data/lib/paystack_gateway/subaccounts.rb +1 -35
  51. data/lib/paystack_gateway/subscription.rb +256 -0
  52. data/lib/paystack_gateway/terminal.rb +236 -0
  53. data/lib/paystack_gateway/transaction.rb +592 -0
  54. data/lib/paystack_gateway/transaction_response.rb +1 -33
  55. data/lib/paystack_gateway/transactions.rb +1 -86
  56. data/lib/paystack_gateway/transfer.rb +410 -0
  57. data/lib/paystack_gateway/transfer_recipient.rb +237 -0
  58. data/lib/paystack_gateway/transfer_recipients.rb +1 -21
  59. data/lib/paystack_gateway/transfers.rb +1 -57
  60. data/lib/paystack_gateway/verification.rb +1 -31
  61. data/lib/paystack_gateway/version.rb +1 -1
  62. data/lib/paystack_gateway/virtual_terminal.rb +297 -0
  63. data/lib/paystack_gateway.rb +50 -18
  64. metadata +50 -7
@@ -0,0 +1,236 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PaystackGateway
4
+ # https://paystack.com/docs/api/terminal
5
+ #
6
+ # Terminal
7
+ # A collection of endpoints for building delightful in-person payment experiences
8
+ module Terminal
9
+ include PaystackGateway::RequestModule
10
+
11
+ # Successful response from calling #send_event.
12
+ class SendEventResponse < PaystackGateway::Response; end
13
+
14
+ # Error response from #send_event.
15
+ class SendEventError < ApiError; end
16
+
17
+ # https://paystack.com/docs/api/terminal/#send_event
18
+ # Send Event: POST /terminal/{id}/event
19
+ # Send an event from your application to the Paystack Terminal
20
+ #
21
+ # @param id [String] (required)
22
+ # The ID of the Terminal the event should be sent to.
23
+ # @param type ["invoice", "transaction"]
24
+ # The type of event to push
25
+ # @param action ["process", "view", "print"]
26
+ # The action the Terminal needs to perform. For the invoice type, the action can either
27
+ # be process or view. For the transaction type, the action can either be process or
28
+ # print.
29
+ # @param data [Hash]
30
+ # The parameters needed to perform the specified action
31
+ # @option data [Integer] :id
32
+ # The invoice or transaction ID you want to push to the Terminal
33
+ # @option data [String] :reference
34
+ # The offline_reference from the Payment Request response
35
+ #
36
+ # @return [SendEventResponse] successful response
37
+ # @raise [SendEventError] if the request fails
38
+ api_method def self.send_event(id:, type: nil, action: nil, data: nil)
39
+ use_connection do |connection|
40
+ connection.post(
41
+ "/terminal/#{id}/event",
42
+ { type:, action:, data: }.compact,
43
+ )
44
+ end
45
+ end
46
+
47
+ # Successful response from calling #fetch_event_status.
48
+ class FetchEventStatusResponse < PaystackGateway::Response; end
49
+
50
+ # Error response from #fetch_event_status.
51
+ class FetchEventStatusError < ApiError; end
52
+
53
+ # https://paystack.com/docs/api/terminal/#fetch_event_status
54
+ # Fetch Event Status: GET /terminal/{terminal_id}/event/{event_id}
55
+ # Check the status of an event sent to the Terminal
56
+ #
57
+ # @param terminal_id [String] (required)
58
+ # The ID of the Terminal the event should be sent to.
59
+ # @param event_id [String] (required)
60
+ # The ID of the event that was sent to the Terminal
61
+ #
62
+ # @return [FetchEventStatusResponse] successful response
63
+ # @raise [FetchEventStatusError] if the request fails
64
+ api_method def self.fetch_event_status(terminal_id:, event_id:)
65
+ use_connection do |connection|
66
+ connection.get(
67
+ "/terminal/#{terminal_id}/event/#{event_id}",
68
+ )
69
+ end
70
+ end
71
+
72
+ # Successful response from calling #fetch_terminal_status.
73
+ class FetchTerminalStatusResponse < PaystackGateway::Response
74
+ delegate :online, :available, to: :data
75
+ end
76
+
77
+ # Error response from #fetch_terminal_status.
78
+ class FetchTerminalStatusError < ApiError; end
79
+
80
+ # https://paystack.com/docs/api/terminal/#fetch_terminal_status
81
+ # Fetch Terminal Status: GET /terminal/{terminal_id}/presence
82
+ # Check the availiability of a Terminal before sending an event to it
83
+ #
84
+ # @param terminal_id [String] (required)
85
+ # The ID of the Terminal the event should be sent to.
86
+ #
87
+ # @return [FetchTerminalStatusResponse] successful response
88
+ # @raise [FetchTerminalStatusError] if the request fails
89
+ api_method def self.fetch_terminal_status(terminal_id:)
90
+ use_connection do |connection|
91
+ connection.get(
92
+ "/terminal/#{terminal_id}/presence",
93
+ )
94
+ end
95
+ end
96
+
97
+ # Successful response from calling #list.
98
+ class ListResponse < PaystackGateway::Response; end
99
+
100
+ # Error response from #list.
101
+ class ListError < ApiError; end
102
+
103
+ # https://paystack.com/docs/api/terminal/#list
104
+ # List Terminals: GET /terminal
105
+ # List the Terminals available on your integration
106
+ #
107
+ # @param next [String]
108
+ # A cursor that indicates your place in the list. It can be used to fetch the next
109
+ # page of the list
110
+ # @param previous [String]
111
+ # A cursor that indicates your place in the list. It should be used to fetch the previous
112
+ # page of the list after an intial next request
113
+ # @param per_page [Integer]
114
+ # Specify how many records you want to retrieve per page
115
+ #
116
+ # @return [ListResponse] successful response
117
+ # @raise [ListError] if the request fails
118
+ api_method def self.list(next: nil, previous: nil, per_page: nil)
119
+ use_connection do |connection|
120
+ connection.get(
121
+ '/terminal',
122
+ { next:, previous:, per_page: }.compact,
123
+ )
124
+ end
125
+ end
126
+
127
+ # Successful response from calling #fetch.
128
+ class FetchResponse < PaystackGateway::Response
129
+ delegate :id,
130
+ :serial_number,
131
+ :device_make,
132
+ :terminal_id,
133
+ :integration,
134
+ :domain,
135
+ :name,
136
+ :address,
137
+ :split_code, to: :data
138
+ end
139
+
140
+ # Error response from #fetch.
141
+ class FetchError < ApiError; end
142
+
143
+ # https://paystack.com/docs/api/terminal/#fetch
144
+ # Fetch Terminal: GET /terminal/{terminal_id}
145
+ # Get the details of a Terminal
146
+ #
147
+ # @param terminal_id [String] (required)
148
+ # The ID of the Terminal the event should be sent to.
149
+ #
150
+ # @return [FetchResponse] successful response
151
+ # @raise [FetchError] if the request fails
152
+ api_method def self.fetch(terminal_id:)
153
+ use_connection do |connection|
154
+ connection.get(
155
+ "/terminal/#{terminal_id}",
156
+ )
157
+ end
158
+ end
159
+
160
+ # Successful response from calling #update.
161
+ class UpdateResponse < PaystackGateway::Response; end
162
+
163
+ # Error response from #update.
164
+ class UpdateError < ApiError; end
165
+
166
+ # https://paystack.com/docs/api/terminal/#update
167
+ # Update Terminal: PUT /terminal/{terminal_id}
168
+ # Update the details of a Terminal
169
+ #
170
+ # @param terminal_id [String] (required)
171
+ # The ID of the Terminal the event should be sent to.
172
+ # @param name [String]
173
+ # The new name for the Terminal
174
+ # @param address [String]
175
+ # The new address for the Terminal
176
+ #
177
+ # @return [UpdateResponse] successful response
178
+ # @raise [UpdateError] if the request fails
179
+ api_method def self.update(terminal_id:, name: nil, address: nil)
180
+ use_connection do |connection|
181
+ connection.put(
182
+ "/terminal/#{terminal_id}",
183
+ { name:, address: }.compact,
184
+ )
185
+ end
186
+ end
187
+
188
+ # Successful response from calling #commission.
189
+ class CommissionResponse < PaystackGateway::Response; end
190
+
191
+ # Error response from #commission.
192
+ class CommissionError < ApiError; end
193
+
194
+ # https://paystack.com/docs/api/terminal/#commission
195
+ # Commission Terminal: POST /terminal/commission_device
196
+ # Activate your debug device by linking it to your integration
197
+ #
198
+ # @param serial_number [String] (required)
199
+ # Device Serial Number
200
+ #
201
+ # @return [CommissionResponse] successful response
202
+ # @raise [CommissionError] if the request fails
203
+ api_method def self.commission(serial_number:)
204
+ use_connection do |connection|
205
+ connection.post(
206
+ '/terminal/commission_device',
207
+ { serial_number: }.compact,
208
+ )
209
+ end
210
+ end
211
+
212
+ # Successful response from calling #decommission.
213
+ class DecommissionResponse < PaystackGateway::Response; end
214
+
215
+ # Error response from #decommission.
216
+ class DecommissionError < ApiError; end
217
+
218
+ # https://paystack.com/docs/api/terminal/#decommission
219
+ # Decommission Terminal: POST /terminal/decommission_device
220
+ # Unlink your debug device from your integration
221
+ #
222
+ # @param serial_number [String] (required)
223
+ # Device Serial Number
224
+ #
225
+ # @return [DecommissionResponse] successful response
226
+ # @raise [DecommissionError] if the request fails
227
+ api_method def self.decommission(serial_number:)
228
+ use_connection do |connection|
229
+ connection.post(
230
+ '/terminal/decommission_device',
231
+ { serial_number: }.compact,
232
+ )
233
+ end
234
+ end
235
+ end
236
+ end