Skip to content

Transactions ​

Transaction operations.

Use it as client.transactions. 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 ​

initiate ​

ruby
transactions.initiate(
  email:,
  amount:,
  currency: nil,
  reference: nil,
  channels: nil,
  callback_url: nil,
  plan: nil,
  invoice_limit: nil,
  split_code: nil,
  split: nil,
  subaccount: nil,
  transaction_charge: nil,
  bearer: nil,
  label: nil,
  metadata: nil
)

Initialize Transaction.

Create a new transaction

ParameterTypeRequiredDescription
emailStringyesCustomer's email address
amountIntegeryesAmount should be in smallest denomination of the currency.
currencyStringList of all support currencies One of: GHS, KES, NGN, ZAR, USD.
referenceStringUnique transaction reference.
channelsArrayAn array of payment channels to control what channels you want to make available to the user to make a payment with
callback_urlStringFully qualified url, e.g.
planStringIf transaction is to create a subscription to a predefined plan, provide plan code here.
invoice_limitIntegerNumber of times to charge customer during subscription to plan
split_codeStringThe split code of the transaction split
splitHashSplit configuration for transactions
subaccountStringThe code for the subaccount that owns the payment
transaction_chargeStringA flat fee to charge the subaccount for a transaction.
bearerStringThe bearer of the transaction charge One of: account, subaccount.
labelStringUsed to replace the email address shown on the Checkout
metadataStringCustom data as a JSON object (a Hash, or a JSON string).

Paystack docs: https://paystack.com/docs/api/transaction/#initialize

charge_authorization ​

ruby
transactions.charge_authorization(
  email:,
  amount:,
  authorization_code:,
  reference: nil,
  currency: nil,
  split_code: nil,
  split: nil,
  subaccount: nil,
  transaction_charge: nil,
  bearer: nil,
  metadata: nil,
  queue: nil
)

Charge Authorization.

Charge all authorizations marked as reusable with this endpoint whenever you need to receive payments

ParameterTypeRequiredDescription
emailStringyesCustomer's email address
amountIntegeryesAmount in the lower denomination of your currency
authorization_codeStringyesValid authorization code to charge
referenceStringUnique transaction reference.
currencyStringList of all support currencies One of: GHS, KES, NGN, ZAR, USD.
split_codeStringThe split code of the transaction split
splitHashSplit configuration for transactions
subaccountStringThe code for the subaccount that owns the payment
transaction_chargeStringA flat fee to charge the subaccount for a transaction.
bearerStringThe bearer of the transaction charge One of: account, subaccount.
metadataStringStringified JSON object of custom data
queueBooleanIf you are making a scheduled charge call, it is a good idea to queue them so the processing system does not get overloaded causing transaction processing errors.

Paystack docs: https://paystack.com/docs/api/transaction/#charge-authorization

partial_debit ​

ruby
transactions.partial_debit(
  email:,
  amount:,
  authorization_code:,
  currency:,
  at_least: nil,
  reference: nil
)

Partial Debit.

Retrieve part of a payment from a customer

ParameterTypeRequiredDescription
emailStringyesCustomer's email address
amountIntegeryesSpecified in the lowest denomination of your currency
authorization_codeStringyesValid authorization code to charge
currencyStringyesList of all support currencies One of: GHS, KES, NGN, ZAR, USD.
at_leastStringMinimum amount to charge
referenceStringUnique transaction reference.

Paystack docs: https://paystack.com/docs/api/transaction/#partial-debit

verify ​

ruby
transactions.verify(reference:)

Verify Transaction.

Verify a previously initiated transaction using it's reference

ParameterTypeRequiredDescription
referenceStringyesThe transaction reference to verify

Paystack docs: https://paystack.com/docs/api/transaction/#verify

list ​

ruby
transactions.list(
  use_cursor: nil,
  next_cursor: nil,
  previous: nil,
  per_page: nil,
  page: nil,
  from: nil,
  to: nil,
  status: nil,
  source: nil,
  terminal_id: nil,
  virtual_account_number: nil,
  customer_id: nil,
  amount: nil,
  settlement: nil,
  channel: nil,
  subaccount_code: nil,
  split_code: nil
)

List Transactions.

List transactions that has occurred on your integration

ParameterTypeRequiredDescription
use_cursorBooleanA flag to indicate if cursor based pagination should be used
next_cursorStringAn alphanumeric value returned for every cursor based retrieval, used to retrieve the next set of data
previousStringAn alphanumeric value returned for every cursor based retrieval, used to retrieve the previous set of data
per_pageIntegerThe number of records to fetch per request
pageIntegerThe offset to retrieve data from
fromStringThe start date
toStringThe end date
statusStringFilter transaction by status One of: success, failed, abandoned, reversed.
sourceStringThe origin of the payment One of: merchantApi, checkout, pos, virtualTerminal.
terminal_idStringFilter transactions by a terminal ID
virtual_account_numberStringFilter transactions by a virtual account number
customer_idIntegerFilter transactions by a customer code
amountIntegerFilter transactions by a specific amount
settlementIntegerThe settlement ID to filter for settled transactions
channelStringThe payment method the customer used to complete the transaction One of: card, pos, bank, dedicated_nuban, ussd, bank_transfer.
subaccount_codeStringFilter transaction by subaccount code
split_codeStringFilter transaction by split code

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

fetch ​

ruby
transactions.fetch(id:)

Fetch Transaction.

Fetch a transaction to get its details

ParameterTypeRequiredDescription
idIntegeryesThe ID of the transaction to fetch

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

timeline ​

ruby
transactions.timeline(id:)

Fetch Transaction Timeline.

Fetch the steps taken from the initiation to the completion of a transaction

ParameterTypeRequiredDescription
idIntegeryesThe ID of the transaction to fetch

Paystack docs: https://paystack.com/docs/api/transaction/#view-timeline

totals ​

ruby
transactions.totals(from: nil, to: nil)

Transaction Totals.

Get the total amount of all transactions

ParameterTypeRequiredDescription
fromStringThe start date
toStringThe end date

Paystack docs: https://paystack.com/docs/api/transaction/#totals

export ​

ruby
transactions.export(
  from: nil,
  to: nil,
  status: nil,
  customer_id: nil,
  subaccount_code: nil,
  settlement: nil,
  currency: nil,
  amount: nil,
  settled: nil,
  payment_page: nil
)

Export Transactions.

Download transactions that occurred on your integration for a specific timeframe

ParameterTypeRequiredDescription
fromStringThe start date
toStringThe end date
statusStringFilter by the status of the transaction One of: success, failed, abandoned, reversed, all.
customer_idIntegerFilter by customer ID
subaccount_codeStringFilter by subaccount code
settlementIntegerFilter by the settlement ID
currencyStringSpecify the transaction currency to export.
amountIntegerFilter transactions by amount, using the supported currency subunit.
settledBooleanSet to true to export only settled transactions, false for pending transactions.
payment_pageIntegerSpecify a payment page's id to export only transactions conducted on said page.

Paystack docs: https://paystack.com/docs/api/transaction/#export

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