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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
4
4
  # Do not edit by hand: regenerate it with `bin/paystack-scaffold Customer`. Hand-written extras go in lib/paystack_sdk/resources/extensions/customers.rb.
5
- # scaffold-digest: a6f9d22c6371a27b341370a5137dda91fe7a082cd0a60f49cdfadd3789cc924d
5
+ # scaffold-digest: 24269cd1f96877a533fed260bdce25e0dc552ebe7ca1c5636362779e27358054
6
6
 
7
7
  require_relative "base"
8
8
 
@@ -277,7 +277,7 @@ module PaystackSdk
277
277
  # @param authorization_id [Integer] The authorization ID gotten from the initiation response
278
278
  # @return [PaystackSdk::Response] The response from the Paystack API.
279
279
  # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
280
- # @see https://paystack.com/docs/api/customer/#direct-debit-activation-charge
280
+ # @see https://paystack.com/docs/api/customer/#directdebit-activation-charge
281
281
  def direct_debit_activation_charge(id:, authorization_id:)
282
282
  validate_presence!(value: id, name: "id")
283
283
  validate_presence!(value: authorization_id, name: "authorization_id")
@@ -0,0 +1,241 @@
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 Dedicated Virtual Account`. Hand-written extras go in lib/paystack_sdk/resources/extensions/dedicated_virtual_accounts.rb.
5
+ # scaffold-digest: ced1a6e3ff1b259142646259b38808d9036c73b57ea1a30384a5f2ad8c7c4da5
6
+
7
+ require_relative "base"
8
+
9
+ module PaystackSdk
10
+ module Resources
11
+ # Dedicated Virtual Account operations.
12
+ class DedicatedVirtualAccounts < PaystackSdk::Resources::Base
13
+ # Ruby keyword => the parameter name Paystack documents.
14
+ WIRE_NAMES = {per_page: "perPage"}.freeze
15
+
16
+ # List Dedicated Accounts.
17
+ #
18
+ # List dedicated virtual accounts available on your integration.
19
+ #
20
+ # @param active [Boolean] Status of the dedicated virtual account
21
+ # @param customer [Integer] The customer's ID
22
+ # @param currency [String] The currency of the dedicated virtual account One of: NGN, GHS.
23
+ # @param provider_slug [String] The bank's slug in lowercase, without spaces
24
+ # @param bank_id [String] The bank's ID
25
+ # @param per_page [Integer] The number of records to fetch per request
26
+ # @param page [Integer] The offset to retrieve data from
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/dedicated-virtual-account/#list
30
+ def list(
31
+ active: nil,
32
+ customer: nil,
33
+ currency: nil,
34
+ provider_slug: nil,
35
+ bank_id: nil,
36
+ per_page: nil,
37
+ page: nil
38
+ )
39
+ validate_allowed_values!(value: currency, allowed_values: %w[NGN GHS], name: "currency")
40
+ validate_positive_integer!(value: per_page, name: "perPage")
41
+ validate_positive_integer!(value: page, name: "page")
42
+
43
+ wire_query = to_wire(
44
+ {
45
+ active:,
46
+ customer:,
47
+ currency:,
48
+ provider_slug:,
49
+ bank_id:,
50
+ per_page:,
51
+ page:
52
+ },
53
+ WIRE_NAMES
54
+ )
55
+
56
+ handle_response(@connection.get("/dedicated_account", wire_query))
57
+ end
58
+
59
+ # Create Dedicated Account.
60
+ #
61
+ # Create a dedicated virtual account for an existing customer
62
+ #
63
+ # @param customer [String] The code for the previously created customer
64
+ # @param preferred_bank [String] The bank slug for preferred bank.
65
+ # @param subaccount [String] Subaccount code of the account you want to split the transaction with
66
+ # @param split_code [String] Split code consisting of the lists of accounts you want to split the transaction with
67
+ # @return [PaystackSdk::Response] The response from the Paystack API.
68
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
69
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#create
70
+ def create(customer:, preferred_bank: nil, subaccount: nil, split_code: nil)
71
+ validate_presence!(value: customer, name: "customer")
72
+
73
+ wire_body = to_wire({customer:, preferred_bank:, subaccount:, split_code:}, WIRE_NAMES)
74
+
75
+ handle_response(@connection.post("/dedicated_account", wire_body))
76
+ end
77
+
78
+ # Assign Dedicated Account.
79
+ #
80
+ # With this endpoint, you can create a customer, validate the customer, and assign a DVA to the customer.
81
+ #
82
+ # @param email [String] Customer's email address
83
+ # @param first_name [String] Customer's first name
84
+ # @param last_name [String] Customer's last name
85
+ # @param phone [String] Customer's phone name
86
+ # @param preferred_bank [String] The bank slug for preferred bank.
87
+ # @param country [String] The two letter code country One of: NG, GH.
88
+ # @param account_number [String] Customer's account number
89
+ # @param bvn [String] Customer's Bank Verification Number
90
+ # @param bank_code [String] Customer's bank code
91
+ # @param subaccount [String] Subaccount code of the account you want to split the transaction with
92
+ # @param split_code [String] Split code consisting of the lists of accounts you want to split the transaction with
93
+ # @return [PaystackSdk::Response] The response from the Paystack API.
94
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
95
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#assign
96
+ def assign(
97
+ email:,
98
+ first_name:,
99
+ last_name:,
100
+ phone:,
101
+ preferred_bank:,
102
+ country:,
103
+ account_number: nil,
104
+ bvn: nil,
105
+ bank_code: nil,
106
+ subaccount: nil,
107
+ split_code: nil
108
+ )
109
+ validate_presence!(value: email, name: "email")
110
+ validate_email!(email: email, name: "email")
111
+ validate_presence!(value: first_name, name: "first_name")
112
+ validate_presence!(value: last_name, name: "last_name")
113
+ validate_presence!(value: phone, name: "phone")
114
+ validate_presence!(value: preferred_bank, name: "preferred_bank")
115
+ validate_presence!(value: country, name: "country")
116
+ validate_allowed_values!(value: country, allowed_values: %w[NG GH], name: "country")
117
+
118
+ wire_body = to_wire(
119
+ {
120
+ email:,
121
+ first_name:,
122
+ last_name:,
123
+ phone:,
124
+ preferred_bank:,
125
+ country:,
126
+ account_number:,
127
+ bvn:,
128
+ bank_code:,
129
+ subaccount:,
130
+ split_code:
131
+ },
132
+ WIRE_NAMES
133
+ )
134
+
135
+ handle_response(@connection.post("/dedicated_account/assign", wire_body))
136
+ end
137
+
138
+ # Fetch Dedicated Account.
139
+ #
140
+ # Get details of a dedicated virtual account on your integration.
141
+ #
142
+ # @param dedicated_account_id [String] ID of dedicated virtual account
143
+ # @return [PaystackSdk::Response] The response from the Paystack API.
144
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
145
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#fetch
146
+ def fetch(dedicated_account_id:)
147
+ validate_presence!(value: dedicated_account_id, name: "dedicated_account_id")
148
+
149
+ handle_response(
150
+ @connection.get("/dedicated_account/#{escape_path(dedicated_account_id, name: "dedicated_account_id")}")
151
+ )
152
+ end
153
+
154
+ # Deactivate Dedicated Account.
155
+ #
156
+ # Deactivate a dedicated virtual account on your integration.
157
+ #
158
+ # @param dedicated_account_id [String] ID of dedicated virtual account
159
+ # @return [PaystackSdk::Response] The response from the Paystack API.
160
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
161
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#deactivate
162
+ def deactivate(dedicated_account_id:)
163
+ validate_presence!(value: dedicated_account_id, name: "dedicated_account_id")
164
+
165
+ handle_response(
166
+ @connection.delete("/dedicated_account/#{escape_path(dedicated_account_id, name: "dedicated_account_id")}")
167
+ )
168
+ end
169
+
170
+ # Requery Dedicated Account.
171
+ #
172
+ # Requery Dedicated Virtual Account for new transactions
173
+ #
174
+ # @param account_number [String] Virtual account number to requery
175
+ # @param provider_slug [String] The bank's slug in lowercase, without spaces.
176
+ # @param date [String] The day the transfer was made
177
+ # @return [PaystackSdk::Response] The response from the Paystack API.
178
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
179
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#requery
180
+ def requery(account_number: nil, provider_slug: nil, date: nil)
181
+ wire_query = to_wire(
182
+ {
183
+ account_number:,
184
+ provider_slug:,
185
+ date: format_datetime(date, name: "date")
186
+ },
187
+ WIRE_NAMES
188
+ )
189
+
190
+ handle_response(@connection.get("/dedicated_account/requery", wire_query))
191
+ end
192
+
193
+ # Split Dedicated Account Transaction.
194
+ #
195
+ # Split a dedicated virtual account transaction with one or more accounts
196
+ #
197
+ # @param account_number [String] Valid Dedicated virtual account
198
+ # @param subaccount [String] Subaccount code of the account you want to split the transaction with
199
+ # @param split_code [String] Split code consisting of the lists of accounts you want to split the transaction with
200
+ # @return [PaystackSdk::Response] The response from the Paystack API.
201
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
202
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#add-split
203
+ def add_split(account_number:, subaccount: nil, split_code: nil)
204
+ validate_presence!(value: account_number, name: "account_number")
205
+
206
+ wire_body = to_wire({account_number:, subaccount:, split_code:}, WIRE_NAMES)
207
+
208
+ handle_response(@connection.post("/dedicated_account/split", wire_body))
209
+ end
210
+
211
+ # Remove Split from Dedicated Account.
212
+ #
213
+ # If you've previously set up split payment for transactions on a dedicated virtual account, you can remove it with this endpoint
214
+ #
215
+ # @param account_number [String] Valid Dedicated virtual account
216
+ # @return [PaystackSdk::Response] The response from the Paystack API.
217
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
218
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#remove-split
219
+ def remove_split(account_number:)
220
+ validate_presence!(value: account_number, name: "account_number")
221
+
222
+ wire_body = to_wire({account_number:}, WIRE_NAMES)
223
+
224
+ handle_response(
225
+ @connection.delete("/dedicated_account/split") { |request| request.body = wire_body }
226
+ )
227
+ end
228
+
229
+ # Fetch Bank Providers.
230
+ #
231
+ # Get available bank providers for a dedicated virtual account
232
+ #
233
+ # @return [PaystackSdk::Response] The response from the Paystack API.
234
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
235
+ # @see https://paystack.com/docs/api/dedicated-virtual-account/#providers
236
+ def fetch_bank_providers
237
+ handle_response(@connection.get("/dedicated_account/available_providers"))
238
+ end
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,237 @@
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 Dispute`. Hand-written extras go in lib/paystack_sdk/resources/extensions/disputes.rb.
5
+ # scaffold-digest: 4d21cf962908ea0d724baff713ce71427be21015014886479ba0b6ecc2785dbe
6
+
7
+ require_relative "base"
8
+
9
+ module PaystackSdk
10
+ module Resources
11
+ # Dispute operations.
12
+ class Disputes < PaystackSdk::Resources::Base
13
+ # Ruby keyword => the parameter name Paystack documents.
14
+ WIRE_NAMES = {per_page: "perPage"}.freeze
15
+
16
+ # List Disputes.
17
+ #
18
+ # List transaction disputes filed by customers
19
+ #
20
+ # @param per_page [Integer] Number of records to fetch per page
21
+ # @param page [Integer] The section to retrieve
22
+ # @param status [String] Dispute status One of: awaiting-merchant-feedback, awaiting-bank-feedback, pending, resolved.
23
+ # @param transaction [String] Transaction ID
24
+ # @param from [String] The start date
25
+ # @param to [String] The end date
26
+ # @return [PaystackSdk::Response] The response from the Paystack API.
27
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
28
+ # @see https://paystack.com/docs/api/dispute/#list
29
+ def list(per_page: nil, page: nil, status: nil, transaction: nil, from: nil, to: nil)
30
+ validate_positive_integer!(value: per_page, name: "perPage")
31
+ validate_positive_integer!(value: page, name: "page")
32
+ validate_allowed_values!(
33
+ value: status,
34
+ allowed_values: %w[awaiting-merchant-feedback awaiting-bank-feedback pending resolved],
35
+ name: "status"
36
+ )
37
+
38
+ wire_query = to_wire(
39
+ {
40
+ per_page:,
41
+ page:,
42
+ status:,
43
+ transaction:,
44
+ from: format_datetime(from, name: "from"),
45
+ to: format_datetime(to, name: "to")
46
+ },
47
+ WIRE_NAMES
48
+ )
49
+
50
+ handle_response(@connection.get("/dispute", wire_query))
51
+ end
52
+
53
+ # Fetch Dispute.
54
+ #
55
+ # Fetch a transaction dispute
56
+ #
57
+ # @param id [Integer] The unique identifier of the dispute
58
+ # @return [PaystackSdk::Response] The response from the Paystack API.
59
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
60
+ # @see https://paystack.com/docs/api/dispute/#fetch
61
+ def fetch(id:)
62
+ validate_presence!(value: id, name: "id")
63
+
64
+ handle_response(@connection.get("/dispute/#{escape_path(id, name: "id")}"))
65
+ end
66
+
67
+ # Update Dispute.
68
+ #
69
+ # Update a transaction dispute
70
+ #
71
+ # @param id [Integer] The unique identifier of the dispute
72
+ # @param refund_amount [Integer] The amount to refund, in the subunit of your currency
73
+ # @param uploaded_filename [String] Filename of attachment returned via response from the Dispute upload URL
74
+ # @return [PaystackSdk::Response] The response from the Paystack API.
75
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
76
+ # @see https://paystack.com/docs/api/dispute/#update
77
+ def update(id:, refund_amount:, uploaded_filename: nil)
78
+ validate_presence!(value: id, name: "id")
79
+ validate_presence!(value: refund_amount, name: "refund_amount")
80
+
81
+ wire_body = to_wire({refund_amount:, uploaded_filename:}, WIRE_NAMES)
82
+
83
+ handle_response(@connection.put("/dispute/#{escape_path(id, name: "id")}", wire_body))
84
+ end
85
+
86
+ # Fetch Upload URL.
87
+ #
88
+ # Get the URL to upload a dispute evidence
89
+ #
90
+ # @param id [Integer] The unique identifier of the dispute
91
+ # @param upload_filename [String] The file name, with its extension, that you want to upload (for example filename.pdf).
92
+ # @return [PaystackSdk::Response] The response from the Paystack API.
93
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
94
+ # @see https://paystack.com/docs/api/dispute/#upload-url
95
+ def fetch_upload_url(id:, upload_filename: nil)
96
+ validate_presence!(value: id, name: "id")
97
+
98
+ wire_query = to_wire({upload_filename:}, WIRE_NAMES)
99
+
100
+ handle_response(
101
+ @connection.get("/dispute/#{escape_path(id, name: "id")}/upload_url", wire_query)
102
+ )
103
+ end
104
+
105
+ # Export Disputes.
106
+ #
107
+ # Export the disputes available on your integration
108
+ #
109
+ # @param per_page [Integer] Number of records to fetch per page
110
+ # @param page [Integer] The section to retrieve
111
+ # @param status [String] One of: awaiting-merchant-feedback, awaiting-bank-feedback, pending, resolved.
112
+ # @param from [String] The start date
113
+ # @param to [String] The end date
114
+ # @return [PaystackSdk::Response] The response from the Paystack API.
115
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
116
+ # @see https://paystack.com/docs/api/dispute/#export
117
+ def export(per_page: nil, page: nil, status: nil, from: nil, to: nil)
118
+ validate_positive_integer!(value: per_page, name: "perPage")
119
+ validate_positive_integer!(value: page, name: "page")
120
+ validate_allowed_values!(
121
+ value: status,
122
+ allowed_values: %w[awaiting-merchant-feedback awaiting-bank-feedback pending resolved],
123
+ name: "status"
124
+ )
125
+
126
+ wire_query = to_wire(
127
+ {
128
+ per_page:,
129
+ page:,
130
+ status:,
131
+ from: format_datetime(from, name: "from"),
132
+ to: format_datetime(to, name: "to")
133
+ },
134
+ WIRE_NAMES
135
+ )
136
+
137
+ handle_response(@connection.get("/dispute/export", wire_query))
138
+ end
139
+
140
+ # List Transaction Disputes.
141
+ #
142
+ # List all disputes filed for a transaction
143
+ #
144
+ # @param id [Integer] The unique identifier of the transaction
145
+ # @return [PaystackSdk::Response] The response from the Paystack API.
146
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
147
+ # @see https://paystack.com/docs/api/dispute/#transaction
148
+ def list_transaction(id:)
149
+ validate_presence!(value: id, name: "id")
150
+
151
+ handle_response(@connection.get("/dispute/transaction/#{escape_path(id, name: "id")}"))
152
+ end
153
+
154
+ # Resolve Dispute.
155
+ #
156
+ # Resolve a transaction dispute
157
+ #
158
+ # @param id [Integer] The unique identifier of the dispute
159
+ # @param resolution [String] Dispute resolution.
160
+ # @param message [String] Reason for resolving
161
+ # @param refund_amount [Integer] The amount to refund, in the subunit of your integration currency
162
+ # @param uploaded_filename [String] Filename of attachment returned via response from the Dispute upload URL
163
+ # @param evidence [Integer] Evidence Id for fraud claims
164
+ # @return [PaystackSdk::Response] The response from the Paystack API.
165
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
166
+ # @see https://paystack.com/docs/api/dispute/#resolve
167
+ def resolve(id:, resolution:, message:, refund_amount:, uploaded_filename:, evidence: nil)
168
+ validate_presence!(value: id, name: "id")
169
+ validate_presence!(value: resolution, name: "resolution")
170
+ validate_presence!(value: message, name: "message")
171
+ validate_presence!(value: refund_amount, name: "refund_amount")
172
+ validate_presence!(value: uploaded_filename, name: "uploaded_filename")
173
+
174
+ wire_body = to_wire(
175
+ {
176
+ resolution:,
177
+ message:,
178
+ refund_amount:,
179
+ uploaded_filename:,
180
+ evidence:
181
+ },
182
+ WIRE_NAMES
183
+ )
184
+
185
+ handle_response(
186
+ @connection.put("/dispute/#{escape_path(id, name: "id")}/resolve", wire_body)
187
+ )
188
+ end
189
+
190
+ # Add Evidence.
191
+ #
192
+ # Provide evidence for a dispute
193
+ #
194
+ # @param id [Integer] The unique identifier of the dispute
195
+ # @param customer_email [String] Customer email
196
+ # @param customer_name [String] Customer name
197
+ # @param customer_phone [String] Customer mobile number
198
+ # @param service_details [String] Details of service offered
199
+ # @param delivery_address [String] Delivery address
200
+ # @param delivery_date [String] ISO 8601 representation of delivery date (YYYY-MM-DD)
201
+ # @return [PaystackSdk::Response] The response from the Paystack API.
202
+ # @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
203
+ # @see https://paystack.com/docs/api/dispute/#evidence
204
+ def add_evidence(
205
+ id:,
206
+ customer_email:,
207
+ customer_name:,
208
+ customer_phone:,
209
+ service_details:,
210
+ delivery_address: nil,
211
+ delivery_date: nil
212
+ )
213
+ validate_presence!(value: id, name: "id")
214
+ validate_presence!(value: customer_email, name: "customer_email")
215
+ validate_presence!(value: customer_name, name: "customer_name")
216
+ validate_presence!(value: customer_phone, name: "customer_phone")
217
+ validate_presence!(value: service_details, name: "service_details")
218
+
219
+ wire_body = to_wire(
220
+ {
221
+ customer_email:,
222
+ customer_name:,
223
+ customer_phone:,
224
+ service_details:,
225
+ delivery_address:,
226
+ delivery_date: format_datetime(delivery_date, name: "delivery_date")
227
+ },
228
+ WIRE_NAMES
229
+ )
230
+
231
+ handle_response(
232
+ @connection.post("/dispute/#{escape_path(id, name: "id")}/evidence", wire_body)
233
+ )
234
+ end
235
+ end
236
+ end
237
+ end