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,186 @@
|
|
|
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 Split`. Hand-written extras go in lib/paystack_sdk/resources/extensions/splits.rb.
|
|
5
|
+
# scaffold-digest: 7edb268cf2271c4fb1af0cf5284840af3e3adbafe31ea1cbc2acfd4dc2c88d10
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Split operations.
|
|
12
|
+
class Splits < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Splits.
|
|
17
|
+
#
|
|
18
|
+
# List the transaction splits available on your integration
|
|
19
|
+
#
|
|
20
|
+
# @param subaccount_code [String] Filter by subaccount code
|
|
21
|
+
# @param name [String] The name of the split
|
|
22
|
+
# @param active [Boolean] The status of the split
|
|
23
|
+
# @param per_page [Integer] The number of records to fetch per request
|
|
24
|
+
# @param page [Integer] The offset to retrieve data from
|
|
25
|
+
# @param from [String] The start date
|
|
26
|
+
# @param to [String] The end date
|
|
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/split/#list
|
|
30
|
+
def list(
|
|
31
|
+
subaccount_code: nil,
|
|
32
|
+
name: nil,
|
|
33
|
+
active: nil,
|
|
34
|
+
per_page: nil,
|
|
35
|
+
page: nil,
|
|
36
|
+
from: nil,
|
|
37
|
+
to: nil
|
|
38
|
+
)
|
|
39
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
40
|
+
validate_positive_integer!(value: page, name: "page")
|
|
41
|
+
|
|
42
|
+
wire_query = to_wire(
|
|
43
|
+
{
|
|
44
|
+
subaccount_code:,
|
|
45
|
+
name:,
|
|
46
|
+
active:,
|
|
47
|
+
per_page:,
|
|
48
|
+
page:,
|
|
49
|
+
from: format_datetime(from, name: "from"),
|
|
50
|
+
to: format_datetime(to, name: "to")
|
|
51
|
+
},
|
|
52
|
+
WIRE_NAMES
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
handle_response(@connection.get("/split", wire_query))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Create Split.
|
|
59
|
+
#
|
|
60
|
+
# Create a split configuration for transactions
|
|
61
|
+
#
|
|
62
|
+
# @param name [String] Name of the transaction split
|
|
63
|
+
# @param type [String] The type of transaction split you want to create. One of: percentage, flat.
|
|
64
|
+
# @param subaccounts [Array] A list of object containing subaccount code and number of shares
|
|
65
|
+
# @param currency [String] The transaction currency One of: NGN, GHS, ZAR, USD.
|
|
66
|
+
# @param bearer_type [String] This allows you specify how the transaction charge should be processed One of: subaccount, account, all-proportional, all.
|
|
67
|
+
# @param bearer_subaccount [String] This is the subaccount code of the customer or partner that would bear the transaction charge if you specified subaccount as the bearer type
|
|
68
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
69
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
70
|
+
# @see https://paystack.com/docs/api/split/#create
|
|
71
|
+
def create(name:, type:, subaccounts:, currency:, bearer_type: nil, bearer_subaccount: nil)
|
|
72
|
+
validate_presence!(value: name, name: "name")
|
|
73
|
+
validate_presence!(value: type, name: "type")
|
|
74
|
+
validate_allowed_values!(value: type, allowed_values: %w[percentage flat], name: "type")
|
|
75
|
+
validate_presence!(value: subaccounts, name: "subaccounts")
|
|
76
|
+
validate_presence!(value: currency, name: "currency")
|
|
77
|
+
validate_allowed_values!(
|
|
78
|
+
value: currency,
|
|
79
|
+
allowed_values: %w[NGN GHS ZAR USD],
|
|
80
|
+
name: "currency"
|
|
81
|
+
)
|
|
82
|
+
validate_allowed_values!(
|
|
83
|
+
value: bearer_type,
|
|
84
|
+
allowed_values: %w[subaccount account all-proportional all],
|
|
85
|
+
name: "bearer_type"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
wire_body = to_wire(
|
|
89
|
+
{
|
|
90
|
+
name:,
|
|
91
|
+
type:,
|
|
92
|
+
subaccounts:,
|
|
93
|
+
currency:,
|
|
94
|
+
bearer_type:,
|
|
95
|
+
bearer_subaccount:
|
|
96
|
+
},
|
|
97
|
+
WIRE_NAMES
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
handle_response(@connection.post("/split", wire_body))
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Fetch Split.
|
|
104
|
+
#
|
|
105
|
+
# Get details of a split configuration for a transaction
|
|
106
|
+
#
|
|
107
|
+
# @param id [String] The ID of the split configuration to fetch
|
|
108
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
109
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
110
|
+
# @see https://paystack.com/docs/api/split/#fetch
|
|
111
|
+
def fetch(id:)
|
|
112
|
+
validate_presence!(value: id, name: "id")
|
|
113
|
+
|
|
114
|
+
handle_response(@connection.get("/split/#{escape_path(id, name: "id")}"))
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Update Split.
|
|
118
|
+
#
|
|
119
|
+
# Update a split configuration for transactions
|
|
120
|
+
#
|
|
121
|
+
# @param id [String]
|
|
122
|
+
# @param name [String] Name of the transaction split
|
|
123
|
+
# @param active [Boolean] Toggle status of split.
|
|
124
|
+
# @param bearer_type [String] This allows you specify how the transaction charge should be processed One of: subaccount, account, all-proportional, all.
|
|
125
|
+
# @param bearer_subaccount [String] This is the subaccount code of the customer or partner that would bear the transaction charge if you specified subaccount as the bearer type
|
|
126
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
127
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
128
|
+
# @see https://paystack.com/docs/api/split/#update
|
|
129
|
+
def update(id:, name: nil, active: nil, bearer_type: nil, bearer_subaccount: nil)
|
|
130
|
+
validate_presence!(value: id, name: "id")
|
|
131
|
+
validate_allowed_values!(
|
|
132
|
+
value: bearer_type,
|
|
133
|
+
allowed_values: %w[subaccount account all-proportional all],
|
|
134
|
+
name: "bearer_type"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
wire_body = to_wire({name:, active:, bearer_type:, bearer_subaccount:}, WIRE_NAMES)
|
|
138
|
+
|
|
139
|
+
handle_response(@connection.put("/split/#{escape_path(id, name: "id")}", wire_body))
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Add Subaccount to Split.
|
|
143
|
+
#
|
|
144
|
+
# Add a subaccount to a split configuration, or update the share of an existing subaccount
|
|
145
|
+
#
|
|
146
|
+
# @param id [Integer] The ID of the split configuration to fetch
|
|
147
|
+
# @param subaccount [String] Subaccount code of the customer or partner
|
|
148
|
+
# @param share [Integer] The percentage or flat quota of the customer or partner
|
|
149
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
150
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
151
|
+
# @see https://paystack.com/docs/api/split/#add-subaccount
|
|
152
|
+
def add_subaccount(id:, subaccount:, share:)
|
|
153
|
+
validate_presence!(value: id, name: "id")
|
|
154
|
+
validate_presence!(value: subaccount, name: "subaccount")
|
|
155
|
+
validate_presence!(value: share, name: "share")
|
|
156
|
+
|
|
157
|
+
wire_body = to_wire({subaccount:, share:}, WIRE_NAMES)
|
|
158
|
+
|
|
159
|
+
handle_response(
|
|
160
|
+
@connection.post("/split/#{escape_path(id, name: "id")}/subaccount/add", wire_body)
|
|
161
|
+
)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Remove Subaccount from split.
|
|
165
|
+
#
|
|
166
|
+
# Remove a subaccount from a split configuration
|
|
167
|
+
#
|
|
168
|
+
# @param id [Integer] The ID of the split configuration to fetch
|
|
169
|
+
# @param subaccount [String] Subaccount code of the customer or partner
|
|
170
|
+
# @param share [Integer] Not used when removing a subaccount; the docs do not list it, and Paystack removes the subaccount whatever share is sent.
|
|
171
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
172
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
173
|
+
# @see https://paystack.com/docs/api/split/#remove-subaccount
|
|
174
|
+
def remove_subaccount(id:, subaccount:, share: nil)
|
|
175
|
+
validate_presence!(value: id, name: "id")
|
|
176
|
+
validate_presence!(value: subaccount, name: "subaccount")
|
|
177
|
+
|
|
178
|
+
wire_body = to_wire({subaccount:, share:}, WIRE_NAMES)
|
|
179
|
+
|
|
180
|
+
handle_response(
|
|
181
|
+
@connection.post("/split/#{escape_path(id, name: "id")}/subaccount/remove", wire_body)
|
|
182
|
+
)
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
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 Subaccount`. Hand-written extras go in lib/paystack_sdk/resources/extensions/subaccounts.rb.
|
|
5
|
+
# scaffold-digest: 138fb843a635fcc0bbe5279df7a324b6973fecc6652458cc3e422999a716bc37
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Subaccount operations.
|
|
12
|
+
class Subaccounts < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Subaccounts.
|
|
17
|
+
#
|
|
18
|
+
# List subaccounts available on your integration
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] Number of records to fetch per request
|
|
21
|
+
# @param page [Integer] The offset to retrieve data from
|
|
22
|
+
# @param active [Integer] Filter by the state of the subaccounts
|
|
23
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
24
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
25
|
+
# @see https://paystack.com/docs/api/subaccount/#list
|
|
26
|
+
def list(per_page: nil, page: nil, active: nil)
|
|
27
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
28
|
+
validate_positive_integer!(value: page, name: "page")
|
|
29
|
+
|
|
30
|
+
wire_query = to_wire({per_page:, page:, active:}, WIRE_NAMES)
|
|
31
|
+
|
|
32
|
+
handle_response(@connection.get("/subaccount", wire_query))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Create Subaccount.
|
|
36
|
+
#
|
|
37
|
+
# Create a subacount for a partner
|
|
38
|
+
#
|
|
39
|
+
# @param business_name [String] Name of business for subaccount
|
|
40
|
+
# @param bank_code [String] Bank code for the bank, from the List Banks endpoint.
|
|
41
|
+
# @param account_number [String] Bank account number
|
|
42
|
+
# @param percentage_charge [Numeric] The percentage the main account receives from each payment made to the subaccount.
|
|
43
|
+
# @param description [String] A description for this subaccount
|
|
44
|
+
# @param primary_contact_email [String] A contact email for the subaccount
|
|
45
|
+
# @param primary_contact_name [String] The name of the contact person for this subaccount
|
|
46
|
+
# @param primary_contact_phone [String] A phone number to call for this subaccount
|
|
47
|
+
# @param metadata [String] Stringified JSON object of custom data
|
|
48
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
49
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
50
|
+
# @see https://paystack.com/docs/api/subaccount/#create
|
|
51
|
+
def create(
|
|
52
|
+
business_name:,
|
|
53
|
+
bank_code:,
|
|
54
|
+
account_number:,
|
|
55
|
+
percentage_charge:,
|
|
56
|
+
description: nil,
|
|
57
|
+
primary_contact_email: nil,
|
|
58
|
+
primary_contact_name: nil,
|
|
59
|
+
primary_contact_phone: nil,
|
|
60
|
+
metadata: nil
|
|
61
|
+
)
|
|
62
|
+
validate_presence!(value: business_name, name: "business_name")
|
|
63
|
+
validate_presence!(value: bank_code, name: "bank_code")
|
|
64
|
+
validate_presence!(value: account_number, name: "account_number")
|
|
65
|
+
validate_presence!(value: percentage_charge, name: "percentage_charge")
|
|
66
|
+
|
|
67
|
+
wire_body = to_wire(
|
|
68
|
+
{
|
|
69
|
+
business_name:,
|
|
70
|
+
bank_code:,
|
|
71
|
+
account_number:,
|
|
72
|
+
percentage_charge:,
|
|
73
|
+
description:,
|
|
74
|
+
primary_contact_email:,
|
|
75
|
+
primary_contact_name:,
|
|
76
|
+
primary_contact_phone:,
|
|
77
|
+
metadata: stringify_json(metadata)
|
|
78
|
+
},
|
|
79
|
+
WIRE_NAMES
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
handle_response(@connection.post("/subaccount", wire_body))
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Fetch Subaccount.
|
|
86
|
+
#
|
|
87
|
+
# Get details of a subaccount on your integration
|
|
88
|
+
#
|
|
89
|
+
# @param id_or_code [String] The subaccount code you want to fetch
|
|
90
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
91
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
92
|
+
# @see https://paystack.com/docs/api/subaccount/#fetch
|
|
93
|
+
def fetch(id_or_code:)
|
|
94
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
95
|
+
|
|
96
|
+
handle_response(
|
|
97
|
+
@connection.get("/subaccount/#{escape_path(id_or_code, name: "id_or_code")}")
|
|
98
|
+
)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Update Subaccount.
|
|
102
|
+
#
|
|
103
|
+
# Update a subaccount details on your integration
|
|
104
|
+
#
|
|
105
|
+
# @param id_or_code [String] The subaccount code you want to fetch
|
|
106
|
+
# @param business_name [String] Name of business for subaccount
|
|
107
|
+
# @param bank_code [String] Bank code for the bank, from the List Banks endpoint.
|
|
108
|
+
# @param account_number [String] Bank account number
|
|
109
|
+
# @param active [Boolean] Activate or deactivate a subaccount
|
|
110
|
+
# @param percentage_charge [Numeric] The default percentage charged when receiving on behalf of this subaccount.
|
|
111
|
+
# @param description [String] A description for this subaccount
|
|
112
|
+
# @param primary_contact_email [String] A contact email for the subaccount
|
|
113
|
+
# @param primary_contact_name [String] The name of the contact person for this subaccount
|
|
114
|
+
# @param primary_contact_phone [String] A phone number to call for this subaccount
|
|
115
|
+
# @param metadata [String] Stringified JSON object of custom data
|
|
116
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
117
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
118
|
+
# @see https://paystack.com/docs/api/subaccount/#update
|
|
119
|
+
def update(
|
|
120
|
+
id_or_code:,
|
|
121
|
+
business_name: nil,
|
|
122
|
+
bank_code: nil,
|
|
123
|
+
account_number: nil,
|
|
124
|
+
active: nil,
|
|
125
|
+
percentage_charge: nil,
|
|
126
|
+
description: nil,
|
|
127
|
+
primary_contact_email: nil,
|
|
128
|
+
primary_contact_name: nil,
|
|
129
|
+
primary_contact_phone: nil,
|
|
130
|
+
metadata: nil
|
|
131
|
+
)
|
|
132
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
133
|
+
|
|
134
|
+
wire_body = to_wire(
|
|
135
|
+
{
|
|
136
|
+
business_name:,
|
|
137
|
+
bank_code:,
|
|
138
|
+
account_number:,
|
|
139
|
+
active:,
|
|
140
|
+
percentage_charge:,
|
|
141
|
+
description:,
|
|
142
|
+
primary_contact_email:,
|
|
143
|
+
primary_contact_name:,
|
|
144
|
+
primary_contact_phone:,
|
|
145
|
+
metadata: stringify_json(metadata)
|
|
146
|
+
},
|
|
147
|
+
WIRE_NAMES
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
handle_response(
|
|
151
|
+
@connection.put("/subaccount/#{escape_path(id_or_code, name: "id_or_code")}", wire_body)
|
|
152
|
+
)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
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 Subscription`. Hand-written extras go in lib/paystack_sdk/resources/extensions/subscriptions.rb.
|
|
5
|
+
# scaffold-digest: bf9e49fa6de4d23b295572c9c4fc3aa74477986410dd3f858145f2e4239d0444
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Subscription operations.
|
|
12
|
+
class Subscriptions < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage", plan_id: "plan", customer_id: "customer"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Subscriptions.
|
|
17
|
+
#
|
|
18
|
+
# List all subscriptions available on your integration
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] Number of records to fetch per page
|
|
21
|
+
# @param page [Integer] The section to retrieve
|
|
22
|
+
# @param plan_id [Integer] Plan ID
|
|
23
|
+
# @param customer_id [Integer] Customer 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/subscription/#list
|
|
29
|
+
def list(per_page: nil, page: nil, plan_id: nil, customer_id: nil, from: nil, to: nil)
|
|
30
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
31
|
+
validate_positive_integer!(value: page, name: "page")
|
|
32
|
+
|
|
33
|
+
wire_query = to_wire(
|
|
34
|
+
{
|
|
35
|
+
per_page:,
|
|
36
|
+
page:,
|
|
37
|
+
plan_id:,
|
|
38
|
+
customer_id:,
|
|
39
|
+
from: format_datetime(from, name: "from"),
|
|
40
|
+
to: format_datetime(to, name: "to")
|
|
41
|
+
},
|
|
42
|
+
WIRE_NAMES
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
handle_response(@connection.get("/subscription", wire_query))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Create Subscription.
|
|
49
|
+
#
|
|
50
|
+
# Create a subscription a customer
|
|
51
|
+
#
|
|
52
|
+
# @param customer [String] Customer's email address or customer code
|
|
53
|
+
# @param plan [String] Plan code
|
|
54
|
+
# @param authorization [String] If customer has multiple authorizations, you can set the desired authorization you wish to use for this subscription here.
|
|
55
|
+
# @param start_date [String] Set the date for the first debit.
|
|
56
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
57
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
58
|
+
# @see https://paystack.com/docs/api/subscription/#create
|
|
59
|
+
def create(customer:, plan:, authorization: nil, start_date: nil)
|
|
60
|
+
validate_presence!(value: customer, name: "customer")
|
|
61
|
+
validate_presence!(value: plan, name: "plan")
|
|
62
|
+
|
|
63
|
+
wire_body = to_wire(
|
|
64
|
+
{
|
|
65
|
+
customer:,
|
|
66
|
+
plan:,
|
|
67
|
+
authorization:,
|
|
68
|
+
start_date: format_datetime(start_date, name: "start_date")
|
|
69
|
+
},
|
|
70
|
+
WIRE_NAMES
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
handle_response(@connection.post("/subscription", wire_body))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Fetch Subscription.
|
|
77
|
+
#
|
|
78
|
+
# Get details of a customer's subscription
|
|
79
|
+
#
|
|
80
|
+
# @param id_or_code [String] The subscription code for the subscription you want to fetch
|
|
81
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
82
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
83
|
+
# @see https://paystack.com/docs/api/subscription/#fetch
|
|
84
|
+
def fetch(id_or_code:)
|
|
85
|
+
validate_presence!(value: id_or_code, name: "id_or_code")
|
|
86
|
+
|
|
87
|
+
handle_response(
|
|
88
|
+
@connection.get("/subscription/#{escape_path(id_or_code, name: "id_or_code")}")
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Disable Subscription.
|
|
93
|
+
#
|
|
94
|
+
# Disable a subscription on your integration
|
|
95
|
+
#
|
|
96
|
+
# @param code [String] Subscription code
|
|
97
|
+
# @param token [String] Email token
|
|
98
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
99
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
100
|
+
# @see https://paystack.com/docs/api/subscription/#disable
|
|
101
|
+
def disable(code:, token:)
|
|
102
|
+
validate_presence!(value: code, name: "code")
|
|
103
|
+
validate_presence!(value: token, name: "token")
|
|
104
|
+
|
|
105
|
+
wire_body = to_wire({code:, token:}, WIRE_NAMES)
|
|
106
|
+
|
|
107
|
+
handle_response(@connection.post("/subscription/disable", wire_body))
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Enable Subscription.
|
|
111
|
+
#
|
|
112
|
+
# Enable a subscription on your integration
|
|
113
|
+
#
|
|
114
|
+
# @param code [String] Subscription code
|
|
115
|
+
# @param token [String] Email token
|
|
116
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
117
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
118
|
+
# @see https://paystack.com/docs/api/subscription/#enable
|
|
119
|
+
def enable(code:, token:)
|
|
120
|
+
validate_presence!(value: code, name: "code")
|
|
121
|
+
validate_presence!(value: token, name: "token")
|
|
122
|
+
|
|
123
|
+
wire_body = to_wire({code:, token:}, WIRE_NAMES)
|
|
124
|
+
|
|
125
|
+
handle_response(@connection.post("/subscription/enable", wire_body))
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Generate Update Subscription Link.
|
|
129
|
+
#
|
|
130
|
+
# Generate a link for updating the card on a subscription
|
|
131
|
+
#
|
|
132
|
+
# @param code [String] Subscription code
|
|
133
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
134
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
135
|
+
# @see https://paystack.com/docs/api/subscription/#manage-link
|
|
136
|
+
def generate_update_link(code:)
|
|
137
|
+
validate_presence!(value: code, name: "code")
|
|
138
|
+
|
|
139
|
+
handle_response(
|
|
140
|
+
@connection.get("/subscription/#{escape_path(code, name: "code")}/manage/link")
|
|
141
|
+
)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Send Update Subscription Link.
|
|
145
|
+
#
|
|
146
|
+
# Email a customer a link for updating the card on their subscription
|
|
147
|
+
#
|
|
148
|
+
# @param code [String] Subscription code
|
|
149
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
150
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
151
|
+
# @see https://paystack.com/docs/api/subscription/#manage-email
|
|
152
|
+
def send_update_link(code:)
|
|
153
|
+
validate_presence!(value: code, name: "code")
|
|
154
|
+
|
|
155
|
+
handle_response(
|
|
156
|
+
@connection.post("/subscription/#{escape_path(code, name: "code")}/manage/email")
|
|
157
|
+
)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
data/lib/paystack_sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: paystack_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maxwell Nana Forson (theLazyProgrammer)
|
|
@@ -165,13 +165,22 @@ files:
|
|
|
165
165
|
- lib/paystack_sdk/client.rb
|
|
166
166
|
- lib/paystack_sdk/middleware/transport_errors.rb
|
|
167
167
|
- lib/paystack_sdk/request_helpers.rb
|
|
168
|
+
- lib/paystack_sdk/resources/balances.rb
|
|
168
169
|
- lib/paystack_sdk/resources/banks.rb
|
|
169
170
|
- lib/paystack_sdk/resources/base.rb
|
|
170
171
|
- lib/paystack_sdk/resources/charges.rb
|
|
171
172
|
- lib/paystack_sdk/resources/customers.rb
|
|
173
|
+
- lib/paystack_sdk/resources/dedicated_virtual_accounts.rb
|
|
174
|
+
- lib/paystack_sdk/resources/disputes.rb
|
|
172
175
|
- lib/paystack_sdk/resources/extensions/charges.rb
|
|
173
176
|
- lib/paystack_sdk/resources/miscellaneous.rb
|
|
177
|
+
- lib/paystack_sdk/resources/payment_requests.rb
|
|
178
|
+
- lib/paystack_sdk/resources/plans.rb
|
|
174
179
|
- lib/paystack_sdk/resources/refunds.rb
|
|
180
|
+
- lib/paystack_sdk/resources/settlements.rb
|
|
181
|
+
- lib/paystack_sdk/resources/splits.rb
|
|
182
|
+
- lib/paystack_sdk/resources/subaccounts.rb
|
|
183
|
+
- lib/paystack_sdk/resources/subscriptions.rb
|
|
175
184
|
- lib/paystack_sdk/resources/transactions.rb
|
|
176
185
|
- lib/paystack_sdk/resources/transfer_recipients.rb
|
|
177
186
|
- lib/paystack_sdk/resources/transfers.rb
|