Payments
Create a subaccount
In a nutshell
Create a subaccount for each partner who receives a share of your payments, and save its subaccount code.
Create a subaccount for each partner who receives part of a payment. Paystack settles the partner's share into the subaccount's bank account. When you split a payment, you identify the partner by the subaccount's subaccount_code.
You can also create subaccounts on the Subaccounts page of your Dashboard.
Copy linkGet the partner's bank code
Create Subaccount identifies the partner's bank by its code, not its name. Call List Banks, find the partner's bank in the response, and copy its code:
GETapi.paystack.co/bank
curl "https://api.paystack.co/bank?country=south%20africa" \
-H "Authorization: Bearer $PAYSTACK_SECRET_KEY" \
-X GETconst https = require("https");
const options = {
hostname: "api.paystack.co",
port: 443,
path: "/bank?country=south%20africa",
method: "GET",
headers: {
Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}`,
},
};
const req = https.request(options, (res) => {
let data = "";
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
console.log(res.statusCode, JSON.parse(data));
});
});
req.on("error", (error) => {
console.error(error);
});
req.end();<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.paystack.co/bank?country=south%20africa",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer " . getenv("PAYSTACK_SECRET_KEY"),
),
));
$response = curl_exec($curl);
echo $response;
?>This response is trimmed to the bank used in the examples on this page. You pass its code as settlement_bank when you create the subaccount.
Copy linkConfirm the account details
If the partner's bank supports validation, call Validate Account with their account number, bank code, account holder name, and identity or business registration number. For the full flow, see Verify an account number.
Check the account before you create the subaccount
Paystack pays the partner's share into the account on the subaccount. If the details are wrong, the money goes to the wrong account, and Paystack isn't responsible for it.
Copy linkCreate the subaccount
Send the partner's business name, bank code, account number, and percentage_charge to Create Subaccount.
percentage_charge is your share
Set percentage_charge to the percentage of each payment your main account keeps, not the partner's share.
This subaccount gives your main account 20% of each payment and Oasis Foods 80%:
POSTapi.paystack.co/subaccount
curl https://api.paystack.co/subaccount \
-H "Authorization: Bearer $PAYSTACK_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"business_name": "Oasis Foods",
"settlement_bank": "051001",
"account_number": "0123456047",
"percentage_charge": 20
}' \
-X POSTconst https = require("https");
const params = JSON.stringify({
"business_name": "Oasis Foods",
"settlement_bank": "051001",
"account_number": "0123456047",
"percentage_charge": 20
});
const options = {
hostname: "api.paystack.co",
port: 443,
path: "/subaccount",
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}`,
"Content-Type": "application/json",
},
};
const req = https.request(options, (res) => {
let data = "";
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
console.log(res.statusCode, JSON.parse(data));
});
});
req.on("error", (error) => {
console.error(error);
});
req.write(params);
req.end();<?php
$fields = [
"business_name" => "Oasis Foods",
"settlement_bank" => "051001",
"account_number" => "0123456047",
"percentage_charge" => 20,
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.paystack.co/subaccount",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($fields),
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer " . getenv("PAYSTACK_SECRET_KEY"),
"Content-Type: application/json",
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
echo curl_getinfo($curl, CURLINFO_HTTP_CODE) . " " . $response;
?>Copy linkSave the subaccount code
Store the subaccount_code (ACCT_6uujpqtzmnufzkw) with the partner's record. Pass it as subaccount to split a payment with one partner, or add it to a split to divide a payment across several subaccounts.
To change the bank account or percentage_charge later, use Update Subaccount.