Skip to content

Subscriptions ​

Subscription operations.

Use it as client.subscriptions. Every method takes keyword arguments, returns a PaystackSdk::Response, and raises a PaystackSdk::Error if a parameter is invalid before anything is sent. An unsuccessful result from Paystack (a 400 or 404) comes back as a Response with success? false.

Methods ​

list ​

ruby
subscriptions.list(per_page: nil, page: nil, plan_id: nil, customer_id: nil, from: nil, to: nil)

List Subscriptions.

List all subscriptions available on your integration

ParameterTypeRequiredDescription
per_pageIntegerNumber of records to fetch per page
pageIntegerThe section to retrieve
plan_idIntegerPlan ID
customer_idIntegerCustomer ID
fromStringThe start date
toStringThe end date

Paystack docs: https://paystack.com/docs/api/subscription/#list

create ​

ruby
subscriptions.create(customer:, plan:, authorization: nil, start_date: nil)

Create Subscription.

Create a subscription a customer

ParameterTypeRequiredDescription
customerStringyesCustomer's email address or customer code
planStringyesPlan code
authorizationStringIf customer has multiple authorizations, you can set the desired authorization you wish to use for this subscription here.
start_dateStringSet the date for the first debit.

Paystack docs: https://paystack.com/docs/api/subscription/#create

fetch ​

ruby
subscriptions.fetch(id_or_code:)

Fetch Subscription.

Get details of a customer's subscription

ParameterTypeRequiredDescription
id_or_codeStringyesThe subscription code for the subscription you want to fetch

Paystack docs: https://paystack.com/docs/api/subscription/#fetch

disable ​

ruby
subscriptions.disable(code:, token:)

Disable Subscription.

Disable a subscription on your integration

ParameterTypeRequiredDescription
codeStringyesSubscription code
tokenStringyesEmail token

Paystack docs: https://paystack.com/docs/api/subscription/#disable

enable ​

ruby
subscriptions.enable(code:, token:)

Enable Subscription.

Enable a subscription on your integration

ParameterTypeRequiredDescription
codeStringyesSubscription code
tokenStringyesEmail token

Paystack docs: https://paystack.com/docs/api/subscription/#enable

ruby
subscriptions.generate_update_link(code:)

Generate Update Subscription Link.

Generate a link for updating the card on a subscription

ParameterTypeRequiredDescription
codeStringyesSubscription code

Paystack docs: https://paystack.com/docs/api/subscription/#manage-link

ruby
subscriptions.send_update_link(code:)

Send Update Subscription Link.

Email a customer a link for updating the card on their subscription

ParameterTypeRequiredDescription
codeStringyesSubscription code

Paystack docs: https://paystack.com/docs/api/subscription/#manage-email

Unofficial community SDK. Not affiliated with or endorsed by Paystack. · MIT License · rubygems.org/gems/paystack_sdk