Skip to content

Customers ​

Customer operations.

Use it as client.customers. 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
customers.list(
  use_cursor: nil,
  next_cursor: nil,
  previous: nil,
  from: nil,
  to: nil,
  per_page: nil,
  page: nil
)

List Customers.

List customers 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
fromStringThe start date
toStringThe end date
per_pageIntegerThe number of records to fetch per request
pageIntegerThe offset to retrieve data from

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

create ​

ruby
customers.create(email:, first_name: nil, last_name: nil, phone: nil, metadata: nil)

Create Customer.

Create a customer on your integration

ParameterTypeRequiredDescription
emailStringyesCustomer's email address
first_nameStringCustomer's first name
last_nameStringCustomer's last name
phoneStringCustomer's phone number
metadataHashA set of key/value pairs that you can attach to the customer.

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

fetch ​

ruby
customers.fetch(email_or_code:)

Fetch Customer.

Get details of a customer on your integration.

ParameterTypeRequiredDescription
email_or_codeStringyesThe code for the customer gotten from the response of the customer creation

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

update ​

ruby
customers.update(code:, first_name: nil, last_name: nil, phone: nil, metadata: nil)

Update Customer.

Update a customer's details on your integration

ParameterTypeRequiredDescription
codeStringyesThe code for the customer gotten from the response of the customer creation
first_nameStringCustomer's first name
last_nameStringCustomer's last name
phoneStringCustomer's phone number
metadataHashA set of key/value pairs that you can attach to the customer.

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

set_risk_action ​

ruby
customers.set_risk_action(customer:, risk_action: nil)

Set Risk Action.

Set customer's risk action by whitelisting or blacklisting the customer

ParameterTypeRequiredDescription
customerStringyesThe customer code from the response of the customer creation
risk_actionStringThis determines the fraud rules that should be applied to the customer One of: allow, deny, default.

Paystack docs: https://paystack.com/docs/api/customer/#whitelist-blacklist

validate ​

ruby
customers.validate(
  code:,
  first_name:,
  last_name:,
  type:,
  country:,
  bvn:,
  bank_code:,
  account_number:,
  middle_name: nil,
  value: nil
)

Validate Customer.

Validate a customer's identity

ParameterTypeRequiredDescription
codeStringyesThe code for the customer gotten from the response of the customer creation
first_nameStringyesCustomer's first name
last_nameStringyesCustomer's last name
typeStringyesPredefined types of identification.
countryStringyesTwo-letter country code of identification issuer
bvnStringyesCustomer's Bank Verification Number
bank_codeStringyesYou can get the list of bank codes by calling the List Banks endpoint (https://api.paystack.co/bank).
account_numberStringyesCustomer's bank account number.
middle_nameStringCustomer's middle name
valueStringCustomer's identification number.

Paystack docs: https://paystack.com/docs/api/customer/#validate

initialize_authorization ​

ruby
customers.initialize_authorization(email:, channel:, callback_url: nil, account: nil, address: nil)

Initialize Authorization.

Initiate a request to create a reusable authorization code for recurring transactions

ParameterTypeRequiredDescription
emailStringyesCustomer's email address
channelStringyesdirect_debit is the only supported option for now One of: direct_debit.
callback_urlStringFully qualified url (e.g.
accountHash
addressHash

Paystack docs: https://paystack.com/docs/api/customer/#initialize-authorization

verify_authorization ​

ruby
customers.verify_authorization(reference:)

Verify Authorization.

Check the status of an authorization request

ParameterTypeRequiredDescription
referenceStringyesThe reference returned in the initialization response

Paystack docs: https://paystack.com/docs/api/customer/#verify-authorization

deactivate_authorization ​

ruby
customers.deactivate_authorization(authorization_code:)

Deactivate Authorization.

Deactivate an authorization for any payment channel.

ParameterTypeRequiredDescription
authorization_codeStringyesAuthorization code to be deactivated

Paystack docs: https://paystack.com/docs/api/customer/#deactivate-authorization

initialize_direct_debit ​

ruby
customers.initialize_direct_debit(id:, account:, address:)

Initialize Direct Debit.

Initialize the process of linking an account to a customer for Direct Debit transactions

ParameterTypeRequiredDescription
idIntegeryesThe ID of the customer to initialize the direct debit for
accountHashyes
addressHashyes

Paystack docs: https://paystack.com/docs/api/customer/#initialize-direct-debit

direct_debit_activation_charge ​

ruby
customers.direct_debit_activation_charge(id:, authorization_id:)

Direct Debit Activation Charge.

Trigger an activation charge on an inactive mandate on behalf of your customer

ParameterTypeRequiredDescription
idIntegeryesThe customer ID attached to the authorization
authorization_idIntegeryesThe authorization ID gotten from the initiation response

Paystack docs: https://paystack.com/docs/api/customer/#directdebit-activation-charge

fetch_mandate_authorizations ​

ruby
customers.fetch_mandate_authorizations(id:)

Fetch Mandate Authorizations.

Get the list of direct debit mandates associated with a customer

ParameterTypeRequiredDescription
idIntegeryesThe customer ID for the authorizations to fetch

Paystack docs: https://paystack.com/docs/api/customer/#directdebit-mandate-authorizations

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