Skip to content

Repository files navigation

Paystack Ruby SDK

The official Ruby SDK for the Paystack API — generated from the Paystack OpenAPI specification.

License: MITRuby ≥ 3.1


Requirements

  • Ruby 3.1 or later
  • Standard library HTTP stack (net/http) — no extra runtime HTTP dependency

Installation

Add this to your application's Gemfile:

gem"paystack-ruby"

Then execute:

bundle install

Or install directly:

gem install paystack-ruby

Configuration

Paystack::Client takes your secret key as its only argument:

paystack=Paystack::Client.new(ENV.fetch("PAYSTACK_SECRET_KEY"))

Use your Test Secret Key (sk_test_...) for development and Live Secret Key (sk_live_...) in production. Get them from your Paystack Dashboard.


Quick Start

Initialize a transaction and send the customer to authorization_url to pay:

require"paystack"paystack=Paystack::Client.new(ENV.fetch("PAYSTACK_SECRET_KEY"))result=paystack.transaction.initialize({email: "customer@example.com",amount: 100_000# kobo})putsresult.data[:authorization_url]

Once the customer is redirected back, verify the transaction before you treat it as paid; never trust the redirect alone:

result=paystack.transaction.verify(reference)ifresult.data[:status] == "success"# fulfil the orderend

Response Shape

All resource methods return a Paystack::Response object exposing:

response.http_status# Integerresponse.status# Booleanresponse.message# Stringresponse.data# Hash / Array / nilresponse.meta# Hash / nil

Error Handling

API failures raise a Paystack::Error, carrying the HTTP status and response body:

beginpaystack.transaction.initialize({email: "customer@example.com",amount: 100_000})rescuePaystack::Error=>eputse.messageputse.http_statusend

If you need to branch on failure type, rescue the specific subclass instead — Paystack::AuthenticationError, ValidationError, NotFoundError, RateLimitError, or ServerError:

beginpaystack.transaction.initialize({email: "customer@example.com",amount: 100_000})rescuePaystack::RateLimitErrorsleep(1)retryend

API Reference

The SDK exposes one method per API resource on the Paystack::Client instance.

ResourcePropertyDescriptionMethods
ApplePaypaystack.apple_payA collection of endpoints for managing application's top-level domain or subdomain accepting payment via Apple Pay3
Balancepaystack.balanceA collection of endpoints gaining insights into the amount on an integration2
Bankpaystack.bankA collection of endpoints for managing bank details3
BulkChargepaystack.bulk_chargeA collection of endpoints for creating and managing multiple recurring payments6
Chargepaystack.chargeA collection of endpoints for configuring and managing the payment channels when initiating a payment7
Customerpaystack.customerA collection of endpoints for creating and managing customers on an integration12
DedicatedVirtualAccountpaystack.dedicated_virtual_accountA collection of endpoints for creating and managing payment accounts for customers9
DirectDebitpaystack.direct_debitA collection of endpoints for managing Direct Debit2
Disputepaystack.disputeA collection of endpoints for managing transactions complaint made by customers8
Integrationpaystack.integrationA collection of endpoints for managing some settings on an integration2
Miscellaneouspaystack.miscellaneousA collection of endpoints that provides utility functions3
Orderpaystack.orderA collection of endpoints for creating and managing orders5
Pagepaystack.pageA collection of endpoints for creating and managing links for the collection of payment for products6
PaymentRequestpaystack.payment_requestA collection of endpoints for managing invoices for the payment of goods and services9
Planpaystack.planA collection of endpoints for creating and managing recurring payment configuration4
Productpaystack.productA collection of endpoints for creating and managing inventories5
Refundpaystack.refundA collection of endpoints for creating and managing transaction reimbursement4
Settlementpaystack.settlementA collection of endpoints for gaining insights into payouts2
Splitpaystack.splitA collection of endpoints for spliting a transaction and managing the splits6
Storefrontpaystack.storefrontA collection of endpoints for creating and managing storefronts11
Subaccountpaystack.subaccountA collection of endpoints for creating and managing accounts for sharing a transaction with4
Subscriptionpaystack.subscriptionA collection of endpoints for creating and managing recurring payments7
Terminalpaystack.terminalA collection of endpoints for building delightful in-person payment experiences8
Transactionpaystack.transactionA collection of endpoints for managing payments9
Transferpaystack.transferA collection of endpoints for automating sending money to beneficiaries11
TransferRecipientpaystack.transfer_recipientA collection of endpoints for creating and managing beneficiaries that you send money to6
VirtualTerminalpaystack.virtual_terminalA collection of endpoints for building in-person payments without a physical terminal9

Detailed method-level documentation for each resource is available in docs/.


Contributing

⚠️This SDK is auto-generated from the Paystack OpenAPI specification. Regenerate instead of manually editing generated files.

To request endpoint/schema changes, open an issue or pull request against the Paystack OpenAPI specification.


License

MIT © Paystack

About

Paystack's Ruby SDK implementing Paystack's APIs

Resources

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages