paystack-gateway 0.1.0 → 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 +88 -105
- data/lib/paystack_gateway/api_error.rb +12 -2
- 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 +5 -3
- 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 +20 -15
- 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 +61 -11
- metadata +50 -7
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/settlement
|
|
5
|
+
#
|
|
6
|
+
# Settlements
|
|
7
|
+
# A collection of endpoints for gaining insights into payouts
|
|
8
|
+
module Settlement
|
|
9
|
+
include PaystackGateway::RequestModule
|
|
10
|
+
|
|
11
|
+
# Successful response from calling #fetch.
|
|
12
|
+
class FetchResponse < PaystackGateway::Response; end
|
|
13
|
+
|
|
14
|
+
# Error response from #fetch.
|
|
15
|
+
class FetchError < ApiError; end
|
|
16
|
+
|
|
17
|
+
# https://paystack.com/docs/api/settlement/#fetch
|
|
18
|
+
# List Settlements: GET /settlement
|
|
19
|
+
# List settlements made to your settlement accounts
|
|
20
|
+
#
|
|
21
|
+
# @param per_page [Integer]
|
|
22
|
+
# The number of records to fetch per request
|
|
23
|
+
# @param page [Integer]
|
|
24
|
+
# The offset to retrieve data from
|
|
25
|
+
#
|
|
26
|
+
# @return [FetchResponse] successful response
|
|
27
|
+
# @raise [FetchError] if the request fails
|
|
28
|
+
api_method def self.fetch(per_page: nil, page: nil)
|
|
29
|
+
use_connection do |connection|
|
|
30
|
+
connection.get(
|
|
31
|
+
'/settlement',
|
|
32
|
+
{ perPage: per_page, page: }.compact,
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Successful response from calling #transaction.
|
|
38
|
+
class TransactionResponse < PaystackGateway::Response; end
|
|
39
|
+
|
|
40
|
+
# Error response from #transaction.
|
|
41
|
+
class TransactionError < ApiError; end
|
|
42
|
+
|
|
43
|
+
# https://paystack.com/docs/api/settlement/#transaction
|
|
44
|
+
# Fetch Settlement Transactions: GET /settlement/{id}/transactions
|
|
45
|
+
# Get the transactions that make up a particular settlement
|
|
46
|
+
#
|
|
47
|
+
# @param id [Integer] (required)
|
|
48
|
+
# The settlement ID in which you want to fetch its transactions
|
|
49
|
+
#
|
|
50
|
+
# @return [TransactionResponse] successful response
|
|
51
|
+
# @raise [TransactionError] if the request fails
|
|
52
|
+
api_method def self.transaction(id:)
|
|
53
|
+
use_connection do |connection|
|
|
54
|
+
connection.get(
|
|
55
|
+
"/settlement/#{id}/transactions",
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/split
|
|
5
|
+
#
|
|
6
|
+
# Transaction Splits
|
|
7
|
+
# A collection of endpoints for spliting a transaction and managing the splits
|
|
8
|
+
module Split
|
|
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/split/#list
|
|
18
|
+
# List Splits: GET /split
|
|
19
|
+
# List the transaction splits available on your integration
|
|
20
|
+
#
|
|
21
|
+
# @param subaccount_code [String]
|
|
22
|
+
# Filter by subaccount code
|
|
23
|
+
# @param name [String]
|
|
24
|
+
# The name of the split
|
|
25
|
+
# @param active [Boolean]
|
|
26
|
+
# The status of the split
|
|
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 from [Time]
|
|
32
|
+
# The start date
|
|
33
|
+
# @param to [Time]
|
|
34
|
+
# The end date
|
|
35
|
+
#
|
|
36
|
+
# @return [ListResponse] successful response
|
|
37
|
+
# @raise [ListError] if the request fails
|
|
38
|
+
api_method def self.list(
|
|
39
|
+
subaccount_code: nil,
|
|
40
|
+
name: nil,
|
|
41
|
+
active: nil,
|
|
42
|
+
per_page: nil,
|
|
43
|
+
page: nil,
|
|
44
|
+
from: nil,
|
|
45
|
+
to: nil
|
|
46
|
+
)
|
|
47
|
+
use_connection do |connection|
|
|
48
|
+
connection.get(
|
|
49
|
+
'/split',
|
|
50
|
+
{
|
|
51
|
+
subaccount_code:,
|
|
52
|
+
name:,
|
|
53
|
+
active:,
|
|
54
|
+
per_page:,
|
|
55
|
+
page:,
|
|
56
|
+
from:,
|
|
57
|
+
to:,
|
|
58
|
+
}.compact,
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Successful response from calling #create.
|
|
64
|
+
class CreateResponse < PaystackGateway::Response
|
|
65
|
+
delegate :id,
|
|
66
|
+
:name,
|
|
67
|
+
:type,
|
|
68
|
+
:currency,
|
|
69
|
+
:integration,
|
|
70
|
+
:domain,
|
|
71
|
+
:split_code,
|
|
72
|
+
:active,
|
|
73
|
+
:bearer_type,
|
|
74
|
+
:createdAt,
|
|
75
|
+
:updatedAt,
|
|
76
|
+
:is_dynamic,
|
|
77
|
+
:subaccounts,
|
|
78
|
+
:total_subaccounts, to: :data
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Error response from #create.
|
|
82
|
+
class CreateError < ApiError; end
|
|
83
|
+
|
|
84
|
+
# https://paystack.com/docs/api/split/#create
|
|
85
|
+
# Create Split: POST /split
|
|
86
|
+
# Create a split configuration for transactions
|
|
87
|
+
#
|
|
88
|
+
# @param name [String] (required)
|
|
89
|
+
# Name of the transaction split
|
|
90
|
+
# @param type ["percentage", "flat"] (required)
|
|
91
|
+
# The type of transaction split you want to create.
|
|
92
|
+
# @param subaccounts [Array<Hash>] (required)
|
|
93
|
+
# A list of object containing subaccount code and number of shares
|
|
94
|
+
# @param currency ["NGN", "GHS", "ZAR", "USD"] (required)
|
|
95
|
+
# The transaction currency
|
|
96
|
+
# @param bearer_type ["subaccount", "account", "all-proportional", "all"]
|
|
97
|
+
# This allows you specify how the transaction charge should be processed
|
|
98
|
+
# @param bearer_subaccount [String]
|
|
99
|
+
# This is the subaccount code of the customer or partner that would bear the transaction
|
|
100
|
+
# charge if you specified subaccount as the bearer type
|
|
101
|
+
#
|
|
102
|
+
# @return [CreateResponse] successful response
|
|
103
|
+
# @raise [CreateError] if the request fails
|
|
104
|
+
api_method def self.create(
|
|
105
|
+
name:,
|
|
106
|
+
type:,
|
|
107
|
+
subaccounts:,
|
|
108
|
+
currency:,
|
|
109
|
+
bearer_type: nil,
|
|
110
|
+
bearer_subaccount: nil
|
|
111
|
+
)
|
|
112
|
+
use_connection do |connection|
|
|
113
|
+
connection.post(
|
|
114
|
+
'/split',
|
|
115
|
+
{
|
|
116
|
+
name:,
|
|
117
|
+
type:,
|
|
118
|
+
subaccounts:,
|
|
119
|
+
currency:,
|
|
120
|
+
bearer_type:,
|
|
121
|
+
bearer_subaccount:,
|
|
122
|
+
}.compact,
|
|
123
|
+
)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Successful response from calling #fetch.
|
|
128
|
+
class FetchResponse < PaystackGateway::Response
|
|
129
|
+
delegate :id,
|
|
130
|
+
:name,
|
|
131
|
+
:type,
|
|
132
|
+
:currency,
|
|
133
|
+
:integration,
|
|
134
|
+
:domain,
|
|
135
|
+
:split_code,
|
|
136
|
+
:active,
|
|
137
|
+
:bearer_type,
|
|
138
|
+
:bearer_subaccount,
|
|
139
|
+
:createdAt,
|
|
140
|
+
:updatedAt,
|
|
141
|
+
:is_dynamic,
|
|
142
|
+
:subaccounts,
|
|
143
|
+
:total_subaccounts, to: :data
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Error response from #fetch.
|
|
147
|
+
class FetchError < ApiError; end
|
|
148
|
+
|
|
149
|
+
# https://paystack.com/docs/api/split/#fetch
|
|
150
|
+
# Fetch Split: GET /split/{id}
|
|
151
|
+
# Get details of a split configuration for a transaction
|
|
152
|
+
#
|
|
153
|
+
# @param id [Integer] (required)
|
|
154
|
+
# The ID of the split configuration to fetch
|
|
155
|
+
#
|
|
156
|
+
# @return [FetchResponse] successful response
|
|
157
|
+
# @raise [FetchError] if the request fails
|
|
158
|
+
api_method def self.fetch(id:)
|
|
159
|
+
use_connection do |connection|
|
|
160
|
+
connection.get(
|
|
161
|
+
"/split/#{id}",
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Successful response from calling #update.
|
|
167
|
+
class UpdateResponse < PaystackGateway::Response
|
|
168
|
+
delegate :id,
|
|
169
|
+
:name,
|
|
170
|
+
:type,
|
|
171
|
+
:currency,
|
|
172
|
+
:integration,
|
|
173
|
+
:domain,
|
|
174
|
+
:split_code,
|
|
175
|
+
:active,
|
|
176
|
+
:bearer_type,
|
|
177
|
+
:bearer_subaccount,
|
|
178
|
+
:createdAt,
|
|
179
|
+
:updatedAt,
|
|
180
|
+
:is_dynamic,
|
|
181
|
+
:subaccounts,
|
|
182
|
+
:total_subaccounts, to: :data
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Error response from #update.
|
|
186
|
+
class UpdateError < ApiError; end
|
|
187
|
+
|
|
188
|
+
# https://paystack.com/docs/api/split/#update
|
|
189
|
+
# Update Split: PUT /split/{id}
|
|
190
|
+
# Update a split configuration for transactions
|
|
191
|
+
#
|
|
192
|
+
# @param id [String] (required)
|
|
193
|
+
# @param name [String]
|
|
194
|
+
# Name of the transaction split
|
|
195
|
+
# @param active [Boolean]
|
|
196
|
+
# Toggle status of split. When true, the split is active, else it's inactive
|
|
197
|
+
# @param bearer_type ["subaccount", "account", "all-proportional", "all"]
|
|
198
|
+
# This allows you specify how the transaction charge should be processed
|
|
199
|
+
# @param bearer_subaccount [String]
|
|
200
|
+
# This is the subaccount code of the customer or partner that would bear the transaction
|
|
201
|
+
# charge if you specified subaccount as the bearer type
|
|
202
|
+
#
|
|
203
|
+
# @return [UpdateResponse] successful response
|
|
204
|
+
# @raise [UpdateError] if the request fails
|
|
205
|
+
api_method def self.update(id:, name: nil, active: nil, bearer_type: nil, bearer_subaccount: nil)
|
|
206
|
+
use_connection do |connection|
|
|
207
|
+
connection.put(
|
|
208
|
+
"/split/#{id}",
|
|
209
|
+
{ name:, active:, bearer_type:, bearer_subaccount: }.compact,
|
|
210
|
+
)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Successful response from calling #add_subaccount.
|
|
215
|
+
class AddSubaccountResponse < PaystackGateway::Response
|
|
216
|
+
delegate :id,
|
|
217
|
+
:name,
|
|
218
|
+
:type,
|
|
219
|
+
:currency,
|
|
220
|
+
:integration,
|
|
221
|
+
:domain,
|
|
222
|
+
:split_code,
|
|
223
|
+
:active,
|
|
224
|
+
:bearer_type,
|
|
225
|
+
:bearer_subaccount,
|
|
226
|
+
:createdAt,
|
|
227
|
+
:updatedAt,
|
|
228
|
+
:is_dynamic,
|
|
229
|
+
:subaccounts,
|
|
230
|
+
:total_subaccounts, to: :data
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Error response from #add_subaccount.
|
|
234
|
+
class AddSubaccountError < ApiError; end
|
|
235
|
+
|
|
236
|
+
# https://paystack.com/docs/api/split/#add_subaccount
|
|
237
|
+
# Add Subaccount to Split: POST /split/{id}/subaccount/add
|
|
238
|
+
# Add a subaccount to a split configuration, or update the share of an existing subaccount
|
|
239
|
+
#
|
|
240
|
+
# @param id [Integer] (required)
|
|
241
|
+
# The ID of the split configuration to fetch
|
|
242
|
+
# @param subaccount [String]
|
|
243
|
+
# Subaccount code of the customer or partner
|
|
244
|
+
# @param share [Integer]
|
|
245
|
+
# The percentage or flat quota of the customer or partner
|
|
246
|
+
#
|
|
247
|
+
# @return [AddSubaccountResponse] successful response
|
|
248
|
+
# @raise [AddSubaccountError] if the request fails
|
|
249
|
+
api_method def self.add_subaccount(id:, subaccount: nil, share: nil)
|
|
250
|
+
use_connection do |connection|
|
|
251
|
+
connection.post(
|
|
252
|
+
"/split/#{id}/subaccount/add",
|
|
253
|
+
{ subaccount:, share: }.compact,
|
|
254
|
+
)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
# Successful response from calling #remove_subaccount.
|
|
259
|
+
class RemoveSubaccountResponse < PaystackGateway::Response; end
|
|
260
|
+
|
|
261
|
+
# Error response from #remove_subaccount.
|
|
262
|
+
class RemoveSubaccountError < ApiError; end
|
|
263
|
+
|
|
264
|
+
# https://paystack.com/docs/api/split/#remove_subaccount
|
|
265
|
+
# Remove Subaccount from split: POST /split/{id}/subaccount/remove
|
|
266
|
+
# Remove a subaccount from a split configuration
|
|
267
|
+
#
|
|
268
|
+
# @param id [Integer] (required)
|
|
269
|
+
# The ID of the split configuration to fetch
|
|
270
|
+
# @param subaccount [String]
|
|
271
|
+
# Subaccount code of the customer or partner
|
|
272
|
+
# @param share [Integer]
|
|
273
|
+
# The percentage or flat quota of the customer or partner
|
|
274
|
+
#
|
|
275
|
+
# @return [RemoveSubaccountResponse] successful response
|
|
276
|
+
# @raise [RemoveSubaccountError] if the request fails
|
|
277
|
+
api_method def self.remove_subaccount(id:, subaccount: nil, share: nil)
|
|
278
|
+
use_connection do |connection|
|
|
279
|
+
connection.post(
|
|
280
|
+
"/split/#{id}/subaccount/remove",
|
|
281
|
+
{ subaccount:, share: }.compact,
|
|
282
|
+
)
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/storefront
|
|
5
|
+
#
|
|
6
|
+
# Storefronts
|
|
7
|
+
# A collection of endpoints for creating and managing storefronts
|
|
8
|
+
module Storefront
|
|
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/storefront/#list
|
|
18
|
+
# List Storefronts: GET /storefront
|
|
19
|
+
# List the storefronts you previously created
|
|
20
|
+
#
|
|
21
|
+
# @param per_page [Integer]
|
|
22
|
+
# Number of records to fetch per request
|
|
23
|
+
# @param page [Integer]
|
|
24
|
+
# The offset to retrieve data from
|
|
25
|
+
# @param status ["active", "inactive"]
|
|
26
|
+
#
|
|
27
|
+
# @return [ListResponse] successful response
|
|
28
|
+
# @raise [ListError] if the request fails
|
|
29
|
+
api_method def self.list(per_page: nil, page: nil, status: nil)
|
|
30
|
+
use_connection do |connection|
|
|
31
|
+
connection.get(
|
|
32
|
+
'/storefront',
|
|
33
|
+
{ perPage: per_page, page:, status: }.compact,
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Successful response from calling #create.
|
|
39
|
+
class CreateResponse < PaystackGateway::Response
|
|
40
|
+
delegate :social_media,
|
|
41
|
+
:contacts,
|
|
42
|
+
:name,
|
|
43
|
+
:slug,
|
|
44
|
+
:currency,
|
|
45
|
+
:welcome_message,
|
|
46
|
+
:success_message,
|
|
47
|
+
:redirect_url,
|
|
48
|
+
:description,
|
|
49
|
+
:delivery_note,
|
|
50
|
+
:background_color,
|
|
51
|
+
:shippable,
|
|
52
|
+
:integration,
|
|
53
|
+
:domain,
|
|
54
|
+
:digital_product_expiry,
|
|
55
|
+
:id,
|
|
56
|
+
:createdAt,
|
|
57
|
+
:updatedAt,
|
|
58
|
+
:products,
|
|
59
|
+
:shipping_fees, to: :data
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Error response from #create.
|
|
63
|
+
class CreateError < ApiError; end
|
|
64
|
+
|
|
65
|
+
# https://paystack.com/docs/api/storefront/#create
|
|
66
|
+
# Create Storefront: POST /storefront
|
|
67
|
+
# Create a digital shop to manage and display your products
|
|
68
|
+
#
|
|
69
|
+
# @param name [String] (required)
|
|
70
|
+
# Name of the storefront
|
|
71
|
+
# @param slug [String] (required)
|
|
72
|
+
# A unique identifier to access your store. Once the storefront is created, it can
|
|
73
|
+
# be accessed from https://paystack.shop/your-slug
|
|
74
|
+
# @param currency ["GHS", "KES", "NGN", "USD", "ZAR"] (required)
|
|
75
|
+
# Currency for prices of products in your storefront.
|
|
76
|
+
# @param description [String]
|
|
77
|
+
# The description of the storefront
|
|
78
|
+
#
|
|
79
|
+
# @return [CreateResponse] successful response
|
|
80
|
+
# @raise [CreateError] if the request fails
|
|
81
|
+
api_method def self.create(name:, slug:, currency:, description: nil)
|
|
82
|
+
use_connection do |connection|
|
|
83
|
+
connection.post(
|
|
84
|
+
'/storefront',
|
|
85
|
+
{ name:, slug:, currency:, description: }.compact,
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Successful response from calling #fetch.
|
|
91
|
+
class FetchResponse < PaystackGateway::Response
|
|
92
|
+
delegate :social_media,
|
|
93
|
+
:contacts,
|
|
94
|
+
:name,
|
|
95
|
+
:slug,
|
|
96
|
+
:currency,
|
|
97
|
+
:welcome_message,
|
|
98
|
+
:success_message,
|
|
99
|
+
:redirect_url,
|
|
100
|
+
:description,
|
|
101
|
+
:delivery_note,
|
|
102
|
+
:background_color,
|
|
103
|
+
:shippable,
|
|
104
|
+
:integration,
|
|
105
|
+
:domain,
|
|
106
|
+
:digital_product_expiry,
|
|
107
|
+
:id,
|
|
108
|
+
:createdAt,
|
|
109
|
+
:updatedAt,
|
|
110
|
+
:products,
|
|
111
|
+
:shipping_fees, to: :data
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Error response from #fetch.
|
|
115
|
+
class FetchError < ApiError; end
|
|
116
|
+
|
|
117
|
+
# https://paystack.com/docs/api/storefront/#fetch
|
|
118
|
+
# Fetch Storefront: GET /storefront/{id}
|
|
119
|
+
# Get the details of a previously created Storefront
|
|
120
|
+
#
|
|
121
|
+
# @param id [Integer] (required)
|
|
122
|
+
# The unique identifier of the Storefront
|
|
123
|
+
#
|
|
124
|
+
# @return [FetchResponse] successful response
|
|
125
|
+
# @raise [FetchError] if the request fails
|
|
126
|
+
api_method def self.fetch(id:)
|
|
127
|
+
use_connection do |connection|
|
|
128
|
+
connection.get(
|
|
129
|
+
"/storefront/#{id}",
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Successful response from calling #update.
|
|
135
|
+
class UpdateResponse < PaystackGateway::Response; end
|
|
136
|
+
|
|
137
|
+
# Error response from #update.
|
|
138
|
+
class UpdateError < ApiError; end
|
|
139
|
+
|
|
140
|
+
# https://paystack.com/docs/api/storefront/#update
|
|
141
|
+
# Update Storefront: PUT /storefront/{id}
|
|
142
|
+
# Update the details of a previously created Storefront
|
|
143
|
+
#
|
|
144
|
+
# @param id [Integer] (required)
|
|
145
|
+
# The unique identifier of the Storefront
|
|
146
|
+
# @param name [String]
|
|
147
|
+
# Name of the storefront
|
|
148
|
+
# @param slug [String]
|
|
149
|
+
# A unique identifier to access your store. Once the storefront is created, it can
|
|
150
|
+
# be accessed from https://paystack.shop/your-slug
|
|
151
|
+
# @param description [String]
|
|
152
|
+
# The description of the storefront
|
|
153
|
+
#
|
|
154
|
+
# @return [UpdateResponse] successful response
|
|
155
|
+
# @raise [UpdateError] if the request fails
|
|
156
|
+
api_method def self.update(id:, name: nil, slug: nil, description: nil)
|
|
157
|
+
use_connection do |connection|
|
|
158
|
+
connection.put(
|
|
159
|
+
"/storefront/#{id}",
|
|
160
|
+
{ name:, slug:, description: }.compact,
|
|
161
|
+
)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Successful response from calling #delete.
|
|
166
|
+
class DeleteResponse < PaystackGateway::Response; end
|
|
167
|
+
|
|
168
|
+
# Error response from #delete.
|
|
169
|
+
class DeleteError < ApiError; end
|
|
170
|
+
|
|
171
|
+
# https://paystack.com/docs/api/storefront/#delete
|
|
172
|
+
# Delete Storefront: DELETE /storefront/{id}
|
|
173
|
+
# Delete a previously created Storefront
|
|
174
|
+
#
|
|
175
|
+
# @param id [Integer] (required)
|
|
176
|
+
# The unique identifier of the Storefront
|
|
177
|
+
#
|
|
178
|
+
# @return [DeleteResponse] successful response
|
|
179
|
+
# @raise [DeleteError] if the request fails
|
|
180
|
+
api_method def self.delete(id:)
|
|
181
|
+
use_connection do |connection|
|
|
182
|
+
connection.delete(
|
|
183
|
+
"/storefront/#{id}",
|
|
184
|
+
)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Successful response from calling #verify_slug.
|
|
189
|
+
class VerifySlugResponse < PaystackGateway::Response; end
|
|
190
|
+
|
|
191
|
+
# Error response from #verify_slug.
|
|
192
|
+
class VerifySlugError < ApiError; end
|
|
193
|
+
|
|
194
|
+
# https://paystack.com/docs/api/storefront/#verify_slug
|
|
195
|
+
# Verify Storefront Slug: GET /storefront/verify/{slug}
|
|
196
|
+
# Verify the availability of a slug before using it for your Storefront
|
|
197
|
+
#
|
|
198
|
+
# @param slug [String] (required)
|
|
199
|
+
# The custom slug to check
|
|
200
|
+
#
|
|
201
|
+
# @return [VerifySlugResponse] successful response
|
|
202
|
+
# @raise [VerifySlugError] if the request fails
|
|
203
|
+
api_method def self.verify_slug(slug:)
|
|
204
|
+
use_connection do |connection|
|
|
205
|
+
connection.get(
|
|
206
|
+
"/storefront/verify/#{slug}",
|
|
207
|
+
)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Successful response from calling #fetch_orders.
|
|
212
|
+
class FetchOrdersResponse < PaystackGateway::Response; end
|
|
213
|
+
|
|
214
|
+
# Error response from #fetch_orders.
|
|
215
|
+
class FetchOrdersError < ApiError; end
|
|
216
|
+
|
|
217
|
+
# https://paystack.com/docs/api/storefront/#fetch_orders
|
|
218
|
+
# Fetch Storefront Orders: GET /storefront/{id}/order
|
|
219
|
+
# Fetch all orders in your Storefront
|
|
220
|
+
#
|
|
221
|
+
# @param id [Integer] (required)
|
|
222
|
+
# The unique identifier of the Storefront
|
|
223
|
+
#
|
|
224
|
+
# @return [FetchOrdersResponse] successful response
|
|
225
|
+
# @raise [FetchOrdersError] if the request fails
|
|
226
|
+
api_method def self.fetch_orders(id:)
|
|
227
|
+
use_connection do |connection|
|
|
228
|
+
connection.get(
|
|
229
|
+
"/storefront/#{id}/order",
|
|
230
|
+
)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# Successful response from calling #list_products.
|
|
235
|
+
class ListProductsResponse < PaystackGateway::Response; end
|
|
236
|
+
|
|
237
|
+
# Error response from #list_products.
|
|
238
|
+
class ListProductsError < ApiError; end
|
|
239
|
+
|
|
240
|
+
# https://paystack.com/docs/api/storefront/#list_products
|
|
241
|
+
# List Storefront Products: GET /storefront/{id}/product
|
|
242
|
+
# List the products in a Storefront
|
|
243
|
+
#
|
|
244
|
+
# @param id [Integer] (required)
|
|
245
|
+
# The unique identifier of the Storefront
|
|
246
|
+
#
|
|
247
|
+
# @return [ListProductsResponse] successful response
|
|
248
|
+
# @raise [ListProductsError] if the request fails
|
|
249
|
+
api_method def self.list_products(id:)
|
|
250
|
+
use_connection do |connection|
|
|
251
|
+
connection.get(
|
|
252
|
+
"/storefront/#{id}/product",
|
|
253
|
+
)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Successful response from calling #add_products.
|
|
258
|
+
class AddProductsResponse < PaystackGateway::Response; end
|
|
259
|
+
|
|
260
|
+
# Error response from #add_products.
|
|
261
|
+
class AddProductsError < ApiError; end
|
|
262
|
+
|
|
263
|
+
# https://paystack.com/docs/api/storefront/#add_products
|
|
264
|
+
# Add Products to Storefront: POST /storefront/{id}/product
|
|
265
|
+
# Add previously created products to a Storefront
|
|
266
|
+
#
|
|
267
|
+
# @param id [Integer] (required)
|
|
268
|
+
# The unique identifier of the Storefront
|
|
269
|
+
# @param products [Array<Integer>] (required)
|
|
270
|
+
# An array of product IDs
|
|
271
|
+
#
|
|
272
|
+
# @return [AddProductsResponse] successful response
|
|
273
|
+
# @raise [AddProductsError] if the request fails
|
|
274
|
+
api_method def self.add_products(id:, products:)
|
|
275
|
+
use_connection do |connection|
|
|
276
|
+
connection.post(
|
|
277
|
+
"/storefront/#{id}/product",
|
|
278
|
+
{ products: }.compact,
|
|
279
|
+
)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Successful response from calling #publish.
|
|
284
|
+
class PublishResponse < PaystackGateway::Response; end
|
|
285
|
+
|
|
286
|
+
# Error response from #publish.
|
|
287
|
+
class PublishError < ApiError; end
|
|
288
|
+
|
|
289
|
+
# https://paystack.com/docs/api/storefront/#publish
|
|
290
|
+
# Publish Storefront: POST /storefront/{id}/publish
|
|
291
|
+
# Make your Storefront publicly available
|
|
292
|
+
#
|
|
293
|
+
# @param id [Integer] (required)
|
|
294
|
+
# The unique identifier of the Storefront
|
|
295
|
+
#
|
|
296
|
+
# @return [PublishResponse] successful response
|
|
297
|
+
# @raise [PublishError] if the request fails
|
|
298
|
+
api_method def self.publish(id:)
|
|
299
|
+
use_connection do |connection|
|
|
300
|
+
connection.post(
|
|
301
|
+
"/storefront/#{id}/publish",
|
|
302
|
+
)
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# Successful response from calling #duplicate.
|
|
307
|
+
class DuplicateResponse < PaystackGateway::Response; end
|
|
308
|
+
|
|
309
|
+
# Error response from #duplicate.
|
|
310
|
+
class DuplicateError < ApiError; end
|
|
311
|
+
|
|
312
|
+
# https://paystack.com/docs/api/storefront/#duplicate
|
|
313
|
+
# Duplicate Storefront: POST /storefront/{id}/duplicate
|
|
314
|
+
# Duplicate a previously created Storefront
|
|
315
|
+
#
|
|
316
|
+
# @param id [Integer] (required)
|
|
317
|
+
# The unique identifier of the Storefront
|
|
318
|
+
#
|
|
319
|
+
# @return [DuplicateResponse] successful response
|
|
320
|
+
# @raise [DuplicateError] if the request fails
|
|
321
|
+
api_method def self.duplicate(id:)
|
|
322
|
+
use_connection do |connection|
|
|
323
|
+
connection.post(
|
|
324
|
+
"/storefront/#{id}/duplicate",
|
|
325
|
+
)
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
end
|