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,263 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/subaccount
|
|
5
|
+
#
|
|
6
|
+
# Subaccounts
|
|
7
|
+
# A collection of endpoints for creating and managing accounts for sharing a transaction with
|
|
8
|
+
module Subaccount
|
|
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/subaccount/#list
|
|
18
|
+
# List Subaccounts: GET /subaccount
|
|
19
|
+
# List subaccounts available on your integration
|
|
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 active [Boolean]
|
|
26
|
+
# Filter by the state of the subaccounts
|
|
27
|
+
#
|
|
28
|
+
# @return [ListResponse] successful response
|
|
29
|
+
# @raise [ListError] if the request fails
|
|
30
|
+
api_method def self.list(per_page: nil, page: nil, active: nil)
|
|
31
|
+
use_connection do |connection|
|
|
32
|
+
connection.get(
|
|
33
|
+
'/subaccount',
|
|
34
|
+
{ perPage: per_page, page:, active: }.compact,
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Successful response from calling #create.
|
|
40
|
+
class CreateResponse < PaystackGateway::Response
|
|
41
|
+
delegate :business_name,
|
|
42
|
+
:description,
|
|
43
|
+
:primary_contact_name,
|
|
44
|
+
:primary_contact_email,
|
|
45
|
+
:primary_contact_phone,
|
|
46
|
+
:metadata,
|
|
47
|
+
:account_number,
|
|
48
|
+
:percentage_charge,
|
|
49
|
+
:settlement_bank,
|
|
50
|
+
:currency,
|
|
51
|
+
:bank,
|
|
52
|
+
:integration,
|
|
53
|
+
:domain,
|
|
54
|
+
:managed_by_integration,
|
|
55
|
+
:product,
|
|
56
|
+
:subaccount_code,
|
|
57
|
+
:is_verified,
|
|
58
|
+
:settlement_schedule,
|
|
59
|
+
:active,
|
|
60
|
+
:migrate,
|
|
61
|
+
:id,
|
|
62
|
+
:createdAt,
|
|
63
|
+
:updatedAt, to: :data
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Error response from #create.
|
|
67
|
+
class CreateError < ApiError; end
|
|
68
|
+
|
|
69
|
+
# https://paystack.com/docs/api/subaccount/#create
|
|
70
|
+
# Create Subaccount: POST /subaccount
|
|
71
|
+
# Create a subacount for a partner
|
|
72
|
+
#
|
|
73
|
+
# @param business_name [String] (required)
|
|
74
|
+
# Name of business for subaccount
|
|
75
|
+
# @param settlement_bank [String] (required)
|
|
76
|
+
# Bank code for the bank. You can get the list of Bank Codes by calling the List Banks
|
|
77
|
+
# endpoint.
|
|
78
|
+
# @param account_number [String] (required)
|
|
79
|
+
# Bank account number
|
|
80
|
+
# @param percentage_charge [Number] (required)
|
|
81
|
+
# Customer's phone number
|
|
82
|
+
# @param description [String]
|
|
83
|
+
# A description for this subaccount
|
|
84
|
+
# @param primary_contact_email [String]
|
|
85
|
+
# A contact email for the subaccount
|
|
86
|
+
# @param primary_contact_name [String]
|
|
87
|
+
# The name of the contact person for this subaccount
|
|
88
|
+
# @param primary_contact_phone [String]
|
|
89
|
+
# A phone number to call for this subaccount
|
|
90
|
+
# @param metadata [String]
|
|
91
|
+
# Stringified JSON object of custom data
|
|
92
|
+
#
|
|
93
|
+
# @return [CreateResponse] successful response
|
|
94
|
+
# @raise [CreateError] if the request fails
|
|
95
|
+
api_method def self.create(
|
|
96
|
+
business_name:,
|
|
97
|
+
settlement_bank:,
|
|
98
|
+
account_number:,
|
|
99
|
+
percentage_charge:,
|
|
100
|
+
description: nil,
|
|
101
|
+
primary_contact_email: nil,
|
|
102
|
+
primary_contact_name: nil,
|
|
103
|
+
primary_contact_phone: nil,
|
|
104
|
+
metadata: nil
|
|
105
|
+
)
|
|
106
|
+
use_connection do |connection|
|
|
107
|
+
connection.post(
|
|
108
|
+
'/subaccount',
|
|
109
|
+
{
|
|
110
|
+
business_name:,
|
|
111
|
+
settlement_bank:,
|
|
112
|
+
account_number:,
|
|
113
|
+
percentage_charge:,
|
|
114
|
+
description:,
|
|
115
|
+
primary_contact_email:,
|
|
116
|
+
primary_contact_name:,
|
|
117
|
+
primary_contact_phone:,
|
|
118
|
+
metadata:,
|
|
119
|
+
}.compact,
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Successful response from calling #fetch.
|
|
125
|
+
class FetchResponse < PaystackGateway::Response
|
|
126
|
+
delegate :integration,
|
|
127
|
+
:bank,
|
|
128
|
+
:managed_by_integration,
|
|
129
|
+
:domain,
|
|
130
|
+
:subaccount_code,
|
|
131
|
+
:business_name,
|
|
132
|
+
:description,
|
|
133
|
+
:primary_contact_name,
|
|
134
|
+
:primary_contact_email,
|
|
135
|
+
:primary_contact_phone,
|
|
136
|
+
:metadata,
|
|
137
|
+
:percentage_charge,
|
|
138
|
+
:is_verified,
|
|
139
|
+
:settlement_bank,
|
|
140
|
+
:account_number,
|
|
141
|
+
:settlement_schedule,
|
|
142
|
+
:active,
|
|
143
|
+
:migrate,
|
|
144
|
+
:currency,
|
|
145
|
+
:product,
|
|
146
|
+
:id,
|
|
147
|
+
:createdAt,
|
|
148
|
+
:updatedAt, to: :data
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Error response from #fetch.
|
|
152
|
+
class FetchError < ApiError; end
|
|
153
|
+
|
|
154
|
+
# https://paystack.com/docs/api/subaccount/#fetch
|
|
155
|
+
# Fetch Subaccount: GET /subaccount/{code}
|
|
156
|
+
# Get details of a subaccount on your integration
|
|
157
|
+
#
|
|
158
|
+
# @param code [String] (required)
|
|
159
|
+
# The subaccount code you want to fetch
|
|
160
|
+
#
|
|
161
|
+
# @return [FetchResponse] successful response
|
|
162
|
+
# @raise [FetchError] if the request fails
|
|
163
|
+
api_method def self.fetch(code:)
|
|
164
|
+
use_connection do |connection|
|
|
165
|
+
connection.get(
|
|
166
|
+
"/subaccount/#{code}",
|
|
167
|
+
)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Successful response from calling #update.
|
|
172
|
+
class UpdateResponse < PaystackGateway::Response
|
|
173
|
+
delegate :domain,
|
|
174
|
+
:subaccount_code,
|
|
175
|
+
:business_name,
|
|
176
|
+
:description,
|
|
177
|
+
:primary_contact_name,
|
|
178
|
+
:primary_contact_email,
|
|
179
|
+
:primary_contact_phone,
|
|
180
|
+
:metadata,
|
|
181
|
+
:percentage_charge,
|
|
182
|
+
:is_verified,
|
|
183
|
+
:settlement_bank,
|
|
184
|
+
:account_number,
|
|
185
|
+
:settlement_schedule,
|
|
186
|
+
:active,
|
|
187
|
+
:migrate,
|
|
188
|
+
:currency,
|
|
189
|
+
:product,
|
|
190
|
+
:id,
|
|
191
|
+
:integration,
|
|
192
|
+
:bank,
|
|
193
|
+
:managed_by_integration,
|
|
194
|
+
:createdAt,
|
|
195
|
+
:updatedAt, to: :data
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Error response from #update.
|
|
199
|
+
class UpdateError < ApiError; end
|
|
200
|
+
|
|
201
|
+
# https://paystack.com/docs/api/subaccount/#update
|
|
202
|
+
# Update Subaccount: PUT /subaccount/{code}
|
|
203
|
+
# Update a subaccount details on your integration
|
|
204
|
+
#
|
|
205
|
+
# @param code [String] (required)
|
|
206
|
+
# The subaccount code you want to fetch
|
|
207
|
+
# @param business_name [String]
|
|
208
|
+
# Name of business for subaccount
|
|
209
|
+
# @param settlement_bank [String]
|
|
210
|
+
# Bank code for the bank. You can get the list of Bank Codes by calling the List Banks
|
|
211
|
+
# endpoint.
|
|
212
|
+
# @param account_number [String]
|
|
213
|
+
# Bank account number
|
|
214
|
+
# @param active [Boolean]
|
|
215
|
+
# Activate or deactivate a subaccount
|
|
216
|
+
# @param percentage_charge [Number]
|
|
217
|
+
# Customer's phone number
|
|
218
|
+
# @param description [String]
|
|
219
|
+
# A description for this subaccount
|
|
220
|
+
# @param primary_contact_email [String]
|
|
221
|
+
# A contact email for the subaccount
|
|
222
|
+
# @param primary_contact_name [String]
|
|
223
|
+
# The name of the contact person for this subaccount
|
|
224
|
+
# @param primary_contact_phone [String]
|
|
225
|
+
# A phone number to call for this subaccount
|
|
226
|
+
# @param metadata [String]
|
|
227
|
+
# Stringified JSON object of custom data
|
|
228
|
+
#
|
|
229
|
+
# @return [UpdateResponse] successful response
|
|
230
|
+
# @raise [UpdateError] if the request fails
|
|
231
|
+
api_method def self.update(
|
|
232
|
+
code:,
|
|
233
|
+
business_name: nil,
|
|
234
|
+
settlement_bank: nil,
|
|
235
|
+
account_number: nil,
|
|
236
|
+
active: nil,
|
|
237
|
+
percentage_charge: nil,
|
|
238
|
+
description: nil,
|
|
239
|
+
primary_contact_email: nil,
|
|
240
|
+
primary_contact_name: nil,
|
|
241
|
+
primary_contact_phone: nil,
|
|
242
|
+
metadata: nil
|
|
243
|
+
)
|
|
244
|
+
use_connection do |connection|
|
|
245
|
+
connection.put(
|
|
246
|
+
"/subaccount/#{code}",
|
|
247
|
+
{
|
|
248
|
+
business_name:,
|
|
249
|
+
settlement_bank:,
|
|
250
|
+
account_number:,
|
|
251
|
+
active:,
|
|
252
|
+
percentage_charge:,
|
|
253
|
+
description:,
|
|
254
|
+
primary_contact_email:,
|
|
255
|
+
primary_contact_name:,
|
|
256
|
+
primary_contact_phone:,
|
|
257
|
+
metadata:,
|
|
258
|
+
}.compact,
|
|
259
|
+
)
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
@@ -1,37 +1,3 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
# Create and manage subaccounts https://paystack.com/docs/api/subaccount/
|
|
5
|
-
module Subaccounts
|
|
6
|
-
include PaystackGateway::RequestModule
|
|
7
|
-
|
|
8
|
-
# Response from POST /subaccount
|
|
9
|
-
class CreateSubaccountResponse < PaystackGateway::Response
|
|
10
|
-
delegate :subaccount_code, to: :data
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
api_method def self.create_subaccount(business_name:, settlement_bank:, account_number:, percentage_charge:)
|
|
14
|
-
use_connection do |connection|
|
|
15
|
-
connection.post(
|
|
16
|
-
'/subaccount',
|
|
17
|
-
{ business_name:, settlement_bank:, account_number:, percentage_charge: }.compact,
|
|
18
|
-
)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Response from PUT /subaccount/:id_or_code
|
|
23
|
-
class UpdateSubaccountResponse < CreateSubaccountResponse; end
|
|
24
|
-
|
|
25
|
-
api_method def self.update_subaccount(
|
|
26
|
-
subaccount_code,
|
|
27
|
-
business_name: nil, settlement_bank: nil, account_number: nil, percentage_charge: nil
|
|
28
|
-
)
|
|
29
|
-
use_connection do |connection|
|
|
30
|
-
connection.put(
|
|
31
|
-
"/subaccount/#{subaccount_code}",
|
|
32
|
-
{ business_name:, settlement_bank:, account_number:, percentage_charge: }.compact,
|
|
33
|
-
)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
3
|
+
require 'paystack_gateway/legacy/subaccounts'
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module PaystackGateway
|
|
4
|
+
# https://paystack.com/docs/api/subscription
|
|
5
|
+
#
|
|
6
|
+
# Subscriptions
|
|
7
|
+
# A collection of endpoints for creating and managing recurring payments
|
|
8
|
+
module Subscription
|
|
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/subscription/#list
|
|
18
|
+
# List Subscriptions: GET /subscription
|
|
19
|
+
# List all subscriptions available on your integration
|
|
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 plan [Integer]
|
|
26
|
+
# Plan ID
|
|
27
|
+
# @param customer [String]
|
|
28
|
+
# Customer ID
|
|
29
|
+
# @param from [Time]
|
|
30
|
+
# The start date
|
|
31
|
+
# @param to [Time]
|
|
32
|
+
# The end date
|
|
33
|
+
#
|
|
34
|
+
# @return [ListResponse] successful response
|
|
35
|
+
# @raise [ListError] if the request fails
|
|
36
|
+
api_method def self.list(
|
|
37
|
+
per_page: nil,
|
|
38
|
+
page: nil,
|
|
39
|
+
plan: nil,
|
|
40
|
+
customer: nil,
|
|
41
|
+
from: nil,
|
|
42
|
+
to: nil
|
|
43
|
+
)
|
|
44
|
+
use_connection do |connection|
|
|
45
|
+
connection.get(
|
|
46
|
+
'/subscription',
|
|
47
|
+
{
|
|
48
|
+
perPage: per_page,
|
|
49
|
+
page:,
|
|
50
|
+
plan:,
|
|
51
|
+
customer:,
|
|
52
|
+
from:,
|
|
53
|
+
to:,
|
|
54
|
+
}.compact,
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Successful response from calling #create.
|
|
60
|
+
class CreateResponse < PaystackGateway::Response
|
|
61
|
+
delegate :customer,
|
|
62
|
+
:plan,
|
|
63
|
+
:integration,
|
|
64
|
+
:domain,
|
|
65
|
+
:start,
|
|
66
|
+
:quantity,
|
|
67
|
+
:amount,
|
|
68
|
+
:authorization,
|
|
69
|
+
:invoice_limit,
|
|
70
|
+
:split_code,
|
|
71
|
+
:subscription_code,
|
|
72
|
+
:email_token,
|
|
73
|
+
:id,
|
|
74
|
+
:cancelledAt,
|
|
75
|
+
:createdAt,
|
|
76
|
+
:updatedAt,
|
|
77
|
+
:cron_expression,
|
|
78
|
+
:next_payment_date,
|
|
79
|
+
:easy_cron_id,
|
|
80
|
+
:open_invoice,
|
|
81
|
+
:metadata, to: :data
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Error response from #create.
|
|
85
|
+
class CreateError < ApiError; end
|
|
86
|
+
|
|
87
|
+
# https://paystack.com/docs/api/subscription/#create
|
|
88
|
+
# Create Subscription: POST /subscription
|
|
89
|
+
# Create a subscription a customer
|
|
90
|
+
#
|
|
91
|
+
# @param customer [String] (required)
|
|
92
|
+
# Customer's email address or customer code
|
|
93
|
+
# @param plan [String] (required)
|
|
94
|
+
# Plan code
|
|
95
|
+
# @param authorization [String]
|
|
96
|
+
# If customer has multiple authorizations, you can set the desired authorization you
|
|
97
|
+
# wish to use for this subscription here. If this is not supplied, the customer's
|
|
98
|
+
# most recent authorization would be used
|
|
99
|
+
# @param start_date [Time]
|
|
100
|
+
# Set the date for the first debit. (ISO 8601 format) e.g. 2017-05-16T00:30:13+01:00
|
|
101
|
+
#
|
|
102
|
+
# @return [CreateResponse] successful response
|
|
103
|
+
# @raise [CreateError] if the request fails
|
|
104
|
+
api_method def self.create(customer:, plan:, authorization: nil, start_date: nil)
|
|
105
|
+
use_connection do |connection|
|
|
106
|
+
connection.post(
|
|
107
|
+
'/subscription',
|
|
108
|
+
{ customer:, plan:, authorization:, start_date: }.compact,
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Successful response from calling #fetch.
|
|
114
|
+
class FetchResponse < PaystackGateway::Response
|
|
115
|
+
delegate :id,
|
|
116
|
+
:domain,
|
|
117
|
+
:subscription_code,
|
|
118
|
+
:email_token,
|
|
119
|
+
:amount,
|
|
120
|
+
:cron_expression,
|
|
121
|
+
:next_payment_date,
|
|
122
|
+
:open_invoice,
|
|
123
|
+
:createdAt,
|
|
124
|
+
:cancelledAt,
|
|
125
|
+
:integration,
|
|
126
|
+
:plan,
|
|
127
|
+
:authorization,
|
|
128
|
+
:customer,
|
|
129
|
+
:invoices,
|
|
130
|
+
:invoices_history,
|
|
131
|
+
:invoice_limit,
|
|
132
|
+
:split_code,
|
|
133
|
+
:most_recent_invoice,
|
|
134
|
+
:payments_count,
|
|
135
|
+
:metadata, to: :data
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Error response from #fetch.
|
|
139
|
+
class FetchError < ApiError; end
|
|
140
|
+
|
|
141
|
+
# https://paystack.com/docs/api/subscription/#fetch
|
|
142
|
+
# Fetch Subscription: GET /subscription/{code}
|
|
143
|
+
# Get details of a customer's subscription
|
|
144
|
+
#
|
|
145
|
+
# @param code [String] (required)
|
|
146
|
+
# The subscription code for the subscription you want to fetch
|
|
147
|
+
#
|
|
148
|
+
# @return [FetchResponse] successful response
|
|
149
|
+
# @raise [FetchError] if the request fails
|
|
150
|
+
api_method def self.fetch(code:)
|
|
151
|
+
use_connection do |connection|
|
|
152
|
+
connection.get(
|
|
153
|
+
"/subscription/#{code}",
|
|
154
|
+
)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Successful response from calling #disable.
|
|
159
|
+
class DisableResponse < PaystackGateway::Response; end
|
|
160
|
+
|
|
161
|
+
# Error response from #disable.
|
|
162
|
+
class DisableError < ApiError; end
|
|
163
|
+
|
|
164
|
+
# https://paystack.com/docs/api/subscription/#disable
|
|
165
|
+
# Disable Subscription: POST /subscription/disable
|
|
166
|
+
# Disable a subscription on your integration
|
|
167
|
+
#
|
|
168
|
+
# @param code [String] (required)
|
|
169
|
+
# Subscription code
|
|
170
|
+
# @param token [String] (required)
|
|
171
|
+
# Email token
|
|
172
|
+
#
|
|
173
|
+
# @return [DisableResponse] successful response
|
|
174
|
+
# @raise [DisableError] if the request fails
|
|
175
|
+
api_method def self.disable(code:, token:)
|
|
176
|
+
use_connection do |connection|
|
|
177
|
+
connection.post(
|
|
178
|
+
'/subscription/disable',
|
|
179
|
+
{ code:, token: }.compact,
|
|
180
|
+
)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Successful response from calling #enable.
|
|
185
|
+
class EnableResponse < PaystackGateway::Response; end
|
|
186
|
+
|
|
187
|
+
# Error response from #enable.
|
|
188
|
+
class EnableError < ApiError; end
|
|
189
|
+
|
|
190
|
+
# https://paystack.com/docs/api/subscription/#enable
|
|
191
|
+
# Enable Subscription: POST /subscription/enable
|
|
192
|
+
# Enable a subscription on your integration
|
|
193
|
+
#
|
|
194
|
+
# @param code [String] (required)
|
|
195
|
+
# Subscription code
|
|
196
|
+
# @param token [String] (required)
|
|
197
|
+
# Email token
|
|
198
|
+
#
|
|
199
|
+
# @return [EnableResponse] successful response
|
|
200
|
+
# @raise [EnableError] if the request fails
|
|
201
|
+
api_method def self.enable(code:, token:)
|
|
202
|
+
use_connection do |connection|
|
|
203
|
+
connection.post(
|
|
204
|
+
'/subscription/enable',
|
|
205
|
+
{ code:, token: }.compact,
|
|
206
|
+
)
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Successful response from calling #manage_link.
|
|
211
|
+
class ManageLinkResponse < PaystackGateway::Response; end
|
|
212
|
+
|
|
213
|
+
# Error response from #manage_link.
|
|
214
|
+
class ManageLinkError < ApiError; end
|
|
215
|
+
|
|
216
|
+
# https://paystack.com/docs/api/subscription/#manage_link
|
|
217
|
+
# Generate Update Subscription Link: GET /subscription/{code}/manage/link
|
|
218
|
+
# Generate a link for updating the card on a subscription
|
|
219
|
+
#
|
|
220
|
+
# @param code [String] (required)
|
|
221
|
+
# Subscription code
|
|
222
|
+
#
|
|
223
|
+
# @return [ManageLinkResponse] successful response
|
|
224
|
+
# @raise [ManageLinkError] if the request fails
|
|
225
|
+
api_method def self.manage_link(code:)
|
|
226
|
+
use_connection do |connection|
|
|
227
|
+
connection.get(
|
|
228
|
+
"/subscription/#{code}/manage/link",
|
|
229
|
+
)
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Successful response from calling #manage_email.
|
|
234
|
+
class ManageEmailResponse < PaystackGateway::Response; end
|
|
235
|
+
|
|
236
|
+
# Error response from #manage_email.
|
|
237
|
+
class ManageEmailError < ApiError; end
|
|
238
|
+
|
|
239
|
+
# https://paystack.com/docs/api/subscription/#manage_email
|
|
240
|
+
# Send Update Subscription Link: POST /subscription/{code}/manage/email
|
|
241
|
+
# Email a customer a link for updating the card on their subscription
|
|
242
|
+
#
|
|
243
|
+
# @param code [String] (required)
|
|
244
|
+
# Subscription code
|
|
245
|
+
#
|
|
246
|
+
# @return [ManageEmailResponse] successful response
|
|
247
|
+
# @raise [ManageEmailError] if the request fails
|
|
248
|
+
api_method def self.manage_email(code:)
|
|
249
|
+
use_connection do |connection|
|
|
250
|
+
connection.post(
|
|
251
|
+
"/subscription/#{code}/manage/email",
|
|
252
|
+
)
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|