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_nameandphoneare 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.
$customer = paystack()->customer()->create([
'email' => '[email protected]',
'first_name' => 'Zero',
'last_name' => 'Sum',
'phone' => '+2348123456789',
'metadata' => [
'custom_field' => 'value'
]
]);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
email | String | Yes | Customer's email address. |
first_name | String | No | Customer's first name. |
last_name | String | No | Customer's last name. |
phone | String | No | Customer's phone number. |
metadata | Object | No | A set of key/value pairs that you can attach to the customer. |
List Customers
List customers available on your integration.
// 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.
$emailOrCode = 'CUS_xnxdt6s1zg1f4nx'; // or '[email protected]'
$details = paystack()->customer()->fetch($emailOrCode);Update Customer
Update a customer's details on your integration.
$code = 'CUS_xnxdt6s1zg1f4nx';
$updated = paystack()->customer()->update($code, [
'first_name' => 'BoJack',
'last_name' => 'Horseman',
'metadata' => [
'twitter' => '@bojack'
]
]);Validate Customer
Validate a customer's identity.
$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
| Parameter | Type | Required | Description |
|---|---|---|---|
first_name | String | Yes | Customer's first name. |
last_name | String | Yes | Customer's last name. |
type | String | Yes | Predefined types of identification. Only bank_account is supported at the moment. |
value | String | No | Customer's identification number. |
country | String | Yes | 2 letter country code of identification issuer. |
bvn | String | Yes | Customer's Bank Verification Number. |
bank_code | String | Yes | You can get the list of Bank Codes by calling the List Banks endpoint. (required if type is bank_account). |
account_number | String | Yes | Customer's bank account number. (required if type is bank_account). |
middle_name | String | No | Customer's middle name. |
Whitelist/Blacklist Customer
Whitelist or blacklist a customer on your integration.
$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.
$authorizationCode = 'AUTH_ekk8t49ogj';
$response = paystack()->customer()->deactivateAuthorization($authorizationCode);Initialize Authorization
Initiate a request to create a reusable authorization code for recurring transactions.
$response = paystack()->customer()->initializeAuthorization([
'email' => '[email protected]',
'channel' => 'direct_debit',
'callback_url' => 'https://stephenasare.dev'
]);Verify Authorization
Check the status of an authorization request.
$reference = 'dfbzfotsrbv4n5s82t4mp5b5mfn51h';
$status = paystack()->customer()->verifyAuthorization($reference);