Skip to content

Customers

The CustomerResource allows you to create and manage customers on your integration.

Create Customer

Create a customer on your integration.

Note: The first_name, last_name and phone are optional parameters. However, when creating a customer that would be assigned a Dedicated Virtual Account and your business category falls under Betting, Financial services, and General Service, then these parameters become compulsory.

php

$customer = paystack()->customer()->create([
    'email' => '[email protected]',
    'first_name' => 'Zero',
    'last_name' => 'Sum',
    'phone' => '+2348123456789',
    'metadata' => [
        'custom_field' => 'value'
    ]
]);

Parameters

ParameterTypeRequiredDescription
emailStringYesCustomer's email address.
first_nameStringNoCustomer's first name.
last_nameStringNoCustomer's last name.
phoneStringNoCustomer's phone number.
metadataObjectNoA set of key/value pairs that you can attach to the customer.

List Customers

List customers available on your integration.

php
// List all customers
$customers = paystack()->customer()->list();

// Filter customers
$filtered = paystack()->customer()->list([
    'perPage' => 20,
    'page' => 1,
    'from' => '2023-01-01',
    'to' => '2023-12-31'
]);

Fetch Customer

Get details of a customer on your integration.

php
$emailOrCode = 'CUS_xnxdt6s1zg1f4nx'; // or '[email protected]'

$details = paystack()->customer()->fetch($emailOrCode);

Update Customer

Update a customer's details on your integration.

php
$code = 'CUS_xnxdt6s1zg1f4nx';

$updated = paystack()->customer()->update($code, [
    'first_name' => 'BoJack',
    'last_name' => 'Horseman',
    'metadata' => [
        'twitter' => '@bojack'
    ]
]);

Validate Customer

Validate a customer's identity.

php
$code = 'CUS_xnxdt6s1zg1f4nx';

$response = paystack()->customer()->validate($code, [
    'country' => 'NG',
    'type' => 'bank_account',
    'account_number' => '0123456789',
    'bvn' => '20012345677',
    'bank_code' => '007',
    'first_name' => 'Asta',
    'last_name' => 'Lavista'
]);

Parameters

ParameterTypeRequiredDescription
first_nameStringYesCustomer's first name.
last_nameStringYesCustomer's last name.
typeStringYesPredefined types of identification. Only bank_account is supported at the moment.
valueStringNoCustomer's identification number.
countryStringYes2 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. (required if type is bank_account).
account_numberStringYesCustomer's bank account number. (required if type is bank_account).
middle_nameStringNoCustomer's middle name.

Whitelist/Blacklist Customer

Whitelist or blacklist a customer on your integration.

php
$response = paystack()->customer()->setRiskAction([
    'customer' => 'CUS_xr58yrr2ujlft9k',
    'risk_action' => 'allow' // 'allow' to whitelist, 'deny' to blacklist, 'default' to reset
]);

Deactivate Authorization

Deactivate an authorization for any payment channel.

php
$authorizationCode = 'AUTH_ekk8t49ogj';

$response = paystack()->customer()->deactivateAuthorization($authorizationCode);

Initialize Authorization

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

php
$response = paystack()->customer()->initializeAuthorization([
    'email' => '[email protected]',
    'channel' => 'direct_debit',
    'callback_url' => 'https://stephenasare.dev'
]);

Verify Authorization

Check the status of an authorization request.

php
$reference = 'dfbzfotsrbv4n5s82t4mp5b5mfn51h';

$status = paystack()->customer()->verifyAuthorization($reference);

Released under the MIT License.