Skip to content

Products ​

Product operations.

Use it as client.products. 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
products.list(per_page: nil, page: nil, active: nil, from: nil, to: nil)

List Products.

List all previously created products

ParameterTypeRequiredDescription
per_pageIntegerNumber of records to fetch per page
pageIntegerThe section to retrieve
activeBooleanThe state of the product
fromStringThe start date
toStringThe end date

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

create ​

ruby
products.create(
  name:,
  price:,
  currency:,
  description: nil,
  unlimited: nil,
  quantity: nil,
  split_code: nil,
  metadata: nil
)

Create Product.

Create a new product on your integration

ParameterTypeRequiredDescription
nameStringyesName of product
priceIntegeryesPrice should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR
currencyStringyesCurrency in which price is set.
descriptionStringThe description of the product.
unlimitedBooleanSet to true if the product has unlimited stock.
quantityIntegerNumber of products in stock.
split_codeStringThe split code if sharing the transaction with partners
metadataHashA set of key/value pairs that you can attach to the product.

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

fetch ​

ruby
products.fetch(id:)

Fetch Product.

Fetch a previously created product

ParameterTypeRequiredDescription
idIntegeryesThe unique identifier of the product

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

update ​

ruby
products.update(
  id:,
  name: nil,
  description: nil,
  price: nil,
  currency: nil,
  unlimited: nil,
  quantity: nil,
  split_code: nil,
  metadata: nil
)

Update product.

Update a previously created product

ParameterTypeRequiredDescription
idIntegeryesThe unique identifier of the product
nameStringName of product
descriptionStringThe description of the product
priceIntegerPrice should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR
currencyStringCurrency in which price is set.
unlimitedBooleanSet to true if the product has unlimited stock.
quantityIntegerNumber of products in stock.
split_codeStringThe split code if sharing the transaction with partners
metadataHashJSON object of custom data

Paystack docs: https://paystack.com/docs/api/product/#update

delete ​

ruby
products.delete(id:)

Delete Product.

Delete a previously created product

ParameterTypeRequiredDescription
idIntegeryesThe unique identifier of the product

Paystack docs: https://paystack.com/docs/api/product/#delete-product

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