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,259 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/order
|
|
5
|
+
#
|
|
6
|
+
# Orders
|
|
7
|
+
# A collection of endpoints for creating and managing orders
|
|
8
|
+
module Order
|
|
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/order/#list
|
|
18
|
+
# List Orders: GET /order
|
|
19
|
+
# List the previously created orders
|
|
20
|
+
#
|
|
21
|
+
# @param per_page [Integer]
|
|
22
|
+
# Number of records to fetch per page
|
|
23
|
+
# @param page [Integer]
|
|
24
|
+
# The section to retrieve
|
|
25
|
+
# @param from [Time]
|
|
26
|
+
# The start date
|
|
27
|
+
# @param to [Time]
|
|
28
|
+
# The end date
|
|
29
|
+
#
|
|
30
|
+
# @return [ListResponse] successful response
|
|
31
|
+
# @raise [ListError] if the request fails
|
|
32
|
+
api_method def self.list(per_page: nil, page: nil, from: nil, to: nil)
|
|
33
|
+
use_connection do |connection|
|
|
34
|
+
connection.get(
|
|
35
|
+
'/order',
|
|
36
|
+
{ perPage: per_page, page:, from:, to: }.compact,
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Successful response from calling #create.
|
|
42
|
+
class CreateResponse < PaystackGateway::Response
|
|
43
|
+
delegate :discounts,
|
|
44
|
+
:currency,
|
|
45
|
+
:shipping_address,
|
|
46
|
+
:integration,
|
|
47
|
+
:domain,
|
|
48
|
+
:email,
|
|
49
|
+
:customer,
|
|
50
|
+
:amount,
|
|
51
|
+
:pay_for_me,
|
|
52
|
+
:shipping,
|
|
53
|
+
:shipping_fees,
|
|
54
|
+
:metadata,
|
|
55
|
+
:order_code,
|
|
56
|
+
:refunded,
|
|
57
|
+
:is_viewed,
|
|
58
|
+
:expiration_date,
|
|
59
|
+
:id,
|
|
60
|
+
:createdAt,
|
|
61
|
+
:updatedAt,
|
|
62
|
+
:items,
|
|
63
|
+
:pay_for_me_code,
|
|
64
|
+
:discount_amount, to: :data
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Error response from #create.
|
|
68
|
+
class CreateError < ApiError; end
|
|
69
|
+
|
|
70
|
+
# https://paystack.com/docs/api/order/#create
|
|
71
|
+
# Create Order: POST /order
|
|
72
|
+
# Create an order for selected items
|
|
73
|
+
#
|
|
74
|
+
# @param email [String] (required)
|
|
75
|
+
# The email of the customer placing the order
|
|
76
|
+
# @param first_name [String] (required)
|
|
77
|
+
# The customer's first name
|
|
78
|
+
# @param last_name [String] (required)
|
|
79
|
+
# The customer's last name
|
|
80
|
+
# @param phone [String] (required)
|
|
81
|
+
# The customer's mobile number
|
|
82
|
+
# @param currency ["GHS", "KES", "NGN", "USD", "ZAR"] (required)
|
|
83
|
+
# Currency in which amount is set
|
|
84
|
+
# @param items [Array<Hash>] (required)
|
|
85
|
+
# The collection of items that make up the order
|
|
86
|
+
# @param shipping [Hash] (required)
|
|
87
|
+
# The shipping details of the order
|
|
88
|
+
# @option shipping [String] :street_line
|
|
89
|
+
# The address of for the delivery
|
|
90
|
+
# @option shipping [String] :city
|
|
91
|
+
# The city of the delivery address
|
|
92
|
+
# @option shipping [String] :state
|
|
93
|
+
# The state of the delivery address
|
|
94
|
+
# @option shipping [String] :country
|
|
95
|
+
# The country of the delivery address
|
|
96
|
+
# @option shipping [Integer] :shipping_fee
|
|
97
|
+
# The cost of delivery
|
|
98
|
+
# @option shipping [String] :delivery_note
|
|
99
|
+
# Extra details to be aware of for the delivery
|
|
100
|
+
# @param is_gift [Boolean]
|
|
101
|
+
# A flag to indicate if the order is for someone else
|
|
102
|
+
# @param pay_for_me [Boolean]
|
|
103
|
+
# A flag to indicate if the someone else should pay for the order
|
|
104
|
+
#
|
|
105
|
+
# @return [CreateResponse] successful response
|
|
106
|
+
# @raise [CreateError] if the request fails
|
|
107
|
+
api_method def self.create(
|
|
108
|
+
email:,
|
|
109
|
+
first_name:,
|
|
110
|
+
last_name:,
|
|
111
|
+
phone:,
|
|
112
|
+
currency:,
|
|
113
|
+
items:,
|
|
114
|
+
shipping:,
|
|
115
|
+
is_gift: nil,
|
|
116
|
+
pay_for_me: nil
|
|
117
|
+
)
|
|
118
|
+
use_connection do |connection|
|
|
119
|
+
connection.post(
|
|
120
|
+
'/order',
|
|
121
|
+
{
|
|
122
|
+
email:,
|
|
123
|
+
first_name:,
|
|
124
|
+
last_name:,
|
|
125
|
+
phone:,
|
|
126
|
+
currency:,
|
|
127
|
+
items:,
|
|
128
|
+
shipping:,
|
|
129
|
+
is_gift:,
|
|
130
|
+
pay_for_me:,
|
|
131
|
+
}.compact,
|
|
132
|
+
)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Successful response from calling #fetch.
|
|
137
|
+
class FetchResponse < PaystackGateway::Response
|
|
138
|
+
delegate :discounts,
|
|
139
|
+
:order_code,
|
|
140
|
+
:domain,
|
|
141
|
+
:currency,
|
|
142
|
+
:amount,
|
|
143
|
+
:email,
|
|
144
|
+
:refunded,
|
|
145
|
+
:paid_at,
|
|
146
|
+
:shipping_address,
|
|
147
|
+
:metadata,
|
|
148
|
+
:shipping_fees,
|
|
149
|
+
:shipping_method,
|
|
150
|
+
:is_viewed,
|
|
151
|
+
:expiration_date,
|
|
152
|
+
:pay_for_me,
|
|
153
|
+
:id,
|
|
154
|
+
:integration,
|
|
155
|
+
:page,
|
|
156
|
+
:customer,
|
|
157
|
+
:shipping,
|
|
158
|
+
:createdAt,
|
|
159
|
+
:updatedAt,
|
|
160
|
+
:transaction,
|
|
161
|
+
:is_gift,
|
|
162
|
+
:payer,
|
|
163
|
+
:fully_refunded,
|
|
164
|
+
:refunded_amount,
|
|
165
|
+
:items,
|
|
166
|
+
:discount_amount, to: :data
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Error response from #fetch.
|
|
170
|
+
class FetchError < ApiError; end
|
|
171
|
+
|
|
172
|
+
# https://paystack.com/docs/api/order/#fetch
|
|
173
|
+
# Fetch Order: GET /order/{id}
|
|
174
|
+
# Fetch the details of a previously created order
|
|
175
|
+
#
|
|
176
|
+
# @param id [Integer] (required)
|
|
177
|
+
# The unique identifier of the order
|
|
178
|
+
#
|
|
179
|
+
# @return [FetchResponse] successful response
|
|
180
|
+
# @raise [FetchError] if the request fails
|
|
181
|
+
api_method def self.fetch(id:)
|
|
182
|
+
use_connection do |connection|
|
|
183
|
+
connection.get(
|
|
184
|
+
"/order/#{id}",
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Successful response from calling #product.
|
|
190
|
+
class ProductResponse < PaystackGateway::Response; end
|
|
191
|
+
|
|
192
|
+
# Error response from #product.
|
|
193
|
+
class ProductError < ApiError; end
|
|
194
|
+
|
|
195
|
+
# https://paystack.com/docs/api/order/#product
|
|
196
|
+
# Fetch Product Orders: GET /order/product/{id}
|
|
197
|
+
# Fetch all orders for a particular product
|
|
198
|
+
#
|
|
199
|
+
# @param id [Integer] (required)
|
|
200
|
+
# The unique identifier of the order
|
|
201
|
+
#
|
|
202
|
+
# @return [ProductResponse] successful response
|
|
203
|
+
# @raise [ProductError] if the request fails
|
|
204
|
+
api_method def self.product(id:)
|
|
205
|
+
use_connection do |connection|
|
|
206
|
+
connection.get(
|
|
207
|
+
"/order/product/#{id}",
|
|
208
|
+
)
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Successful response from calling #validate.
|
|
213
|
+
class ValidateResponse < PaystackGateway::Response
|
|
214
|
+
delegate :order_code,
|
|
215
|
+
:domain,
|
|
216
|
+
:currency,
|
|
217
|
+
:amount,
|
|
218
|
+
:email,
|
|
219
|
+
:refunded,
|
|
220
|
+
:paid_at,
|
|
221
|
+
:shipping_address,
|
|
222
|
+
:metadata,
|
|
223
|
+
:shipping_fees,
|
|
224
|
+
:shipping_method,
|
|
225
|
+
:is_viewed,
|
|
226
|
+
:expiration_date,
|
|
227
|
+
:pay_for_me,
|
|
228
|
+
:id,
|
|
229
|
+
:integration,
|
|
230
|
+
:transaction,
|
|
231
|
+
:page,
|
|
232
|
+
:customer,
|
|
233
|
+
:shipping,
|
|
234
|
+
:createdAt,
|
|
235
|
+
:updatedAt,
|
|
236
|
+
:payer, to: :data
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Error response from #validate.
|
|
240
|
+
class ValidateError < ApiError; end
|
|
241
|
+
|
|
242
|
+
# https://paystack.com/docs/api/order/#validate
|
|
243
|
+
# Validate Order: GET /order/{code}/validate
|
|
244
|
+
# Validate a pay for me order
|
|
245
|
+
#
|
|
246
|
+
# @param code [String] (required)
|
|
247
|
+
# The unique code of a previously created order
|
|
248
|
+
#
|
|
249
|
+
# @return [ValidateResponse] successful response
|
|
250
|
+
# @raise [ValidateError] if the request fails
|
|
251
|
+
api_method def self.validate(code:)
|
|
252
|
+
use_connection do |connection|
|
|
253
|
+
connection.get(
|
|
254
|
+
"/order/#{code}/validate",
|
|
255
|
+
)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/page
|
|
5
|
+
#
|
|
6
|
+
# Payment Pages
|
|
7
|
+
# A collection of endpoints for creating and managing links for the collection of payment for products
|
|
8
|
+
module Page
|
|
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/page/#list
|
|
18
|
+
# List Pages: GET /page
|
|
19
|
+
# List all previously created payment pages
|
|
20
|
+
#
|
|
21
|
+
# @param per_page [Integer]
|
|
22
|
+
# Number of records to fetch per page
|
|
23
|
+
# @param page [Integer]
|
|
24
|
+
# The section to retrieve
|
|
25
|
+
# @param from [Time]
|
|
26
|
+
# The start date
|
|
27
|
+
# @param to [Time]
|
|
28
|
+
# The end date
|
|
29
|
+
#
|
|
30
|
+
# @return [ListResponse] successful response
|
|
31
|
+
# @raise [ListError] if the request fails
|
|
32
|
+
api_method def self.list(per_page: nil, page: nil, from: nil, to: nil)
|
|
33
|
+
use_connection do |connection|
|
|
34
|
+
connection.get(
|
|
35
|
+
'/page',
|
|
36
|
+
{ perPage: per_page, page:, from:, to: }.compact,
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Successful response from calling #create.
|
|
42
|
+
class CreateResponse < PaystackGateway::Response
|
|
43
|
+
delegate :name,
|
|
44
|
+
:integration,
|
|
45
|
+
:domain,
|
|
46
|
+
:slug,
|
|
47
|
+
:currency,
|
|
48
|
+
:type,
|
|
49
|
+
:collect_phone,
|
|
50
|
+
:active,
|
|
51
|
+
:published,
|
|
52
|
+
:migrate,
|
|
53
|
+
:id,
|
|
54
|
+
:createdAt,
|
|
55
|
+
:updatedAt, to: :data
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Error response from #create.
|
|
59
|
+
class CreateError < ApiError; end
|
|
60
|
+
|
|
61
|
+
# https://paystack.com/docs/api/page/#create
|
|
62
|
+
# Create Page: POST /page
|
|
63
|
+
# Create a webpage to receive payments
|
|
64
|
+
#
|
|
65
|
+
# @param name [String] (required)
|
|
66
|
+
# Name of page
|
|
67
|
+
# @param description [String]
|
|
68
|
+
# The description of the page
|
|
69
|
+
# @param amount [Integer]
|
|
70
|
+
# Amount should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents,
|
|
71
|
+
# if currency is ZAR
|
|
72
|
+
# @param currency ["NGN", "GHS", "ZAR", "KES", "USD"]
|
|
73
|
+
# The transaction currency. Defaults to your integration currency.
|
|
74
|
+
# @param slug [String]
|
|
75
|
+
# URL slug you would like to be associated with this page. Page will be accessible
|
|
76
|
+
# at `https://paystack.com/pay/[slug]`
|
|
77
|
+
# @param type ["payment", "subscription", "product", "plan"]
|
|
78
|
+
# The type of payment page to create. Defaults to `payment` if no type is specified.
|
|
79
|
+
# @param plan [String]
|
|
80
|
+
# The ID of the plan to subscribe customers on this payment page to when `type` is
|
|
81
|
+
# set to `subscription`.
|
|
82
|
+
# @param fixed_amount [Boolean]
|
|
83
|
+
# Specifies whether to collect a fixed amount on the payment page. If true, `amount`
|
|
84
|
+
# must be passed.
|
|
85
|
+
# @param split_code [String]
|
|
86
|
+
# The split code of the transaction split. e.g. `SPL_98WF13Eb3w`
|
|
87
|
+
# @param metadata [Hash]
|
|
88
|
+
# JSON object of custom data
|
|
89
|
+
# @param redirect_url [String]
|
|
90
|
+
# If you would like Paystack to redirect to a URL upon successful payment, specify
|
|
91
|
+
# the URL here.
|
|
92
|
+
# @param success_message [String]
|
|
93
|
+
# A success message to display to the customer after a successful transaction
|
|
94
|
+
# @param notification_email [String]
|
|
95
|
+
# An email address that will receive transaction notifications for this payment page
|
|
96
|
+
# @param collect_phone [Boolean]
|
|
97
|
+
# Specify whether to collect phone numbers on the payment page
|
|
98
|
+
# @param custom_fields [Array<Hash>]
|
|
99
|
+
# If you would like to accept custom fields, specify them here.
|
|
100
|
+
#
|
|
101
|
+
# @return [CreateResponse] successful response
|
|
102
|
+
# @raise [CreateError] if the request fails
|
|
103
|
+
api_method def self.create(
|
|
104
|
+
name:,
|
|
105
|
+
description: nil,
|
|
106
|
+
amount: nil,
|
|
107
|
+
currency: nil,
|
|
108
|
+
slug: nil,
|
|
109
|
+
type: nil,
|
|
110
|
+
plan: nil,
|
|
111
|
+
fixed_amount: nil,
|
|
112
|
+
split_code: nil,
|
|
113
|
+
metadata: nil,
|
|
114
|
+
redirect_url: nil,
|
|
115
|
+
success_message: nil,
|
|
116
|
+
notification_email: nil,
|
|
117
|
+
collect_phone: nil,
|
|
118
|
+
custom_fields: nil
|
|
119
|
+
)
|
|
120
|
+
use_connection do |connection|
|
|
121
|
+
connection.post(
|
|
122
|
+
'/page',
|
|
123
|
+
{
|
|
124
|
+
name:,
|
|
125
|
+
description:,
|
|
126
|
+
amount:,
|
|
127
|
+
currency:,
|
|
128
|
+
slug:,
|
|
129
|
+
type:,
|
|
130
|
+
plan:,
|
|
131
|
+
fixed_amount:,
|
|
132
|
+
split_code:,
|
|
133
|
+
metadata:,
|
|
134
|
+
redirect_url:,
|
|
135
|
+
success_message:,
|
|
136
|
+
notification_email:,
|
|
137
|
+
collect_phone:,
|
|
138
|
+
custom_fields:,
|
|
139
|
+
}.compact,
|
|
140
|
+
)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Successful response from calling #fetch.
|
|
145
|
+
class FetchResponse < PaystackGateway::Response
|
|
146
|
+
delegate :integration,
|
|
147
|
+
:domain,
|
|
148
|
+
:name,
|
|
149
|
+
:description,
|
|
150
|
+
:amount,
|
|
151
|
+
:currency,
|
|
152
|
+
:slug,
|
|
153
|
+
:custom_fields,
|
|
154
|
+
:type,
|
|
155
|
+
:redirect_url,
|
|
156
|
+
:success_message,
|
|
157
|
+
:collect_phone,
|
|
158
|
+
:active,
|
|
159
|
+
:published,
|
|
160
|
+
:migrate,
|
|
161
|
+
:notification_email,
|
|
162
|
+
:metadata,
|
|
163
|
+
:split_code,
|
|
164
|
+
:id,
|
|
165
|
+
:createdAt,
|
|
166
|
+
:updatedAt, to: :data
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Error response from #fetch.
|
|
170
|
+
class FetchError < ApiError; end
|
|
171
|
+
|
|
172
|
+
# https://paystack.com/docs/api/page/#fetch
|
|
173
|
+
# Fetch Page: GET /page/{id}
|
|
174
|
+
# Get a previously created payment page
|
|
175
|
+
#
|
|
176
|
+
# @param id [Integer] (required)
|
|
177
|
+
# The unique identifier of a payment page
|
|
178
|
+
#
|
|
179
|
+
# @return [FetchResponse] successful response
|
|
180
|
+
# @raise [FetchError] if the request fails
|
|
181
|
+
api_method def self.fetch(id:)
|
|
182
|
+
use_connection do |connection|
|
|
183
|
+
connection.get(
|
|
184
|
+
"/page/#{id}",
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Successful response from calling #update.
|
|
190
|
+
class UpdateResponse < PaystackGateway::Response
|
|
191
|
+
delegate :domain,
|
|
192
|
+
:name,
|
|
193
|
+
:description,
|
|
194
|
+
:amount,
|
|
195
|
+
:currency,
|
|
196
|
+
:slug,
|
|
197
|
+
:custom_fields,
|
|
198
|
+
:type,
|
|
199
|
+
:redirect_url,
|
|
200
|
+
:success_message,
|
|
201
|
+
:collect_phone,
|
|
202
|
+
:active,
|
|
203
|
+
:published,
|
|
204
|
+
:migrate,
|
|
205
|
+
:notification_email,
|
|
206
|
+
:metadata,
|
|
207
|
+
:split_code,
|
|
208
|
+
:id,
|
|
209
|
+
:integration,
|
|
210
|
+
:plan,
|
|
211
|
+
:createdAt,
|
|
212
|
+
:updatedAt, to: :data
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Error response from #update.
|
|
216
|
+
class UpdateError < ApiError; end
|
|
217
|
+
|
|
218
|
+
# https://paystack.com/docs/api/page/#update
|
|
219
|
+
# Update Page: PUT /page/{id}
|
|
220
|
+
# Update a previously created payment page
|
|
221
|
+
#
|
|
222
|
+
# @param id [Integer] (required)
|
|
223
|
+
# The unique identifier of a payment page
|
|
224
|
+
# @param name [String]
|
|
225
|
+
# Name of page
|
|
226
|
+
# @param description [String]
|
|
227
|
+
# The description of the page
|
|
228
|
+
# @param amount [Integer]
|
|
229
|
+
# Amount should be in the subunit of the currency
|
|
230
|
+
# @param active [Boolean]
|
|
231
|
+
# Set to false to deactivate page url
|
|
232
|
+
#
|
|
233
|
+
# @return [UpdateResponse] successful response
|
|
234
|
+
# @raise [UpdateError] if the request fails
|
|
235
|
+
api_method def self.update(id:, name: nil, description: nil, amount: nil, active: nil)
|
|
236
|
+
use_connection do |connection|
|
|
237
|
+
connection.put(
|
|
238
|
+
"/page/#{id}",
|
|
239
|
+
{ name:, description:, amount:, active: }.compact,
|
|
240
|
+
)
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# Successful response from calling #check_slug_availability.
|
|
245
|
+
class CheckSlugAvailabilityResponse < PaystackGateway::Response; end
|
|
246
|
+
|
|
247
|
+
# Error response from #check_slug_availability.
|
|
248
|
+
class CheckSlugAvailabilityError < ApiError; end
|
|
249
|
+
|
|
250
|
+
# https://paystack.com/docs/api/page/#check_slug_availability
|
|
251
|
+
# Check Slug Availability: GET /page/check_slug_availability/{slug}
|
|
252
|
+
# Check if a custom slug is available for use when creating a payment page
|
|
253
|
+
#
|
|
254
|
+
# @param slug [String] (required)
|
|
255
|
+
# The custom slug to check
|
|
256
|
+
#
|
|
257
|
+
# @return [CheckSlugAvailabilityResponse] successful response
|
|
258
|
+
# @raise [CheckSlugAvailabilityError] if the request fails
|
|
259
|
+
api_method def self.check_slug_availability(slug:)
|
|
260
|
+
use_connection do |connection|
|
|
261
|
+
connection.get(
|
|
262
|
+
"/page/check_slug_availability/#{slug}",
|
|
263
|
+
)
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Successful response from calling #add_products.
|
|
268
|
+
class AddProductsResponse < PaystackGateway::Response
|
|
269
|
+
delegate :integration,
|
|
270
|
+
:plan,
|
|
271
|
+
:domain,
|
|
272
|
+
:name,
|
|
273
|
+
:description,
|
|
274
|
+
:amount,
|
|
275
|
+
:currency,
|
|
276
|
+
:slug,
|
|
277
|
+
:custom_fields,
|
|
278
|
+
:type,
|
|
279
|
+
:redirect_url,
|
|
280
|
+
:success_message,
|
|
281
|
+
:collect_phone,
|
|
282
|
+
:active,
|
|
283
|
+
:published,
|
|
284
|
+
:migrate,
|
|
285
|
+
:notification_email,
|
|
286
|
+
:metadata,
|
|
287
|
+
:split_code,
|
|
288
|
+
:id,
|
|
289
|
+
:createdAt,
|
|
290
|
+
:updatedAt,
|
|
291
|
+
:products, to: :data
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Error response from #add_products.
|
|
295
|
+
class AddProductsError < ApiError; end
|
|
296
|
+
|
|
297
|
+
# https://paystack.com/docs/api/page/#add_products
|
|
298
|
+
# Add Products: POST /page/{id}/product
|
|
299
|
+
# Add products to a previously created payment page. You can only add products to
|
|
300
|
+
# pages that was created with a `product` type.
|
|
301
|
+
#
|
|
302
|
+
# @param id [String] (required)
|
|
303
|
+
# @param products [Array<Integer>] (required)
|
|
304
|
+
# A list of IDs of products to add to a page.
|
|
305
|
+
#
|
|
306
|
+
# @return [AddProductsResponse] successful response
|
|
307
|
+
# @raise [AddProductsError] if the request fails
|
|
308
|
+
api_method def self.add_products(id:, products:)
|
|
309
|
+
use_connection do |connection|
|
|
310
|
+
connection.post(
|
|
311
|
+
"/page/#{id}/product",
|
|
312
|
+
{ products: }.compact,
|
|
313
|
+
)
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|