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.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -2
- data/CHANGELOG.md +57 -0
- data/README.md +81 -102
- data/lib/paystack_gateway/api_error.rb +3 -1
- data/lib/paystack_gateway/apple_pay.rb +92 -0
- data/lib/paystack_gateway/balance.rb +62 -0
- data/lib/paystack_gateway/bank.rb +181 -0
- data/lib/paystack_gateway/bulk_charge.rb +197 -0
- data/lib/paystack_gateway/charge.rb +346 -0
- data/lib/paystack_gateway/configuration.rb +13 -2
- data/lib/paystack_gateway/customer.rb +498 -0
- data/lib/paystack_gateway/customers.rb +1 -42
- data/lib/paystack_gateway/dedicated_virtual_account.rb +353 -0
- data/lib/paystack_gateway/dedicated_virtual_accounts.rb +1 -64
- data/lib/paystack_gateway/direct_debit.rb +64 -0
- data/lib/paystack_gateway/dispute.rb +380 -0
- data/lib/paystack_gateway/extensions/customer_extensions.rb +14 -0
- data/lib/paystack_gateway/extensions/plan_extensions.rb +36 -0
- data/lib/paystack_gateway/extensions/refund_extensions.rb +43 -0
- data/lib/paystack_gateway/extensions/transaction_extensions.rb +40 -0
- data/lib/paystack_gateway/extensions/transaction_response_extension.rb +31 -0
- data/lib/paystack_gateway/extensions/transfer_extensions.rb +34 -0
- data/lib/paystack_gateway/integration.rb +60 -0
- data/lib/paystack_gateway/legacy/customers.rb +48 -0
- data/lib/paystack_gateway/legacy/dedicated_virtual_accounts.rb +70 -0
- data/lib/paystack_gateway/legacy/miscellaneous.rb +30 -0
- data/lib/paystack_gateway/legacy/plans.rb +86 -0
- data/lib/paystack_gateway/legacy/refunds.rb +65 -0
- data/lib/paystack_gateway/legacy/subaccounts.rb +41 -0
- data/lib/paystack_gateway/legacy/transaction_response.rb +37 -0
- data/lib/paystack_gateway/legacy/transactions.rb +91 -0
- data/lib/paystack_gateway/legacy/transfer_recipients.rb +27 -0
- data/lib/paystack_gateway/legacy/transfers.rb +63 -0
- data/lib/paystack_gateway/legacy/verification.rb +37 -0
- data/lib/paystack_gateway/miscellaneous.rb +75 -13
- data/lib/paystack_gateway/order.rb +259 -0
- data/lib/paystack_gateway/page.rb +317 -0
- data/lib/paystack_gateway/payment_request.rb +454 -0
- data/lib/paystack_gateway/plan.rb +247 -0
- data/lib/paystack_gateway/plans.rb +1 -80
- data/lib/paystack_gateway/product.rb +303 -0
- data/lib/paystack_gateway/refund.rb +197 -0
- data/lib/paystack_gateway/refunds.rb +1 -59
- data/lib/paystack_gateway/request_module.rb +12 -11
- data/lib/paystack_gateway/settlement.rb +60 -0
- data/lib/paystack_gateway/split.rb +286 -0
- data/lib/paystack_gateway/storefront.rb +329 -0
- data/lib/paystack_gateway/subaccount.rb +263 -0
- data/lib/paystack_gateway/subaccounts.rb +1 -35
- data/lib/paystack_gateway/subscription.rb +256 -0
- data/lib/paystack_gateway/terminal.rb +236 -0
- data/lib/paystack_gateway/transaction.rb +592 -0
- data/lib/paystack_gateway/transaction_response.rb +1 -33
- data/lib/paystack_gateway/transactions.rb +1 -86
- data/lib/paystack_gateway/transfer.rb +410 -0
- data/lib/paystack_gateway/transfer_recipient.rb +237 -0
- data/lib/paystack_gateway/transfer_recipients.rb +1 -21
- data/lib/paystack_gateway/transfers.rb +1 -57
- data/lib/paystack_gateway/verification.rb +1 -31
- data/lib/paystack_gateway/version.rb +1 -1
- data/lib/paystack_gateway/virtual_terminal.rb +297 -0
- data/lib/paystack_gateway.rb +50 -18
- metadata +50 -7
|
@@ -1,88 +1,3 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
# Create and manage payments https://paystack.com/docs/api/#transaction
|
|
5
|
-
module Transactions
|
|
6
|
-
include PaystackGateway::RequestModule
|
|
7
|
-
|
|
8
|
-
# Response from POST /transaction/initialize endpoint.
|
|
9
|
-
class InitializeTransactionResponse < PaystackGateway::Response
|
|
10
|
-
delegate :authorization_url, to: :data
|
|
11
|
-
|
|
12
|
-
alias payment_url authorization_url
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Raised when an error occurs while calling POST /transaction/initialize
|
|
16
|
-
class InitializeTransactionError < ApiError
|
|
17
|
-
def cancellable? = super || network_error?
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Response looks like this.
|
|
21
|
-
# {
|
|
22
|
-
# "status": true,
|
|
23
|
-
# "message": "Authorization URL created",
|
|
24
|
-
# "data": {
|
|
25
|
-
# "authorization_url": "https://checkout.paystack.com/n4ysyedbuseog8c",
|
|
26
|
-
# "access_code": "n4ysyedbuseog8c",
|
|
27
|
-
# "reference": "hlr4bxhypt"
|
|
28
|
-
# }
|
|
29
|
-
# }
|
|
30
|
-
api_method def self.initialize_transaction(**transaction_data)
|
|
31
|
-
raise ApiError.new(:invalid_amount, cancellable: true) if transaction_data[:amount].blank?
|
|
32
|
-
raise ApiError.new(:invalid_reference, cancellable: true) if transaction_data[:reference].blank?
|
|
33
|
-
raise ApiError.new(:invalid_email, cancellable: true) if transaction_data[:email].blank?
|
|
34
|
-
|
|
35
|
-
transaction_data[:amount] = (transaction_data[:amount] * 100).to_i
|
|
36
|
-
|
|
37
|
-
use_connection do |connection|
|
|
38
|
-
connection.post('/transaction/initialize', transaction_data.compact)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Response from GET /transaction/verify/:reference endpoint.
|
|
43
|
-
class VerifyTransactionResponse < PaystackGateway::Response
|
|
44
|
-
include TransactionResponse
|
|
45
|
-
|
|
46
|
-
delegate :paid_at, to: :data
|
|
47
|
-
|
|
48
|
-
def transaction_completed_at
|
|
49
|
-
paid_at || super
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# Raised when an error occurs while calling /transactions/verify/:reference
|
|
54
|
-
class VerifyTransactionError < ApiError
|
|
55
|
-
def transaction_not_found?
|
|
56
|
-
return false if !response_body
|
|
57
|
-
|
|
58
|
-
response_body[:status] == false && response_body[:message].match?(/transaction reference not found/i)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
api_method def self.verify_transaction(reference:)
|
|
63
|
-
raise VerifyTransactionError, :invalid_reference if reference.blank?
|
|
64
|
-
|
|
65
|
-
use_connection do |connection|
|
|
66
|
-
connection.get("/transaction/verify/#{reference}")
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# Response from POST /transaction/charge_authorization endpoint.
|
|
71
|
-
class ChargeAuthorizationResponse < PaystackGateway::Response
|
|
72
|
-
include TransactionResponse
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
api_method def self.charge_authorization(**transaction_data)
|
|
76
|
-
raise ApiError.new(:invalid_amount, cancellable: true) if transaction_data[:amount].blank?
|
|
77
|
-
raise ApiError.new(:invalid_reference, cancellable: true) if transaction_data[:reference].blank?
|
|
78
|
-
raise ApiError.new(:invalid_authorization_code, cancellable: true) if transaction_data[:authorization_code].blank?
|
|
79
|
-
raise ApiError.new(:invalid_email, cancellable: true) if transaction_data[:email].blank?
|
|
80
|
-
|
|
81
|
-
transaction_data[:amount] = (transaction_data[:amount] * 100).to_i
|
|
82
|
-
|
|
83
|
-
use_connection do |connection|
|
|
84
|
-
connection.post('/transaction/charge_authorization', transaction_data.compact)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
3
|
+
require 'paystack_gateway/legacy/transactions'
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/transfer
|
|
5
|
+
#
|
|
6
|
+
# Transfers
|
|
7
|
+
# A collection of endpoints for automating sending money to beneficiaries
|
|
8
|
+
module Transfer
|
|
9
|
+
include PaystackGateway::RequestModule
|
|
10
|
+
|
|
11
|
+
# Successful response from calling #list.
|
|
12
|
+
class ListResponse < PaystackGateway::Response; end
|
|
13
|
+
|
|
14
|
+
# Error response from #list.
|
|
15
|
+
class ListError < ApiError; end
|
|
16
|
+
|
|
17
|
+
# https://paystack.com/docs/api/transfer/#list
|
|
18
|
+
# List Transfers: GET /transfer
|
|
19
|
+
# List the transfers made on your integration
|
|
20
|
+
#
|
|
21
|
+
# @param use_cursor [Boolean]
|
|
22
|
+
# A flag to indicate if cursor based pagination should be used
|
|
23
|
+
# @param next [String]
|
|
24
|
+
# An alphanumeric value returned for every cursor based retrieval, used to retrieve
|
|
25
|
+
# the next set of data
|
|
26
|
+
# @param previous [String]
|
|
27
|
+
# An alphanumeric value returned for every cursor based retrieval, used to retrieve
|
|
28
|
+
# the previous set of data
|
|
29
|
+
# @param per_page [Integer]
|
|
30
|
+
# The number of records to fetch per request
|
|
31
|
+
# @param page [Integer]
|
|
32
|
+
# The offset to retrieve data from
|
|
33
|
+
# @param from [Time]
|
|
34
|
+
# The start date
|
|
35
|
+
# @param to [Time]
|
|
36
|
+
# The end date
|
|
37
|
+
# @param recipient [String]
|
|
38
|
+
# Filter transfer by the recipient code
|
|
39
|
+
# @param status ["pending", "success", "failed", "otp", "abandoned", "reversed", "blocked", "rejected", "received"]
|
|
40
|
+
# Filter transfer by status
|
|
41
|
+
#
|
|
42
|
+
# @return [ListResponse] successful response
|
|
43
|
+
# @raise [ListError] if the request fails
|
|
44
|
+
api_method def self.list(
|
|
45
|
+
use_cursor: nil,
|
|
46
|
+
next: nil,
|
|
47
|
+
previous: nil,
|
|
48
|
+
per_page: nil,
|
|
49
|
+
page: nil,
|
|
50
|
+
from: nil,
|
|
51
|
+
to: nil,
|
|
52
|
+
recipient: nil,
|
|
53
|
+
status: nil
|
|
54
|
+
)
|
|
55
|
+
use_connection do |connection|
|
|
56
|
+
connection.get(
|
|
57
|
+
'/transfer',
|
|
58
|
+
{
|
|
59
|
+
use_cursor:,
|
|
60
|
+
next:,
|
|
61
|
+
previous:,
|
|
62
|
+
per_page:,
|
|
63
|
+
page:,
|
|
64
|
+
from:,
|
|
65
|
+
to:,
|
|
66
|
+
recipient:,
|
|
67
|
+
status:,
|
|
68
|
+
}.compact,
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Successful response from calling #initiate.
|
|
74
|
+
class InitiateResponse < PaystackGateway::Response
|
|
75
|
+
delegate :transfersessionid,
|
|
76
|
+
:transfertrials,
|
|
77
|
+
:domain,
|
|
78
|
+
:amount,
|
|
79
|
+
:currency,
|
|
80
|
+
:reference,
|
|
81
|
+
:source,
|
|
82
|
+
:source_details,
|
|
83
|
+
:reason,
|
|
84
|
+
:failures,
|
|
85
|
+
:transfer_code,
|
|
86
|
+
:titan_code,
|
|
87
|
+
:transferred_at,
|
|
88
|
+
:id,
|
|
89
|
+
:integration,
|
|
90
|
+
:request,
|
|
91
|
+
:recipient,
|
|
92
|
+
:createdAt,
|
|
93
|
+
:updatedAt, to: :data
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Error response from #initiate.
|
|
97
|
+
class InitiateError < ApiError; end
|
|
98
|
+
|
|
99
|
+
# https://paystack.com/docs/api/transfer/#initiate
|
|
100
|
+
# Initiate Transfer: POST /transfer
|
|
101
|
+
# Send money to your customers
|
|
102
|
+
#
|
|
103
|
+
# @param amount [Integer] (required)
|
|
104
|
+
# Amount to transfer in kobo if currency is NGN and pesewas if currency is GHS.
|
|
105
|
+
# @param recipient [String] (required)
|
|
106
|
+
# The transfer recipient's code
|
|
107
|
+
# @param reference [String] (required)
|
|
108
|
+
# To ensure idempotency, you need to provide e a unique identifier for the request.
|
|
109
|
+
# The identifier should be a lowercase alphanumeric string with only -,_ symbols allowed.
|
|
110
|
+
# @param source [String] (required)
|
|
111
|
+
# The source of funds to send from
|
|
112
|
+
# @param reason [String]
|
|
113
|
+
# The reason or narration for the transfer.
|
|
114
|
+
# @param currency ["NGN", "ZAR", "KES", "GHS"]
|
|
115
|
+
# Specify the currency of the transfer.
|
|
116
|
+
#
|
|
117
|
+
# @return [InitiateResponse] successful response
|
|
118
|
+
# @raise [InitiateError] if the request fails
|
|
119
|
+
api_method def self.initiate(
|
|
120
|
+
amount:,
|
|
121
|
+
recipient:,
|
|
122
|
+
reference:,
|
|
123
|
+
source:,
|
|
124
|
+
reason: nil,
|
|
125
|
+
currency: nil
|
|
126
|
+
)
|
|
127
|
+
use_connection do |connection|
|
|
128
|
+
connection.post(
|
|
129
|
+
'/transfer',
|
|
130
|
+
{
|
|
131
|
+
amount:,
|
|
132
|
+
recipient:,
|
|
133
|
+
reference:,
|
|
134
|
+
source:,
|
|
135
|
+
reason:,
|
|
136
|
+
currency:,
|
|
137
|
+
}.compact,
|
|
138
|
+
)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Successful response from calling #finalize.
|
|
143
|
+
class FinalizeResponse < PaystackGateway::Response; end
|
|
144
|
+
|
|
145
|
+
# Error response from #finalize.
|
|
146
|
+
class FinalizeError < ApiError; end
|
|
147
|
+
|
|
148
|
+
# https://paystack.com/docs/api/transfer/#finalize
|
|
149
|
+
# Finalize Transfer: POST /transfer/finalize_transfer
|
|
150
|
+
# Finalize an initiated transfer
|
|
151
|
+
#
|
|
152
|
+
# @param transfer_code [String] (required)
|
|
153
|
+
# The transfer code you want to finalize
|
|
154
|
+
# @param otp [String] (required)
|
|
155
|
+
# OTP sent to business phone to verify transfer
|
|
156
|
+
#
|
|
157
|
+
# @return [FinalizeResponse] successful response
|
|
158
|
+
# @raise [FinalizeError] if the request fails
|
|
159
|
+
api_method def self.finalize(transfer_code:, otp:)
|
|
160
|
+
use_connection do |connection|
|
|
161
|
+
connection.post(
|
|
162
|
+
'/transfer/finalize_transfer',
|
|
163
|
+
{ transfer_code:, otp: }.compact,
|
|
164
|
+
)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Successful response from calling #bulk.
|
|
169
|
+
class BulkResponse < PaystackGateway::Response; end
|
|
170
|
+
|
|
171
|
+
# Error response from #bulk.
|
|
172
|
+
class BulkError < ApiError; end
|
|
173
|
+
|
|
174
|
+
# https://paystack.com/docs/api/transfer/#bulk
|
|
175
|
+
# Initiate Bulk Transfer: POST /transfer/bulk
|
|
176
|
+
# Batch multiple transfers in a single request. You need to disable the Transfers
|
|
177
|
+
# OTP requirement to use this endpoint.
|
|
178
|
+
#
|
|
179
|
+
# @param source [String] (required)
|
|
180
|
+
# The source of funds for the transfer.
|
|
181
|
+
# @param transfers [Array<Hash>] (required)
|
|
182
|
+
# A list of transfer object
|
|
183
|
+
# @param currency ["NGN", "ZAR", "KES", "GHS"]
|
|
184
|
+
# Specify the currency of the transfer.
|
|
185
|
+
#
|
|
186
|
+
# @return [BulkResponse] successful response
|
|
187
|
+
# @raise [BulkError] if the request fails
|
|
188
|
+
api_method def self.bulk(source:, transfers:, currency: nil)
|
|
189
|
+
use_connection do |connection|
|
|
190
|
+
connection.post(
|
|
191
|
+
'/transfer/bulk',
|
|
192
|
+
{ source:, transfers:, currency: }.compact,
|
|
193
|
+
)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Successful response from calling #fetch.
|
|
198
|
+
class FetchResponse < PaystackGateway::Response
|
|
199
|
+
delegate :amount,
|
|
200
|
+
:createdAt,
|
|
201
|
+
:currency,
|
|
202
|
+
:domain,
|
|
203
|
+
:failures,
|
|
204
|
+
:id,
|
|
205
|
+
:integration,
|
|
206
|
+
:reason,
|
|
207
|
+
:reference,
|
|
208
|
+
:source,
|
|
209
|
+
:source_details,
|
|
210
|
+
:titan_code,
|
|
211
|
+
:transfer_code,
|
|
212
|
+
:request,
|
|
213
|
+
:transferred_at,
|
|
214
|
+
:updatedAt,
|
|
215
|
+
:recipient,
|
|
216
|
+
:session,
|
|
217
|
+
:fee_charged,
|
|
218
|
+
:fees_breakdown,
|
|
219
|
+
:gateway_response, to: :data
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Error response from #fetch.
|
|
223
|
+
class FetchError < ApiError; end
|
|
224
|
+
|
|
225
|
+
# https://paystack.com/docs/api/transfer/#fetch
|
|
226
|
+
# Fetch Transfer: GET /transfer/{code}
|
|
227
|
+
# Get details of a transfer on your integration
|
|
228
|
+
#
|
|
229
|
+
# @param code [String] (required)
|
|
230
|
+
# Transfer code
|
|
231
|
+
#
|
|
232
|
+
# @return [FetchResponse] successful response
|
|
233
|
+
# @raise [FetchError] if the request fails
|
|
234
|
+
api_method def self.fetch(code:)
|
|
235
|
+
use_connection do |connection|
|
|
236
|
+
connection.get(
|
|
237
|
+
"/transfer/#{code}",
|
|
238
|
+
)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Successful response from calling #verify.
|
|
243
|
+
class VerifyResponse < PaystackGateway::Response
|
|
244
|
+
delegate :amount,
|
|
245
|
+
:createdAt,
|
|
246
|
+
:currency,
|
|
247
|
+
:domain,
|
|
248
|
+
:failures,
|
|
249
|
+
:id,
|
|
250
|
+
:integration,
|
|
251
|
+
:reason,
|
|
252
|
+
:reference,
|
|
253
|
+
:source,
|
|
254
|
+
:source_details,
|
|
255
|
+
:titan_code,
|
|
256
|
+
:transfer_code,
|
|
257
|
+
:transferred_at,
|
|
258
|
+
:updatedAt,
|
|
259
|
+
:recipient,
|
|
260
|
+
:session,
|
|
261
|
+
:gateway_response, to: :data
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
# Error response from #verify.
|
|
265
|
+
class VerifyError < ApiError; end
|
|
266
|
+
|
|
267
|
+
# https://paystack.com/docs/api/transfer/#verify
|
|
268
|
+
# Verify Transfer: GET /transfer/verify/{reference}
|
|
269
|
+
# Verify the status of a transfer on your integration
|
|
270
|
+
#
|
|
271
|
+
# @param reference [String] (required)
|
|
272
|
+
# Transfer reference
|
|
273
|
+
#
|
|
274
|
+
# @return [VerifyResponse] successful response
|
|
275
|
+
# @raise [VerifyError] if the request fails
|
|
276
|
+
api_method def self.verify(reference:)
|
|
277
|
+
use_connection do |connection|
|
|
278
|
+
connection.get(
|
|
279
|
+
"/transfer/verify/#{reference}",
|
|
280
|
+
)
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Successful response from calling #export_transfer.
|
|
285
|
+
class ExportTransferResponse < PaystackGateway::Response; end
|
|
286
|
+
|
|
287
|
+
# Error response from #export_transfer.
|
|
288
|
+
class ExportTransferError < ApiError; end
|
|
289
|
+
|
|
290
|
+
# https://paystack.com/docs/api/transfer/#export_transfer
|
|
291
|
+
# Export Transfers: GET /transfer/export
|
|
292
|
+
# Export a list of transfers carried out on your integration
|
|
293
|
+
#
|
|
294
|
+
# @param recipient [String]
|
|
295
|
+
# Export transfer by the recipient code
|
|
296
|
+
# @param status ["pending", "success", "failed", "otp", "abandoned", "reversed", "blocked", "rejected", "received"]
|
|
297
|
+
# Export transfer by status
|
|
298
|
+
# @param from [Time]
|
|
299
|
+
# The start date
|
|
300
|
+
# @param to [Time]
|
|
301
|
+
# The end date
|
|
302
|
+
#
|
|
303
|
+
# @return [ExportTransferResponse] successful response
|
|
304
|
+
# @raise [ExportTransferError] if the request fails
|
|
305
|
+
api_method def self.export_transfer(recipient: nil, status: nil, from: nil, to: nil)
|
|
306
|
+
use_connection do |connection|
|
|
307
|
+
connection.get(
|
|
308
|
+
'/transfer/export',
|
|
309
|
+
{ recipient:, status:, from:, to: }.compact,
|
|
310
|
+
)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# Successful response from calling #resend_otp.
|
|
315
|
+
class ResendOtpResponse < PaystackGateway::Response; end
|
|
316
|
+
|
|
317
|
+
# Error response from #resend_otp.
|
|
318
|
+
class ResendOtpError < ApiError; end
|
|
319
|
+
|
|
320
|
+
# https://paystack.com/docs/api/transfer/#resend_otp
|
|
321
|
+
# Resend OTP for Transfer: POST /transfer/resend_otp
|
|
322
|
+
# Generates and send a new OTP to customer in the event they are having trouble receiving
|
|
323
|
+
# one.
|
|
324
|
+
#
|
|
325
|
+
# @param transfer_code [String] (required)
|
|
326
|
+
# The transfer code that requires an OTP validation
|
|
327
|
+
# @param reason ["disable_otp", "resend_otp", "transfer"] (required)
|
|
328
|
+
# Specify the flag to indicate the purpose of the OTP
|
|
329
|
+
#
|
|
330
|
+
# @return [ResendOtpResponse] successful response
|
|
331
|
+
# @raise [ResendOtpError] if the request fails
|
|
332
|
+
api_method def self.resend_otp(transfer_code:, reason:)
|
|
333
|
+
use_connection do |connection|
|
|
334
|
+
connection.post(
|
|
335
|
+
'/transfer/resend_otp',
|
|
336
|
+
{ transfer_code:, reason: }.compact,
|
|
337
|
+
)
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# Successful response from calling #disable_otp.
|
|
342
|
+
class DisableOtpResponse < PaystackGateway::Response; end
|
|
343
|
+
|
|
344
|
+
# Error response from #disable_otp.
|
|
345
|
+
class DisableOtpError < ApiError; end
|
|
346
|
+
|
|
347
|
+
# https://paystack.com/docs/api/transfer/#disable_otp
|
|
348
|
+
# Disable OTP for Transfers: POST /transfer/disable_otp
|
|
349
|
+
# This is used in the event that you want to be able to complete transfers programmatically
|
|
350
|
+
# without use of OTPs. No arguments required. You will get an OTP to complete the
|
|
351
|
+
# request.
|
|
352
|
+
#
|
|
353
|
+
#
|
|
354
|
+
# @return [DisableOtpResponse] successful response
|
|
355
|
+
# @raise [DisableOtpError] if the request fails
|
|
356
|
+
api_method def self.disable_otp
|
|
357
|
+
use_connection do |connection|
|
|
358
|
+
connection.post(
|
|
359
|
+
'/transfer/disable_otp',
|
|
360
|
+
)
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
# Successful response from calling #disable_otp_finalize.
|
|
365
|
+
class DisableOtpFinalizeResponse < PaystackGateway::Response; end
|
|
366
|
+
|
|
367
|
+
# Error response from #disable_otp_finalize.
|
|
368
|
+
class DisableOtpFinalizeError < ApiError; end
|
|
369
|
+
|
|
370
|
+
# https://paystack.com/docs/api/transfer/#disable_otp_finalize
|
|
371
|
+
# Finalize Disabling OTP for Transfers: POST /transfer/disable_otp_finalize
|
|
372
|
+
# Finalize the request to disable OTP on your transfers
|
|
373
|
+
#
|
|
374
|
+
# @param otp [String] (required)
|
|
375
|
+
# OTP sent to business phone to verify disabling OTP requirement
|
|
376
|
+
#
|
|
377
|
+
# @return [DisableOtpFinalizeResponse] successful response
|
|
378
|
+
# @raise [DisableOtpFinalizeError] if the request fails
|
|
379
|
+
api_method def self.disable_otp_finalize(otp:)
|
|
380
|
+
use_connection do |connection|
|
|
381
|
+
connection.post(
|
|
382
|
+
'/transfer/disable_otp_finalize',
|
|
383
|
+
{ otp: }.compact,
|
|
384
|
+
)
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# Successful response from calling #enable_otp.
|
|
389
|
+
class EnableOtpResponse < PaystackGateway::Response; end
|
|
390
|
+
|
|
391
|
+
# Error response from #enable_otp.
|
|
392
|
+
class EnableOtpError < ApiError; end
|
|
393
|
+
|
|
394
|
+
# https://paystack.com/docs/api/transfer/#enable_otp
|
|
395
|
+
# Enable OTP requirement for Transfers: POST /transfer/enable_otp
|
|
396
|
+
# In the event that a customer wants to stop being able to complete transfers programmatically,
|
|
397
|
+
# this endpoint helps turn OTP requirement back on. No arguments required.
|
|
398
|
+
#
|
|
399
|
+
#
|
|
400
|
+
# @return [EnableOtpResponse] successful response
|
|
401
|
+
# @raise [EnableOtpError] if the request fails
|
|
402
|
+
api_method def self.enable_otp
|
|
403
|
+
use_connection do |connection|
|
|
404
|
+
connection.post(
|
|
405
|
+
'/transfer/enable_otp',
|
|
406
|
+
)
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
end
|