paystack_sdk 0.2.0 → 0.3.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/CHANGELOG.md +20 -0
- data/README.md +469 -0
- data/lib/paystack_sdk/client.rb +81 -0
- data/lib/paystack_sdk/resources/balances.rb +56 -0
- data/lib/paystack_sdk/resources/customers.rb +2 -2
- data/lib/paystack_sdk/resources/dedicated_virtual_accounts.rb +241 -0
- data/lib/paystack_sdk/resources/disputes.rb +237 -0
- data/lib/paystack_sdk/resources/payment_requests.rb +285 -0
- data/lib/paystack_sdk/resources/plans.rb +188 -0
- data/lib/paystack_sdk/resources/settlements.rb +51 -0
- data/lib/paystack_sdk/resources/splits.rb +186 -0
- data/lib/paystack_sdk/resources/subaccounts.rb +156 -0
- data/lib/paystack_sdk/resources/subscriptions.rb +161 -0
- data/lib/paystack_sdk/version.rb +1 -1
- metadata +10 -1
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
|
|
4
|
+
# Do not edit by hand: regenerate it with `bin/paystack-scaffold Payment Request`. Hand-written extras go in lib/paystack_sdk/resources/extensions/payment_requests.rb.
|
|
5
|
+
# scaffold-digest: 884176d0fce2f23befd4655d04efd15b5dccf6808f496f41b09e0afcd43c1e73
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Payment Request operations.
|
|
12
|
+
class PaymentRequests < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage", customer_id: "customer"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Payment Request.
|
|
17
|
+
#
|
|
18
|
+
# List all previously created payment requests to your customers
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] Number of records to fetch per page
|
|
21
|
+
# @param page [Integer] The section to retrieve
|
|
22
|
+
# @param customer_id [Integer] Customer ID
|
|
23
|
+
# @param status [String] Invoice status to filter One of: draft, pending, success, failed.
|
|
24
|
+
# @param currency [String] If your integration supports more than one currency, choose the one to filter
|
|
25
|
+
# @param from [String] The start date
|
|
26
|
+
# @param to [String] The end date
|
|
27
|
+
# @param include_archive [Boolean] Pass true to include archived payment requests.
|
|
28
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
29
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
30
|
+
# @see https://paystack.com/docs/api/payment-request/#list
|
|
31
|
+
def list(
|
|
32
|
+
per_page: nil,
|
|
33
|
+
page: nil,
|
|
34
|
+
customer_id: nil,
|
|
35
|
+
status: nil,
|
|
36
|
+
currency: nil,
|
|
37
|
+
from: nil,
|
|
38
|
+
to: nil,
|
|
39
|
+
include_archive: nil
|
|
40
|
+
)
|
|
41
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
42
|
+
validate_positive_integer!(value: page, name: "page")
|
|
43
|
+
validate_allowed_values!(
|
|
44
|
+
value: status,
|
|
45
|
+
allowed_values: %w[draft pending success failed],
|
|
46
|
+
name: "status"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
wire_query = to_wire(
|
|
50
|
+
{
|
|
51
|
+
per_page:,
|
|
52
|
+
page:,
|
|
53
|
+
customer_id:,
|
|
54
|
+
status:,
|
|
55
|
+
currency:,
|
|
56
|
+
from: format_datetime(from, name: "from"),
|
|
57
|
+
to: format_datetime(to, name: "to"),
|
|
58
|
+
include_archive:
|
|
59
|
+
},
|
|
60
|
+
WIRE_NAMES
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
handle_response(@connection.get("/paymentrequest", wire_query))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Create Payment Request.
|
|
67
|
+
#
|
|
68
|
+
# Create a new payment request by issuing an invoice to a customer
|
|
69
|
+
#
|
|
70
|
+
# @param customer [String] Customer id or code
|
|
71
|
+
# @param amount [Integer] The amount in the subunit.
|
|
72
|
+
# @param currency [String] Specify the currency of the invoice.
|
|
73
|
+
# @param due_date [String] ISO 8601 date or date-time the request is due, for example 2026-12-31 or 2026-12-31T23:00:00Z.
|
|
74
|
+
# @param description [String] A short description of the payment request
|
|
75
|
+
# @param line_items [Array] Line items, each a Hash such as {name: "item 1", amount: 2000, quantity: 1} (amount in the subunit).
|
|
76
|
+
# @param tax [Array] Taxes, each a Hash such as {name: "VAT", amount: 2000} (amount in the subunit).
|
|
77
|
+
# @param send_notification [Boolean] Indicates whether Paystack sends an email notification to customer.
|
|
78
|
+
# @param draft [Boolean] Indicate if request should be saved as draft.
|
|
79
|
+
# @param has_invoice [Boolean] Set to true to create a draft invoice (adds an auto incrementing invoice number if none is provided) even if there are no line_items or tax passed
|
|
80
|
+
# @param invoice_number [Integer] Numeric value of invoice.
|
|
81
|
+
# @param split_code [String] The split code of the transaction split.
|
|
82
|
+
# @param metadata [Hash] A Hash of custom data, stored on the payment request.
|
|
83
|
+
# @param redirect_url [String] A URL for Paystack to redirect to after a successful payment.
|
|
84
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
85
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
86
|
+
# @see https://paystack.com/docs/api/payment-request/#create
|
|
87
|
+
def create(
|
|
88
|
+
customer:,
|
|
89
|
+
amount: nil,
|
|
90
|
+
currency: nil,
|
|
91
|
+
due_date: nil,
|
|
92
|
+
description: nil,
|
|
93
|
+
line_items: nil,
|
|
94
|
+
tax: nil,
|
|
95
|
+
send_notification: nil,
|
|
96
|
+
draft: nil,
|
|
97
|
+
has_invoice: nil,
|
|
98
|
+
invoice_number: nil,
|
|
99
|
+
split_code: nil,
|
|
100
|
+
metadata: nil,
|
|
101
|
+
redirect_url: nil
|
|
102
|
+
)
|
|
103
|
+
validate_presence!(value: customer, name: "customer")
|
|
104
|
+
validate_positive_integer!(value: amount, name: "amount")
|
|
105
|
+
|
|
106
|
+
wire_body = to_wire(
|
|
107
|
+
{
|
|
108
|
+
customer:,
|
|
109
|
+
amount:,
|
|
110
|
+
currency:,
|
|
111
|
+
due_date: format_datetime(due_date, name: "due_date"),
|
|
112
|
+
description:,
|
|
113
|
+
line_items:,
|
|
114
|
+
tax:,
|
|
115
|
+
send_notification:,
|
|
116
|
+
draft:,
|
|
117
|
+
has_invoice:,
|
|
118
|
+
invoice_number:,
|
|
119
|
+
split_code:,
|
|
120
|
+
metadata:,
|
|
121
|
+
redirect_url:
|
|
122
|
+
},
|
|
123
|
+
WIRE_NAMES
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
handle_response(@connection.post("/paymentrequest", wire_body))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Fetch Payment Request.
|
|
130
|
+
#
|
|
131
|
+
# Fetch a previously created payment request
|
|
132
|
+
#
|
|
133
|
+
# @param id_or_code [String] The unique identifier of a previously created payment request
|
|
134
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
135
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
136
|
+
# @see https://paystack.com/docs/api/payment-request/#fetch
|
|
137
|
+
def fetch(id_or_code:)
|
|
138
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
139
|
+
|
|
140
|
+
handle_response(
|
|
141
|
+
@connection.get("/paymentrequest/#{escape_path(id_or_code, name: "id_or_code")}")
|
|
142
|
+
)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Update Payment Request.
|
|
146
|
+
#
|
|
147
|
+
# Update a previously created payment request
|
|
148
|
+
#
|
|
149
|
+
# @param id_or_code [String] The unique identifier of a previously created payment request
|
|
150
|
+
# @param customer [String] Customer id or code
|
|
151
|
+
# @param amount [Integer] Payment request amount.
|
|
152
|
+
# @param currency [String] Specify the currency of the invoice.
|
|
153
|
+
# @param due_date [String] ISO 8601 date or date-time the request is due, for example 2026-12-31 or 2026-12-31T23:00:00Z.
|
|
154
|
+
# @param description [String] A short description of the payment request
|
|
155
|
+
# @param line_items [Array] Line items, each a Hash such as {name: "item 1", amount: 2000, quantity: 1} (amount in the subunit).
|
|
156
|
+
# @param tax [Array] Taxes, each a Hash such as {name: "VAT", amount: 2000} (amount in the subunit).
|
|
157
|
+
# @param send_notification [Boolean] Indicates whether Paystack sends an email notification to customer.
|
|
158
|
+
# @param draft [Boolean] Indicate if request should be saved as draft.
|
|
159
|
+
# @param has_invoice [Boolean] Set to true to create a draft invoice (adds an auto incrementing invoice number if none is provided) even if there are no line_items or tax passed
|
|
160
|
+
# @param invoice_number [Integer] Numeric value of invoice.
|
|
161
|
+
# @param split_code [String] The split code of the transaction split.
|
|
162
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
163
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
164
|
+
# @see https://paystack.com/docs/api/payment-request/#update
|
|
165
|
+
def update(
|
|
166
|
+
id_or_code:,
|
|
167
|
+
customer: nil,
|
|
168
|
+
amount: nil,
|
|
169
|
+
currency: nil,
|
|
170
|
+
due_date: nil,
|
|
171
|
+
description: nil,
|
|
172
|
+
line_items: nil,
|
|
173
|
+
tax: nil,
|
|
174
|
+
send_notification: nil,
|
|
175
|
+
draft: nil,
|
|
176
|
+
has_invoice: nil,
|
|
177
|
+
invoice_number: nil,
|
|
178
|
+
split_code: nil
|
|
179
|
+
)
|
|
180
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
181
|
+
validate_positive_integer!(value: amount, name: "amount")
|
|
182
|
+
|
|
183
|
+
wire_body = to_wire(
|
|
184
|
+
{
|
|
185
|
+
customer:,
|
|
186
|
+
amount:,
|
|
187
|
+
currency:,
|
|
188
|
+
due_date: format_datetime(due_date, name: "due_date"),
|
|
189
|
+
description:,
|
|
190
|
+
line_items:,
|
|
191
|
+
tax:,
|
|
192
|
+
send_notification:,
|
|
193
|
+
draft:,
|
|
194
|
+
has_invoice:,
|
|
195
|
+
invoice_number:,
|
|
196
|
+
split_code:
|
|
197
|
+
},
|
|
198
|
+
WIRE_NAMES
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
handle_response(
|
|
202
|
+
@connection.put("/paymentrequest/#{escape_path(id_or_code, name: "id_or_code")}", wire_body)
|
|
203
|
+
)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Verify Payment Request.
|
|
207
|
+
#
|
|
208
|
+
# Verify the status of a previously created payment request
|
|
209
|
+
#
|
|
210
|
+
# @param code [String] The unique identifier of a previously created payment request
|
|
211
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
212
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
213
|
+
# @see https://paystack.com/docs/api/payment-request/#verify
|
|
214
|
+
def verify(code:)
|
|
215
|
+
validate_presence!(value: code, name: "code")
|
|
216
|
+
|
|
217
|
+
handle_response(
|
|
218
|
+
@connection.get("/paymentrequest/verify/#{escape_path(code, name: "code")}")
|
|
219
|
+
)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Send Notification.
|
|
223
|
+
#
|
|
224
|
+
# Trigger an email reminder to a customer for a previously created payment request
|
|
225
|
+
#
|
|
226
|
+
# @param code [String] The unique identifier of a previously created payment request
|
|
227
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
228
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
229
|
+
# @see https://paystack.com/docs/api/payment-request/#send-notification
|
|
230
|
+
def notify(code:)
|
|
231
|
+
validate_presence!(value: code, name: "code")
|
|
232
|
+
|
|
233
|
+
handle_response(
|
|
234
|
+
@connection.post("/paymentrequest/notify/#{escape_path(code, name: "code")}")
|
|
235
|
+
)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Payment Request Total.
|
|
239
|
+
#
|
|
240
|
+
# Get the metric of all pending and successful payment requests
|
|
241
|
+
#
|
|
242
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
243
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
244
|
+
# @see https://paystack.com/docs/api/payment-request/#total
|
|
245
|
+
def totals
|
|
246
|
+
handle_response(@connection.get("/paymentrequest/totals"))
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Finalize Payment Request.
|
|
250
|
+
#
|
|
251
|
+
# Finalise the creation of a draft payment request for a customer
|
|
252
|
+
#
|
|
253
|
+
# @param id_or_code [String] The unique identifier of a draft payment request
|
|
254
|
+
# @param send_notification [Boolean] Whether Paystack emails the customer; defaults to true.
|
|
255
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
256
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
257
|
+
# @see https://paystack.com/docs/api/payment-request/#finalize
|
|
258
|
+
def finalize(id_or_code:, send_notification: nil)
|
|
259
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
260
|
+
|
|
261
|
+
wire_body = to_wire({send_notification:}, WIRE_NAMES)
|
|
262
|
+
|
|
263
|
+
handle_response(
|
|
264
|
+
@connection.post("/paymentrequest/finalize/#{escape_path(id_or_code, name: "id_or_code")}", wire_body)
|
|
265
|
+
)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Archive Payment Request.
|
|
269
|
+
#
|
|
270
|
+
# Archive a payment request to clean up your records.
|
|
271
|
+
#
|
|
272
|
+
# @param id_or_code [String] The unique identifier of a previously created payment request
|
|
273
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
274
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
275
|
+
# @see https://paystack.com/docs/api/payment-request/#archive
|
|
276
|
+
def archive(id_or_code:)
|
|
277
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
278
|
+
|
|
279
|
+
handle_response(
|
|
280
|
+
@connection.post("/paymentrequest/archive/#{escape_path(id_or_code, name: "id_or_code")}")
|
|
281
|
+
)
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
|
|
4
|
+
# Do not edit by hand: regenerate it with `bin/paystack-scaffold Plan`. Hand-written extras go in lib/paystack_sdk/resources/extensions/plans.rb.
|
|
5
|
+
# scaffold-digest: 68769f801c1b9e113bc52707375e9ffd37cf248629d9454a18c3d690571e9996
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Plan operations.
|
|
12
|
+
class Plans < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Plans.
|
|
17
|
+
#
|
|
18
|
+
# List all recurring payment plans
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] Number of records to fetch per page
|
|
21
|
+
# @param page [Integer] The section to retrieve
|
|
22
|
+
# @param interval [String] Specify interval of the plan One of: hourly, daily, weekly, monthly, quarterly, biannually, annually.
|
|
23
|
+
# @param amount [Integer] The amount on the plans to retrieve
|
|
24
|
+
# @param from [String] The start date
|
|
25
|
+
# @param to [String] The end date
|
|
26
|
+
# @param status [String] Filter list by plans with specified status.
|
|
27
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
28
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
29
|
+
# @see https://paystack.com/docs/api/plan/#list
|
|
30
|
+
def list(
|
|
31
|
+
per_page: nil,
|
|
32
|
+
page: nil,
|
|
33
|
+
interval: nil,
|
|
34
|
+
amount: nil,
|
|
35
|
+
from: nil,
|
|
36
|
+
to: nil,
|
|
37
|
+
status: nil
|
|
38
|
+
)
|
|
39
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
40
|
+
validate_positive_integer!(value: page, name: "page")
|
|
41
|
+
validate_allowed_values!(
|
|
42
|
+
value: interval,
|
|
43
|
+
allowed_values: %w[hourly daily weekly monthly quarterly biannually annually],
|
|
44
|
+
name: "interval"
|
|
45
|
+
)
|
|
46
|
+
validate_positive_integer!(value: amount, name: "amount")
|
|
47
|
+
|
|
48
|
+
wire_query = to_wire(
|
|
49
|
+
{
|
|
50
|
+
per_page:,
|
|
51
|
+
page:,
|
|
52
|
+
interval:,
|
|
53
|
+
amount:,
|
|
54
|
+
from: format_datetime(from, name: "from"),
|
|
55
|
+
to: format_datetime(to, name: "to"),
|
|
56
|
+
status:
|
|
57
|
+
},
|
|
58
|
+
WIRE_NAMES
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
handle_response(@connection.get("/plan", wire_query))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Create Plan.
|
|
65
|
+
#
|
|
66
|
+
# Create a plan for recurring payments
|
|
67
|
+
#
|
|
68
|
+
# @param name [String] Name of plan
|
|
69
|
+
# @param amount [Integer] Amount should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR
|
|
70
|
+
# @param interval [String] Payment interval One of: hourly, daily, weekly, monthly, quarterly, biannually, annually.
|
|
71
|
+
# @param description [String] A description for this plan
|
|
72
|
+
# @param send_invoices [Boolean] Set to false if you don't want invoices to be sent to your customers
|
|
73
|
+
# @param send_sms [Boolean] Set to false if you don't want text messages to be sent to your customers
|
|
74
|
+
# @param currency [String] Currency in which amount is set.
|
|
75
|
+
# @param invoice_limit [Integer] Number of invoices to raise during subscription to this plan.
|
|
76
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
77
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
78
|
+
# @see https://paystack.com/docs/api/plan/#create
|
|
79
|
+
def create(
|
|
80
|
+
name:,
|
|
81
|
+
amount:,
|
|
82
|
+
interval:,
|
|
83
|
+
description: nil,
|
|
84
|
+
send_invoices: nil,
|
|
85
|
+
send_sms: nil,
|
|
86
|
+
currency: nil,
|
|
87
|
+
invoice_limit: nil
|
|
88
|
+
)
|
|
89
|
+
validate_presence!(value: name, name: "name")
|
|
90
|
+
validate_presence!(value: amount, name: "amount")
|
|
91
|
+
validate_positive_integer!(value: amount, name: "amount")
|
|
92
|
+
validate_presence!(value: interval, name: "interval")
|
|
93
|
+
validate_allowed_values!(
|
|
94
|
+
value: interval,
|
|
95
|
+
allowed_values: %w[hourly daily weekly monthly quarterly biannually annually],
|
|
96
|
+
name: "interval"
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
wire_body = to_wire(
|
|
100
|
+
{
|
|
101
|
+
name:,
|
|
102
|
+
amount:,
|
|
103
|
+
interval:,
|
|
104
|
+
description:,
|
|
105
|
+
send_invoices:,
|
|
106
|
+
send_sms:,
|
|
107
|
+
currency:,
|
|
108
|
+
invoice_limit:
|
|
109
|
+
},
|
|
110
|
+
WIRE_NAMES
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
handle_response(@connection.post("/plan", wire_body))
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Fetch Plan.
|
|
117
|
+
#
|
|
118
|
+
# Get the details of a payment plan
|
|
119
|
+
#
|
|
120
|
+
# @param id_or_code [String] The plan code you want to fetch
|
|
121
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
122
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
123
|
+
# @see https://paystack.com/docs/api/plan/#fetch
|
|
124
|
+
def fetch(id_or_code:)
|
|
125
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
126
|
+
|
|
127
|
+
handle_response(@connection.get("/plan/#{escape_path(id_or_code, name: "id_or_code")}"))
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Update Plan.
|
|
131
|
+
#
|
|
132
|
+
# Update a plan details on your integration
|
|
133
|
+
#
|
|
134
|
+
# @param id_or_code [String] The plan code you want to fetch
|
|
135
|
+
# @param name [String] Name of plan
|
|
136
|
+
# @param amount [Integer] Amount should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR
|
|
137
|
+
# @param interval [String] Payment interval One of: hourly, daily, weekly, monthly, quarterly, biannually, annually.
|
|
138
|
+
# @param description [String] A description for this plan
|
|
139
|
+
# @param send_invoices [Boolean] Set to false if you don't want invoices to be sent to your customers
|
|
140
|
+
# @param send_sms [Boolean] Set to false if you don't want text messages to be sent to your customers
|
|
141
|
+
# @param currency [String] Currency in which amount is set.
|
|
142
|
+
# @param invoice_limit [Integer] Number of invoices to raise during subscription to this plan.
|
|
143
|
+
# @param update_existing_subscriptions [Boolean] Set to true if you want the existing subscriptions to use the new changes.
|
|
144
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
145
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
146
|
+
# @see https://paystack.com/docs/api/plan/#update
|
|
147
|
+
def update(
|
|
148
|
+
id_or_code:,
|
|
149
|
+
name: nil,
|
|
150
|
+
amount: nil,
|
|
151
|
+
interval: nil,
|
|
152
|
+
description: nil,
|
|
153
|
+
send_invoices: nil,
|
|
154
|
+
send_sms: nil,
|
|
155
|
+
currency: nil,
|
|
156
|
+
invoice_limit: nil,
|
|
157
|
+
update_existing_subscriptions: nil
|
|
158
|
+
)
|
|
159
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
160
|
+
validate_positive_integer!(value: amount, name: "amount")
|
|
161
|
+
validate_allowed_values!(
|
|
162
|
+
value: interval,
|
|
163
|
+
allowed_values: %w[hourly daily weekly monthly quarterly biannually annually],
|
|
164
|
+
name: "interval"
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
wire_body = to_wire(
|
|
168
|
+
{
|
|
169
|
+
name:,
|
|
170
|
+
amount:,
|
|
171
|
+
interval:,
|
|
172
|
+
description:,
|
|
173
|
+
send_invoices:,
|
|
174
|
+
send_sms:,
|
|
175
|
+
currency:,
|
|
176
|
+
invoice_limit:,
|
|
177
|
+
update_existing_subscriptions:
|
|
178
|
+
},
|
|
179
|
+
WIRE_NAMES
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
handle_response(
|
|
183
|
+
@connection.put("/plan/#{escape_path(id_or_code, name: "id_or_code")}", wire_body)
|
|
184
|
+
)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
|
|
4
|
+
# Do not edit by hand: regenerate it with `bin/paystack-scaffold Settlement`. Hand-written extras go in lib/paystack_sdk/resources/extensions/settlements.rb.
|
|
5
|
+
# scaffold-digest: 026436fb32768e6f2bdba729240aead9977fafe0b99448bb269f1b4429634d78
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Settlement operations.
|
|
12
|
+
class Settlements < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Settlements.
|
|
17
|
+
#
|
|
18
|
+
# List settlements made to your settlement accounts
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] The number of records to fetch per request
|
|
21
|
+
# @param page [Integer] The offset to retrieve data from
|
|
22
|
+
# @param from [String] A timestamp from which to start listing settlements, for example 2016-09-24T00:00:05.000Z or 2016-09-21.
|
|
23
|
+
# @param to [String] A timestamp at which to stop listing settlements, for example 2016-09-24T00:00:05.000Z or 2016-09-21.
|
|
24
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
25
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
26
|
+
# @see https://paystack.com/docs/api/settlement/#list
|
|
27
|
+
def list(per_page: nil, page: nil, from: nil, to: nil)
|
|
28
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
29
|
+
validate_positive_integer!(value: page, name: "page")
|
|
30
|
+
|
|
31
|
+
wire_query = to_wire({per_page:, page:, from:, to:}, WIRE_NAMES)
|
|
32
|
+
|
|
33
|
+
handle_response(@connection.get("/settlement", wire_query))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Fetch Settlement Transactions.
|
|
37
|
+
#
|
|
38
|
+
# Get the transactions that make up a particular settlement
|
|
39
|
+
#
|
|
40
|
+
# @param id [Integer] The settlement ID in which you want to fetch its transactions
|
|
41
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
42
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
43
|
+
# @see https://paystack.com/docs/api/settlement/#transactions
|
|
44
|
+
def transactions(id:)
|
|
45
|
+
validate_presence!(value: id, name: "id")
|
|
46
|
+
|
|
47
|
+
handle_response(@connection.get("/settlement/#{escape_path(id, name: "id")}/transactions"))
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|