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
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/bank
|
|
5
|
+
#
|
|
6
|
+
# Banks
|
|
7
|
+
# A collection of endpoints for managing bank details
|
|
8
|
+
module Bank
|
|
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/bank/#list
|
|
18
|
+
# List Banks: GET /bank
|
|
19
|
+
# List banks supported on Paystack
|
|
20
|
+
#
|
|
21
|
+
# @param country ["ghana", "kenya", "nigeria", "south africa"]
|
|
22
|
+
# The country from which to obtain the list of supported banks
|
|
23
|
+
# @param currency ["GHS", "KES", "NGN", "ZAR"]
|
|
24
|
+
# The country from which to obtain the list of supported banks
|
|
25
|
+
# @param use_cursor [Boolean]
|
|
26
|
+
# A flag to indicate if cursor based pagination should be used
|
|
27
|
+
# @param per_page [Integer]
|
|
28
|
+
# The number of records to fetch per request
|
|
29
|
+
# @param page [Integer]
|
|
30
|
+
# The offset to retrieve data from
|
|
31
|
+
# @param next [String]
|
|
32
|
+
# An alphanumeric value returned for every cursor based retrieval, used to retrieve
|
|
33
|
+
# the next set of data
|
|
34
|
+
# @param previous [String]
|
|
35
|
+
# An alphanumeric value returned for every cursor based retrieval, used to retrieve
|
|
36
|
+
# the previous set of data
|
|
37
|
+
# @param pay_with_bank_transfer [Boolean]
|
|
38
|
+
# A flag to filter for available banks a customer can make a transfer to complete
|
|
39
|
+
# a payment
|
|
40
|
+
# @param pay_with_bank [Boolean]
|
|
41
|
+
# A flag to filter for banks a customer can pay directly from
|
|
42
|
+
# @param enabled_for_verification [Boolean]
|
|
43
|
+
# A flag to filter the banks that are supported for account verification in South
|
|
44
|
+
# Africa. You need to combine this with either the `currency` or `country` filter.
|
|
45
|
+
# @param gateway ["emandate", "digitalbankmandate"]
|
|
46
|
+
# The type of gateway for a Nigerian bank
|
|
47
|
+
# @param type ["ghipps", "mobile_money", "nuban", "kepss", "basa"]
|
|
48
|
+
# Type of financial channel
|
|
49
|
+
# @param include_nip_sort_code [Boolean]
|
|
50
|
+
# A flag that returns Nigerian banks with their NIP institution code. The returned
|
|
51
|
+
# value can be used in identifying institutions on NIP.
|
|
52
|
+
#
|
|
53
|
+
# @return [ListResponse] successful response
|
|
54
|
+
# @raise [ListError] if the request fails
|
|
55
|
+
api_method def self.list(
|
|
56
|
+
country: nil,
|
|
57
|
+
currency: nil,
|
|
58
|
+
use_cursor: nil,
|
|
59
|
+
per_page: nil,
|
|
60
|
+
page: nil,
|
|
61
|
+
next: nil,
|
|
62
|
+
previous: nil,
|
|
63
|
+
pay_with_bank_transfer: nil,
|
|
64
|
+
pay_with_bank: nil,
|
|
65
|
+
enabled_for_verification: nil,
|
|
66
|
+
gateway: nil,
|
|
67
|
+
type: nil,
|
|
68
|
+
include_nip_sort_code: nil
|
|
69
|
+
)
|
|
70
|
+
use_connection do |connection|
|
|
71
|
+
connection.get(
|
|
72
|
+
'/bank',
|
|
73
|
+
{
|
|
74
|
+
country:,
|
|
75
|
+
currency:,
|
|
76
|
+
use_cursor:,
|
|
77
|
+
perPage: per_page,
|
|
78
|
+
page:,
|
|
79
|
+
next:,
|
|
80
|
+
previous:,
|
|
81
|
+
pay_with_bank_transfer:,
|
|
82
|
+
pay_with_bank:,
|
|
83
|
+
enabled_for_verification:,
|
|
84
|
+
gateway:,
|
|
85
|
+
type:,
|
|
86
|
+
include_nip_sort_code:,
|
|
87
|
+
}.compact,
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Successful response from calling #resolve_account_number.
|
|
93
|
+
class ResolveAccountNumberResponse < PaystackGateway::Response
|
|
94
|
+
delegate :account_number, :account_name, :bank_id, to: :data
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Error response from #resolve_account_number.
|
|
98
|
+
class ResolveAccountNumberError < ApiError; end
|
|
99
|
+
|
|
100
|
+
# https://paystack.com/docs/api/bank/#resolve_account_number
|
|
101
|
+
# Resolve Account Number: GET /bank/resolve
|
|
102
|
+
# Resolve an account number to confirm the name associated with it
|
|
103
|
+
#
|
|
104
|
+
# @param account_number [Integer]
|
|
105
|
+
# The account number of interest
|
|
106
|
+
# @param bank_code [Integer]
|
|
107
|
+
# The bank code associated with the account number
|
|
108
|
+
#
|
|
109
|
+
# @return [ResolveAccountNumberResponse] successful response
|
|
110
|
+
# @raise [ResolveAccountNumberError] if the request fails
|
|
111
|
+
api_method def self.resolve_account_number(account_number: nil, bank_code: nil)
|
|
112
|
+
use_connection do |connection|
|
|
113
|
+
connection.get(
|
|
114
|
+
'/bank/resolve',
|
|
115
|
+
{ account_number:, bank_code: }.compact,
|
|
116
|
+
)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Successful response from calling #validate_account_number.
|
|
121
|
+
class ValidateAccountNumberResponse < PaystackGateway::Response
|
|
122
|
+
delegate :verified,
|
|
123
|
+
:verificationMessage,
|
|
124
|
+
:accountAcceptsDebits,
|
|
125
|
+
:accountAcceptsCredits,
|
|
126
|
+
:accountOpenForMoreThanThreeMonths,
|
|
127
|
+
:accountHolderMatch,
|
|
128
|
+
:accountOpen, to: :data
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Error response from #validate_account_number.
|
|
132
|
+
class ValidateAccountNumberError < ApiError; end
|
|
133
|
+
|
|
134
|
+
# https://paystack.com/docs/api/bank/#validate_account_number
|
|
135
|
+
# Validate Bank Account: POST /bank/validate
|
|
136
|
+
# Confirm the authenticity of a customer's account number before sending money
|
|
137
|
+
#
|
|
138
|
+
# @param account_name [String] (required)
|
|
139
|
+
# Customer's first and last name registered with their bank
|
|
140
|
+
# @param account_number [String] (required)
|
|
141
|
+
# Customer's account number
|
|
142
|
+
# @param account_type ["personal", "business"] (required)
|
|
143
|
+
# The type of the customer's account number
|
|
144
|
+
# @param bank_code [String] (required)
|
|
145
|
+
# The bank code of the customer’s bank. You can fetch the bank codes by using our
|
|
146
|
+
# List Banks endpoint
|
|
147
|
+
# @param country_code [String] (required)
|
|
148
|
+
# The two digit ISO code of the customer’s bank
|
|
149
|
+
# @param document_type ["identityNumber", "passportNumber", "businessRegistrationNumber"] (required)
|
|
150
|
+
# Customer’s mode of identity
|
|
151
|
+
# @param document_number [String]
|
|
152
|
+
# Customer’s mode of identity number
|
|
153
|
+
#
|
|
154
|
+
# @return [ValidateAccountNumberResponse] successful response
|
|
155
|
+
# @raise [ValidateAccountNumberError] if the request fails
|
|
156
|
+
api_method def self.validate_account_number(
|
|
157
|
+
account_name:,
|
|
158
|
+
account_number:,
|
|
159
|
+
account_type:,
|
|
160
|
+
bank_code:,
|
|
161
|
+
country_code:,
|
|
162
|
+
document_type:,
|
|
163
|
+
document_number: nil
|
|
164
|
+
)
|
|
165
|
+
use_connection do |connection|
|
|
166
|
+
connection.post(
|
|
167
|
+
'/bank/validate',
|
|
168
|
+
{
|
|
169
|
+
account_name:,
|
|
170
|
+
account_number:,
|
|
171
|
+
account_type:,
|
|
172
|
+
bank_code:,
|
|
173
|
+
country_code:,
|
|
174
|
+
document_type:,
|
|
175
|
+
document_number:,
|
|
176
|
+
}.compact,
|
|
177
|
+
)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/bulkcharge
|
|
5
|
+
#
|
|
6
|
+
# Bulk Charges
|
|
7
|
+
# A collection of endpoints for creating and managing multiple recurring payments
|
|
8
|
+
module BulkCharge
|
|
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/bulk-charge/#list
|
|
18
|
+
# List Bulk Charge Batches: GET /bulkcharge
|
|
19
|
+
# List all bulk charge batches.
|
|
20
|
+
#
|
|
21
|
+
# @param per_page [Integer]
|
|
22
|
+
# Number of records to fetch per page
|
|
23
|
+
# @param page [Integer]
|
|
24
|
+
# The offset to retrieve data from
|
|
25
|
+
# @param status ["active", "paused", "complete"]
|
|
26
|
+
# Filter by the status of the charges
|
|
27
|
+
#
|
|
28
|
+
# @return [ListResponse] successful response
|
|
29
|
+
# @raise [ListError] if the request fails
|
|
30
|
+
api_method def self.list(per_page: nil, page: nil, status: nil)
|
|
31
|
+
use_connection do |connection|
|
|
32
|
+
connection.get(
|
|
33
|
+
'/bulkcharge',
|
|
34
|
+
{ perPage: per_page, page:, status: }.compact,
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Successful response from calling #initiate.
|
|
40
|
+
class InitiateResponse < PaystackGateway::Response
|
|
41
|
+
delegate :batch_code,
|
|
42
|
+
:reference,
|
|
43
|
+
:id,
|
|
44
|
+
:integration,
|
|
45
|
+
:domain,
|
|
46
|
+
:total_charges,
|
|
47
|
+
:pending_charges,
|
|
48
|
+
:createdAt,
|
|
49
|
+
:updatedAt, to: :data
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Error response from #initiate.
|
|
53
|
+
class InitiateError < ApiError; end
|
|
54
|
+
|
|
55
|
+
# https://paystack.com/docs/api/bulk-charge/#initiate
|
|
56
|
+
# Initiate Bulk Charge: POST /bulkcharge
|
|
57
|
+
# Charge multiple customers in batches
|
|
58
|
+
#
|
|
59
|
+
# @param charges [Array<Hash>] (required)
|
|
60
|
+
# A list of charge object
|
|
61
|
+
# @option charges [String] :authorization
|
|
62
|
+
# Customer's card authorization code
|
|
63
|
+
# @option charges [Integer] :amount
|
|
64
|
+
# Amount to charge on the authorization
|
|
65
|
+
# @option charges [String] :reference
|
|
66
|
+
# A unique identifier containing lowercase letters `(a-z)`, digits `(0-9)` and these
|
|
67
|
+
# symbols: dash (`-`), underscore(`_`)
|
|
68
|
+
# @option charges [Boolean] :attempt_partial_debit
|
|
69
|
+
# A flag to indicate if you want us to try recouping lower amounts when the customer
|
|
70
|
+
# has insufficient fund
|
|
71
|
+
# @option charges [Integer] :at_least
|
|
72
|
+
# Minimum amount to charge if the attempt_partial_debit flag is set
|
|
73
|
+
# @option charges [Hash] :metadata
|
|
74
|
+
# JSON object of custom data
|
|
75
|
+
#
|
|
76
|
+
# @return [InitiateResponse] successful response
|
|
77
|
+
# @raise [InitiateError] if the request fails
|
|
78
|
+
api_method def self.initiate(charges:)
|
|
79
|
+
use_connection do |connection|
|
|
80
|
+
connection.post(
|
|
81
|
+
'/bulkcharge',
|
|
82
|
+
charges,
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Successful response from calling #fetch.
|
|
88
|
+
class FetchResponse < PaystackGateway::Response
|
|
89
|
+
delegate :batch_code,
|
|
90
|
+
:reference,
|
|
91
|
+
:id,
|
|
92
|
+
:integration,
|
|
93
|
+
:domain,
|
|
94
|
+
:total_charges,
|
|
95
|
+
:pending_charges,
|
|
96
|
+
:createdAt,
|
|
97
|
+
:updatedAt, to: :data
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Error response from #fetch.
|
|
101
|
+
class FetchError < ApiError; end
|
|
102
|
+
|
|
103
|
+
# https://paystack.com/docs/api/bulk-charge/#fetch
|
|
104
|
+
# Fetch Bulk Charge Batch: GET /bulkcharge/{code}
|
|
105
|
+
# This endpoint retrieves a specific batch code. It also returns useful information
|
|
106
|
+
# on its progress by way of the `total_charges` and `pending_charges` attributes.
|
|
107
|
+
#
|
|
108
|
+
# @param code [String] (required)
|
|
109
|
+
# The code for the charge whose batches you want to retrieve
|
|
110
|
+
#
|
|
111
|
+
# @return [FetchResponse] successful response
|
|
112
|
+
# @raise [FetchError] if the request fails
|
|
113
|
+
api_method def self.fetch(code:)
|
|
114
|
+
use_connection do |connection|
|
|
115
|
+
connection.get(
|
|
116
|
+
"/bulkcharge/#{code}",
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Successful response from calling #charges.
|
|
122
|
+
class ChargesResponse < PaystackGateway::Response; end
|
|
123
|
+
|
|
124
|
+
# Error response from #charges.
|
|
125
|
+
class ChargesError < ApiError; end
|
|
126
|
+
|
|
127
|
+
# https://paystack.com/docs/api/bulk-charge/#charges
|
|
128
|
+
# List Charges in a Batch: GET /bulkcharge/{code}/charges
|
|
129
|
+
# This endpoint retrieves the charges associated with a specified batch code
|
|
130
|
+
#
|
|
131
|
+
# @param code [String] (required)
|
|
132
|
+
# An code for the batch whose charges you want to retrieve
|
|
133
|
+
# @param per_page [Integer]
|
|
134
|
+
# Number of records to fetch per page
|
|
135
|
+
# @param page [Integer]
|
|
136
|
+
# The offset to retrieve data from
|
|
137
|
+
# @param status ["success", "failed", "pending", "error", "inactive_authorization"]
|
|
138
|
+
# Filter by the status of the charges
|
|
139
|
+
#
|
|
140
|
+
# @return [ChargesResponse] successful response
|
|
141
|
+
# @raise [ChargesError] if the request fails
|
|
142
|
+
api_method def self.charges(code:, per_page: nil, page: nil, status: nil)
|
|
143
|
+
use_connection do |connection|
|
|
144
|
+
connection.get(
|
|
145
|
+
"/bulkcharge/#{code}/charges",
|
|
146
|
+
{ perPage: per_page, page:, status: }.compact,
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Successful response from calling #pause.
|
|
152
|
+
class PauseResponse < PaystackGateway::Response; end
|
|
153
|
+
|
|
154
|
+
# Error response from #pause.
|
|
155
|
+
class PauseError < ApiError; end
|
|
156
|
+
|
|
157
|
+
# https://paystack.com/docs/api/bulk-charge/#pause
|
|
158
|
+
# Pause Bulk Charge Batch: GET /bulkcharge/pause/{code}
|
|
159
|
+
# Pause the processing of a charge batch
|
|
160
|
+
#
|
|
161
|
+
# @param code [String] (required)
|
|
162
|
+
# The batch code for the bulk charge you want to pause
|
|
163
|
+
#
|
|
164
|
+
# @return [PauseResponse] successful response
|
|
165
|
+
# @raise [PauseError] if the request fails
|
|
166
|
+
api_method def self.pause(code:)
|
|
167
|
+
use_connection do |connection|
|
|
168
|
+
connection.get(
|
|
169
|
+
"/bulkcharge/pause/#{code}",
|
|
170
|
+
)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Successful response from calling #resume.
|
|
175
|
+
class ResumeResponse < PaystackGateway::Response; end
|
|
176
|
+
|
|
177
|
+
# Error response from #resume.
|
|
178
|
+
class ResumeError < ApiError; end
|
|
179
|
+
|
|
180
|
+
# https://paystack.com/docs/api/bulk-charge/#resume
|
|
181
|
+
# Resume Bulk Charge Batch: GET /bulkcharge/resume/{code}
|
|
182
|
+
# Resume the processing of a previously paused charge batch
|
|
183
|
+
#
|
|
184
|
+
# @param code [String] (required)
|
|
185
|
+
# The batch code for the bulk charge you want to pause
|
|
186
|
+
#
|
|
187
|
+
# @return [ResumeResponse] successful response
|
|
188
|
+
# @raise [ResumeError] if the request fails
|
|
189
|
+
api_method def self.resume(code:)
|
|
190
|
+
use_connection do |connection|
|
|
191
|
+
connection.get(
|
|
192
|
+
"/bulkcharge/resume/#{code}",
|
|
193
|
+
)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|