Skip to content

Split a payment between merchants

View as Markdown

Overview

Split shares the net amount of a payment among several merchants. You add a beneficiary, the beneficiary accepts, and then you set the percentages. A beneficiary is a verified merchant, and it receives its share in its own balance.

Before you begin

Your key needs split:write in its scope, and you use your secret key, shown below as sk_test_YOUR_SECRET_KEY. Use a sandbox key while you build. The beneficiary is a second merchant with its own secret key, and step 2 uses that key. The beneficiary must have completed identity verification and must be ACTIVE. TapPay first sets your split_type. STATIC uses saved rules, DYNAMIC_ALLOWED takes the split from each invoice, and HYBRID uses the saved rules unless an invoice sends its own. NONE turns the split off.

Steps

Add a beneficiary

Send the merchant code of the beneficiary. The request stays PENDING until the beneficiary accepts it. The response has the request id and its version.

curl -sS -X POST "https://api.tappay.mn/api/v1/split/beneficiaries" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"beneficiaryMerchantCode":"YOUR_BENEFICIARY_MERCHANT_CODE"}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const splitBeneficiary = await tappay.splitBeneficiaries.create({ body: { beneficiaryMerchantCode: 'YOUR_BENEFICIARY_MERCHANT_CODE' } });
console.log(JSON.stringify(splitBeneficiary));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$splitBeneficiary = $tappay->splitBeneficiaries->create(['body' => ['beneficiaryMerchantCode' => 'YOUR_BENEFICIARY_MERCHANT_CODE']]);
echo json_encode($splitBeneficiary);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
split_beneficiary = client.split_beneficiaries.create({"body": {"beneficiaryMerchantCode": "YOUR_BENEFICIARY_MERCHANT_CODE"}})
print(json.dumps(split_beneficiary))

Accept as the beneficiary

The beneficiary merchant accepts with its own secret key, which the example shows as the beneficiary key. Put the request id from step 1 in the path, and send the version of the request, which is 1 for a new request. Nobody can accept for the beneficiary, and you cannot split to any account that has not accepted.

curl -sS -X POST "https://api.tappay.mn/api/v1/split/beneficiaries/BENEFICIARY_ID/accept" \
  -H "Authorization: Bearer sk_test_BENEFICIARY_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"version":1}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_BENEFICIARY_SECRET_KEY' });
const splitBeneficiary = await tappay.splitBeneficiaries.accept({ id: 'BENEFICIARY_ID', body: { version: 1 } });
console.log(JSON.stringify(splitBeneficiary));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_BENEFICIARY_SECRET_KEY']);
$splitBeneficiary = $tappay->splitBeneficiaries->accept(['id' => 'BENEFICIARY_ID', 'body' => ['version' => 1]]);
echo json_encode($splitBeneficiary);
import json
import tappay

client = tappay.TapPay("sk_test_BENEFICIARY_SECRET_KEY")
split_beneficiary = client.split_beneficiaries.accept({"id": "BENEFICIARY_ID", "body": {"version": 1}})
print(json.dumps(split_beneficiary))

Set the rules

Replace the rules of your merchant. For one terminal, send scope TERMINAL and its scopeId. Each rule has a beneficiaryMerchantCode and a percent. The percentages add up to at most 100, and you keep the rest, so more than 100 returns 422 PYO-205. A rule can start later with validFrom, but not in the past.

curl -sS -X PUT "https://api.tappay.mn/api/v1/split/rules" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"scope":"MERCHANT","rules":[{"beneficiaryMerchantCode":"YOUR_BENEFICIARY_MERCHANT_CODE","percent":"20"}]}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const splitRule = await tappay.splitRules.update({
  body: {
    scope: 'MERCHANT',
    rules: [
      {
        beneficiaryMerchantCode: 'YOUR_BENEFICIARY_MERCHANT_CODE',
        percent: '20',
      },
    ],
  },
});
console.log(JSON.stringify(splitRule));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$splitRule = $tappay->splitRules->update([
    'body' => [
        'scope' => 'MERCHANT',
        'rules' => [
            [
                'beneficiaryMerchantCode' => 'YOUR_BENEFICIARY_MERCHANT_CODE',
                'percent' => '20',
            ],
        ],
    ],
]);
echo json_encode($splitRule);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
split_rule = client.split_rules.update({
    "body": {
        "scope": "MERCHANT",
        "rules": [
            {
                "beneficiaryMerchantCode": "YOUR_BENEFICIARY_MERCHANT_CODE",
                "percent": "20",
            },
        ],
    },
})
print(json.dumps(split_rule))

Read the rules

Read the rules that apply now. The response shows your splitType and your primaryPercent, and history=true adds the earlier rule sets.

curl -sS "https://api.tappay.mn/api/v1/split/rules?scope=MERCHANT" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const splitRule = await tappay.splitRules.retrieve({ query: { scope: 'MERCHANT' } });
console.log(JSON.stringify(splitRule));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$splitRule = $tappay->splitRules->retrieve(['query' => ['scope' => 'MERCHANT']]);
echo json_encode($splitRule);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
split_rule = client.split_rules.retrieve({"scope": "MERCHANT"})
print(json.dumps(split_rule))

List your beneficiaries

List the beneficiaries with a status filter. Only an ACTIVE beneficiary can be in a rule. A beneficiary can decline a request with reject.

curl -sS "https://api.tappay.mn/api/v1/split/beneficiaries?status=ACTIVE" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const page = await tappay.splitBeneficiaries.list({ query: { status: 'ACTIVE' } }).firstPage();
console.log(JSON.stringify(page));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$page = $tappay->splitBeneficiaries->list(['query' => ['status' => 'ACTIVE']])->firstPage();
echo json_encode(['data' => $page->data, 'hasMore' => $page->hasMore, 'nextCursor' => $page->nextCursor]);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
page = client.split_beneficiaries.list({"status": "ACTIVE"}).first_page()
print(json.dumps({"data": page.data, "has_more": page.has_more, "next_cursor": page.next_cursor}))

Revoke the beneficiary

Revoke the link when the split should end. Put the request id from step 1 in the path, send the current version, which is 2 after the beneficiary accepted, and a reason. The beneficiary becomes REVOKED, and later payments are no longer split with it. You can add the same merchant again after that, so in the sandbox you can run this guide from step 1 again.

curl -sS -X POST "https://api.tappay.mn/api/v1/split/beneficiaries/BENEFICIARY_ID/revoke" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Contract ended","version":2}'
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const splitBeneficiary = await tappay.splitBeneficiaries.revoke({ id: 'BENEFICIARY_ID', body: { reason: 'Contract ended', version: 2 } });
console.log(JSON.stringify(splitBeneficiary));
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$splitBeneficiary = $tappay->splitBeneficiaries->revoke(['id' => 'BENEFICIARY_ID', 'body' => ['reason' => 'Contract ended', 'version' => 2]]);
echo json_encode($splitBeneficiary);
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
split_beneficiary = client.split_beneficiaries.revoke({"id": "BENEFICIARY_ID", "body": {"reason": "Contract ended", "version": 2}})
print(json.dumps(split_beneficiary))

Verify

Read the rules and the beneficiaries as in steps 4 and 5. After step 6 the beneficiary is REVOKED. A beneficiary is PENDING, ACTIVE, REJECTED or REVOKED.

TapPay splits the net amount, which is the full amount minus the mdr_rate fee. You pay the whole fee as the main merchant. What is left after the percentages stays with you, and rounding goes to you too. An overpaid payment is not split. A refund or a chargeback returns money from each beneficiary in the same ratio as the split. If a balance is too small, it goes negative.

Each beneficiary gets its share in its own balance, and it is paid out by its own payout_policy. Its balance and bank account can be at another bank.

Common mistakes

  • Adding a merchant that has not completed identity verification. TapPay returns PYO-203.
  • Adding yourself or adding the same beneficiary twice. TapPay returns PYO-202 or PYO-204.
  • Putting a beneficiary in a rule before it is ACTIVE. TapPay returns PYO-206.
  • Accepting or deciding on a request that is no longer PENDING. TapPay returns PYO-208.
  • Setting a rule that starts in the past, or one for a terminal that is not yours. TapPay returns PYO-210 or PYO-209.
  • Expecting a split on an overpaid payment, or a split to any bank account. Only an accepted, verified merchant can be a beneficiary.

Next steps

See how a refund returns shares in the refunds guide. See Add a beneficiary, Accept a beneficiary, Set split rules and Retrieve split rules.

To split a single invoice, send split when you create the invoice, with the merchantId and percent of each beneficiary. This works when your split_type is DYNAMIC_ALLOWED or HYBRID.

{
  "split": [
    { "merchantId": "BENEFICIARY_MERCHANT_ID", "percent": "20" }
  ]
}