# Split a payment with a subaccount

> Pass a subaccount code when you initialize a payment to split it with one partner by percentage or fixed amount.

Pass a `subaccount` code when you initialize a payment to split it with one partner. Paystack settles your share to your main account and the partner's share to the subaccount.

Before you start, [create a subaccount](/payments/split-payments/subaccounts) for the partner and save its `subaccount_code`. To divide one payment between several partners, [split it across multiple subaccounts](/payments/split-payments/multi-split) instead.

## Collect a payment with the subaccount

Add `subaccount` to your [Initialize Transaction](/api/transaction#initialize) request. Paystack splits the payment by the subaccount's `percentage_charge`.

<request-response>
<template v-slot:curl="">

```bash
curl https://api.paystack.co/transaction/initialize \
  -H "Authorization: Bearer $PAYSTACK_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "ada.obi@example.com",
    "amount": 2000000,
    "subaccount": "ACCT_6uujpqtzmnufzkw"
  }' \
  -X POST
```

</template>

<template v-slot:js="">

```javascript
const https = require("https");

const params = JSON.stringify({
  "email": "ada.obi@example.com",
  "amount": 2000000,
  "subaccount": "ACCT_6uujpqtzmnufzkw"
});

const options = {
  hostname: "api.paystack.co",
  port: 443,
  path: "/transaction/initialize",
  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();
```

</template>

<template v-slot:php="">

```php
<?php
$fields = [
  "email" => "ada.obi@example.com",
  "amount" => 2000000,
  "subaccount" => "ACCT_6uujpqtzmnufzkw",
];

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.paystack.co/transaction/initialize",
  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;
?>
```

</template>

<template v-slot:response="">

```json
{
  "status": true,
  "message": "Authorization URL created",
  "data": {
    "authorization_url": "https://checkout.paystack.com/0peioxfhpn7ghr1",
    "access_code": "0peioxfhpn7ghr1",
    "reference": "s8h3qm1vzc"
  }
}
```

</template>
</request-response>

Send the customer to the `authorization_url`, or open checkout with the `access_code`. Paystack applies the split when the payment succeeds.

Amounts are in the currency's subunit (<localized-value page-key="markets" path="subunit">



</localized-value>

), so 2000000 is <localized-value page-key="markets" path="example_amount">



</localized-value>

. On this 2000000 payment, with `percentage_charge: 20`:

- Oasis Foods gets 1600000.
- Your main account gets 400000 and pays the Paystack fee from it.

## Keep a fixed amount instead of a percentage

To keep a fixed amount in your main account, pass `transaction_charge` in the currency's subunit. It overrides `percentage_charge` for this payment only. Here your main account gets 300000 and Oasis Foods gets the rest:

<request-response>
<template v-slot:curl="">

```bash
curl https://api.paystack.co/transaction/initialize \
  -H "Authorization: Bearer $PAYSTACK_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "ada.obi@example.com",
    "amount": 2000000,
    "subaccount": "ACCT_6uujpqtzmnufzkw",
    "transaction_charge": 300000
  }' \
  -X POST
```

</template>

<template v-slot:js="">

```javascript
const https = require("https");

const params = JSON.stringify({
  "email": "ada.obi@example.com",
  "amount": 2000000,
  "subaccount": "ACCT_6uujpqtzmnufzkw",
  "transaction_charge": 300000
});

const options = {
  hostname: "api.paystack.co",
  port: 443,
  path: "/transaction/initialize",
  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();
```

</template>

<template v-slot:php="">

```php
<?php
$fields = [
  "email" => "ada.obi@example.com",
  "amount" => 2000000,
  "subaccount" => "ACCT_6uujpqtzmnufzkw",
  "transaction_charge" => 300000,
];

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.paystack.co/transaction/initialize",
  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;
?>
```

</template>

<template v-slot:response="">

```json
{
  "status": true,
  "message": "Authorization URL created",
  "data": {
    "authorization_url": "https://checkout.paystack.com/8w3hdrq5vkc1zpe",
    "access_code": "8w3hdrq5vkc1zpe",
    "reference": "t7k2mzq9xa"
  }
}
```

</template>
</request-response>

## Choose who pays the Paystack fee

To make the subaccount pay the Paystack fee, pass `bearer: "subaccount"`. Otherwise your main account pays it.

<request-response>
<template v-slot:curl="">

```bash
curl https://api.paystack.co/transaction/initialize \
  -H "Authorization: Bearer $PAYSTACK_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "ada.obi@example.com",
    "amount": 2000000,
    "subaccount": "ACCT_6uujpqtzmnufzkw",
    "bearer": "subaccount"
  }' \
  -X POST
```

</template>

<template v-slot:js="">

```javascript
const https = require("https");

const params = JSON.stringify({
  "email": "ada.obi@example.com",
  "amount": 2000000,
  "subaccount": "ACCT_6uujpqtzmnufzkw",
  "bearer": "subaccount"
});

const options = {
  hostname: "api.paystack.co",
  port: 443,
  path: "/transaction/initialize",
  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();
```

</template>

<template v-slot:php="">

```php
<?php
$fields = [
  "email" => "ada.obi@example.com",
  "amount" => 2000000,
  "subaccount" => "ACCT_6uujpqtzmnufzkw",
  "bearer" => "subaccount",
];

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.paystack.co/transaction/initialize",
  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;
?>
```

</template>

<template v-slot:response="">

```json
{
  "status": true,
  "message": "Authorization URL created",
  "data": {
    "authorization_url": "https://checkout.paystack.com/k1v9tq7ymz3rdo2",
    "access_code": "k1v9tq7ymz3rdo2",
    "reference": "b4xw8lnq2e"
  }
}
```

</template>
</request-response>

<callout title="The subaccount's share must cover the fee" type="warning">

Use `bearer: "subaccount"` only when the subaccount's share is larger than the Paystack fee. Otherwise, Initialize Transaction returns `400 Bad Request`.

</callout>

## Split Popup and saved-card payments

Use the equivalent fields to split a payment from Paystack Popup or Charge Authorization:

- **Paystack Popup**: pass `subaccountCode`, `transactionCharge`, and `bearer`. See [Split transaction](/developer-tools/inline-js#split-transaction).
- **Charge Authorization**: pass `subaccount`, `transaction_charge`, and `bearer` to [Charge Authorization](/api/transaction#chargeAuthorization) to split a repeat payment from a saved card.

## Confirm the split

Use the `charge.success` webhook as your primary signal to fulfill orders, grant access, or update your database. The customer can close the page before your callback runs, but the webhook still arrives.

Add your webhook URL on the [Paystack Dashboard](https://dashboard.paystack.com/v2/developers/api-configuration), and [verify the signature](/developer-tools/integration/webhooks#verify-webhook-signatures) on every event with your webhook signing secret.

To see each party's share, [verify the payment](/api/transaction#verify) with its `reference`. In `fees_split`, each share is in the currency's subunit and `integration` is your main account. This response, trimmed to the split fields, is for the first 2000000 payment on this page:

<localized-snippet src="payments/split-payments/verify-subaccount-split">



</localized-snippet>

The fee in this example uses standard pricing for <localized-value page-key="markets" path="currency_code">



</localized-value>

 local card payments. Your fee depends on your pricing and the payment channel.
