Profit Sharing
Description of Profit Sharing Feature
The profit sharing feature transfers part of a payment order's amount to other recipient merchants. There are two kinds of profit sharing:
- Order profit sharing: shares a specific payment order (with
relationTxnId). - Global profit sharing: without
relationTxnId, automatically shares every payment order cleared from then on according to the configuration.
A profit sharing request is not executed immediately. It is executed in the daily settlement run, and the result is sent through the callback. You can also get it from Query Current Profit Sharing Execution Result.
Profit Sharing Rules
- Currency: The sharing currency must equal the settlement currency of the payment order. Cross-currency profit sharing is not supported. For global profit sharing, the currency must be a settlement currency of the source merchant.
- Recipient: The recipient merchant (
targetMerCode) must be an active merchant with a settlement account in the sharing currency. The source merchant and the recipient cannot be the same. - Channel: Only payment orders of self-collected channels support profit sharing. Order profit sharing on other channels is rejected, and global profit sharing skips those orders. Contact BD to confirm which channels are supported.
- Global profit sharing: Only one active global profit sharing is allowed for the same source merchant, recipient and currency. It applies only to payment orders cleared in the daily run while the configuration is active, and is not applied to orders that were already cleared.
- No stacking: A payment order can use either global profit sharing or order profit sharing, not both. An order that has been shared by a global configuration cannot be shared again by an order profit sharing request; global profit sharing skips orders that have a pending order profit sharing request.
- Amount: Profit sharing can be executed multiple times for a payment order, but the cumulative sharing amount cannot exceed the available amount of the payment order (net settlement amount minus refunded and already shared amounts). Sharing amounts are rounded to the currency precision, and a sharing amount below 0.01 fails.
- Execution time: Profit sharing is executed every day starting at 15:00 UTC (23:00 Beijing time). Order profit sharing is executed only after the payment order has been cleared and stays "Pending" until then. After a successful execution the status changes to "Success"; on failure it changes to "Failed".
- Cancel: Pending order profit sharing and active global profit sharing can be canceled. Cancel is not allowed between 15:00 and 18:00 UTC (23:00 to 02:00 Beijing time) while profit sharing is being executed; use a reversal after the execution finishes. Successful profit sharing cannot be canceled, only reversed.
- Reversal: You can only reverse successful profit sharing initiated by yourself; pending profit sharing cannot be reversed. A reversal can be full or partial, and partial reversals can be done multiple times, but the cumulative reversed amount cannot exceed the amount received from the original profit sharing.
- Fees: Profit sharing and reversal are charged at the initiator's profit sharing rate and reversal rate, rounded to the currency precision. If the original profit sharing rate is configured to return fees, a reversal returns the original fee in proportion to the reversed amount. Profit sharing fails if no profit sharing rate is configured; contact BD to enable it.
- As profit sharing incurs fees, the cumulative total of profit sharing or reversal cannot exceed the amount of the original payment order or profit sharing after deducting fees. You might consider setting the fee to be deducted from the source account.
- Permission: Merchants can only initiate profit sharing for their own payment orders. Platform-type merchants can initiate profit sharing for the payment orders of their associated merchants (specify the merchant with
sourceMerCode); see Query Delegated Merchants. - Limits: A payment order can be shared at most 50 times, and each profit sharing can be reversed at most 10 times.
Explanation of the Actual Effect of Profit Sharing
Prerequisites
- Payment order amount: 100 USD
- Platform fee collected: 2 USD
- Actual settlement to Merchant A: 98 USD
- Merchant A initiates profit sharing of 10% to Merchant B (the base amount is the net settlement amount of the payment order, 98 USD).
- Payment processing fee rate: 2%
- Profit sharing fee rate: 2%
- Fees are rounded to cents: 9.80 × 2% = 0.196, recorded as 0.20.
Scenario 1: Handling fee deducted from the transaction
| Account | Profit Sharing Amount | Handling Fee | Amount Received |
|---|---|---|---|
| Merchant A | -9.80 | 0.00 | -9.80 |
| Merchant B | 9.80 | 0.20 | 9.60 |
Scenario 2: Handling fee deducted from the source account
| Account | Profit Sharing Amount | Handling Fee | Amount Received |
|---|---|---|---|
| Merchant A | -9.80 | 0.20 | -10.00 |
| Merchant B | 9.80 | 0.00 | 9.80 |
Explanation of the Actual Effect of Reversing Profit Sharing
Prerequisites
- Payment order amount: 100 USD
- Platform fee collected: 2 USD
- Actual settlement to Merchant A: 98 USD
- Merchant A initiates profit sharing of 10% to Merchant B with a fee of 2%.
- Merchant A initiates a full reversal (without
splitMethod/splitValue). The reversed amount is the amount received from the original profit sharing (Note: The original profit sharing might not be reversed in full because of the deducted fees). - Payment processing fee rate: 2%
- Profit sharing fee rate: 2%
- Reversal fee rate: 2%; the original profit sharing rate does not return fees.
feeFromof a reversal is set in the reversal request. In both scenarios below, the reversal uses the samefeeFromas the original profit sharing.
Scenario 1: Handling fee deducted from the transaction
| Account | Profit Sharing Amount | Handling Fee | Amount Received |
|---|---|---|---|
| Merchant A | -9.80 | 0.00 | -9.80 |
| Merchant B | 9.80 | 0.20 | 9.60 |
| Merchant A | 9.60 | 0.19 | 9.41 |
| Merchant B | -9.60 | 0.00 | -9.60 |
Scenario 2: Handling fee deducted from the source account
| Account | Profit Sharing Amount | Handling Fee | Amount Received |
|---|---|---|---|
| Merchant A | -9.80 | 0.20 | -10.00 |
| Merchant B | 9.80 | 0.00 | 9.80 |
| Merchant A | 9.80 | 0.00 | 9.80 |
| Merchant B | -9.80 | 0.20 | -10.00 |
Explanation of Fixed Amount Profit Sharing
- For common currencies such as JPY, KRW, VND, where the smallest unit is the base unit, the splitValue unit is in the base unit. For example, splitValue=1000 means a profit sharing of 1000 units.
- For common currencies such as USD, CNY, where the smallest unit is cents, the splitValue unit is in cents. For example, splitValue=1023 means a profit sharing of 10.23 USD.
- Amount fields in query results and callbacks also use the smallest currency unit.
Parameter Explanation
| Parameter | Mandatory | Type | Explanation |
|---|---|---|---|
| reference | Required | string(240) | The unique identifier of the profit sharing initiator, used to check uniqueness of profit sharing configurations. Only letters, digits and _ . : - are allowed. |
| sharingType | Required | int | 0: Profit Sharing, 2: Reversal of Profit Sharing |
| splitMethod | Conditional | int | 0: Percentage-based profit sharing, 1: Fixed amount profit sharing. Required for profit sharing; optional for a reversal (full reversal if omitted). |
| splitValue | Conditional | int | When splitMethod=0, the profit sharing percentage with a precision of ten thousandths, from 1 to 9999. For example, splitValue=1023 means 10.23% When splitMethod=1, the actual profit sharing amount (the smallest unit of the currency) Currency Rules. Required for profit sharing; for a reversal, pass it together with splitMethod. |
| targetMerCode | Conditional | string(11) | The recipient merchant. Required for profit sharing. Not needed for a reversal (same as the original profit sharing). |
| sourceMerCode | Optional | string(11) | The funding source merchant. If not provided, the current merchant is used. For order profit sharing it must be the merchant of the payment order. To share for another merchant, the current merchant must be its platform merchant. |
| currency | Conditional | string(3) | Sharing currency, such as USD, CNY. Required for profit sharing and must equal the settlement currency of the payment order. Not needed for a reversal (same as the original profit sharing). |
| relationTxnId | Conditional | string(21) | The ID of the payment order to share, which is nihaopay's transactionId. Omitting it for profit sharing creates a global profit sharing configuration; use with caution in production. Required for a reversal. |
| remark | Optional | string(128) | Remarks that appear in the order description when viewing the order. Only letters, digits, _ . : - and Chinese characters are allowed; spaces and punctuation are not. |
| feeFrom | Optional | int | 0: The handling fee is deducted from the transaction (paid by the recipient) 1: The handling fee is deducted from the source account Default: 0 |
| baseFrom | Optional | int | Base amount for percentage-based calculation: 0: Net settlement amount of the original payment order 1: Amount of the original profit sharing (reversal only) 2: Order amount of the original payment order Default: 0. For a partial percentage reversal you usually need 1. |
| originConfId | Conditional | string(21) | Required for a reversal: the ID of the original profit sharing configuration to reverse. |
| notifyUrl | Optional | string(256) | The callback URL for profit sharing results. Both success and failure are notified. Data format. Must be an http or https URL reachable from the public internet. |
Profit Sharing Interface
Scenario: Initiate Global Percentage-based Profit Sharing
curl --location 'https://api.nihaopay.com/v1.2/sharing/apply' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"sharingType": 0,
"splitMethod": 0,
"splitValue": 10,
"reference": "20211111153109001472",
"targetMerCode": "M001000001",
"currency": "USD",
"remark": "test_remark",
"notifyUrl": "https://www.nihaopay.com/sharing/notify"
}'Scenario: Initiate Percentage-based Profit Sharing for a Specific Order
curl --location 'https://api.nihaopay.com/v1.2/sharing/apply' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"relationTxnId": "20211111153109001472",
"sharingType": 0,
"splitMethod": 0,
"splitValue": 1000,
"targetMerCode": "M001000001",
"reference": "20211111153109001472",
"remark": "test_remark",
"notifyUrl": "https://www.nihaopay.com/sharing/notify",
"currency": "USD"
}'Scenario: Initiate Fixed Amount Profit Sharing for a Specific Order
curl --location 'https://api.nihaopay.com/v1.2/sharing/apply' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"relationTxnId": "20211111153109001472",
"sharingType": 0,
"splitMethod": 1,
"splitValue": 100,
"targetMerCode": "M001000001",
"reference": "20211111153109001472",
"remark": "test_remark",
"notifyUrl": "https://www.nihaopay.com/sharing/notify",
"currency": "USD"
}'Scenario: Partially Reverse Profit Sharing (50% of the original sharing amount)
curl --location 'https://api.nihaopay.com/v1.2/sharing/apply' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"relationTxnId": "20211111153109001472",
"sharingType": 2,
"splitMethod": 0,
"splitValue": 5000,
"baseFrom": 1,
"reference": "20211111153109001473",
"remark": "test_remark",
"notifyUrl": "https://www.nihaopay.com/sharing/notify",
"originConfId": "20211111153109001472"
}'Scenario: Fully Reverse Profit Sharing
curl --location 'https://api.nihaopay.com/v1.2/sharing/apply' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"relationTxnId": "20211111153109001472",
"sharingType": 2,
"reference": "20211111153109001474",
"remark": "test_remark",
"notifyUrl": "https://www.nihaopay.com/sharing/notify",
"originConfId": "20211111153109001472"
}'Profit Sharing Initiation Success Response
{
"confId": "20230804021118097285"
}Profit Sharing Initiation Failure Response
{
"code": 400,
"label": "N/A",
"message": "sharing config already exist"
}Common failure reasons when applying:
| message | Explanation |
|---|---|
| reference is invalid / remark is invalid / notifyUrl is invalid | Parameter format is invalid |
| relation transaction currency not match | Sharing currency differs from the settlement currency of the payment order |
| source merchant has no settlement account in sharing currency | The source merchant of a global configuration has no account in the currency |
| target merchant has no settlement account in sharing currency | The recipient has no settlement account in the currency |
| targetMerCode not exist / targetMerCode is not active | The recipient does not exist or is not active |
| channel provider not support sharing | The payment channel does not support profit sharing (not self-collected) |
| transaction already shared by global sharing config | The order was shared by a global configuration and cannot be shared again |
| no transaction sharing permission | No permission to share for this merchant |
| sharing config already exist | Duplicate profit sharing configuration |
| reverse amount exceed available amount | The reversal amount exceeds the reversible amount |
Query Current Profit Sharing Configuration
Returns profit sharing configurations initiated by the current merchant with status Pending (APPLY) or Success/Active (SUCCESS), up to 50 records. Canceled and failed configurations are not returned; get failure reasons from Query Current Profit Sharing Execution Result or the callback.
| Parameter | Mandatory | Type | Explanation |
|---|---|---|---|
| relationTxnId | Optional | string(21) | Payment order ID |
| originConfId | Optional | string(21) | Original profit sharing configuration ID (reversals) |
| reference | Optional | string | Initiator's reference |
| sharingType | Optional | int | 0: Profit Sharing, 2: Reversal |
| currency | Optional | string(3) | Sharing currency |
Query all profit sharing configurations
curl --location 'https://apitest.nihaopay.com/v1.2/sharing/query' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{}'Query profit sharing configurations of a payment order
curl --location 'https://apitest.nihaopay.com/v1.2/sharing/query' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"relationTxnId": "20230804021118097285"
}'Profit sharing configuration success response
{
"sharingConfItems": [
{
"confId": "20230804021822097288",
"reference": "9200",
"originConfId": "",
"relationTxnId": "20230804021118097285",
"sourceMerCode": "M001000001",
"targetMerCode": "M001000002",
"sharingType": 0,
"splitMethod": 0,
"splitValue": 22,
"sharingCurrency": "USD",
"txnStatus": "SUCCESS",
"failReason": "",
"feeFrom": 0,
"baseFrom": 0,
"remark": "test",
"notifyUrl": "https://www.nihaopay.com/sharing/notify"
}
]
}No matching configuration
{
"sharingConfItems": []
}Query Current Profit Sharing Execution Result
Queries the execution result of a profit sharing configuration on a payment order. Both relationTxnId and confId are required; a global configuration is executed on many orders, so pass the specific payment order ID. Results may be cached for up to 1 hour.
| Parameter | Mandatory | Type | Explanation |
|---|---|---|---|
| relationTxnId | Required | string(21) | Payment order ID |
| confId | Required | string(21) | Profit sharing configuration ID |
Request Example
curl --location 'https://apitest.nihaopay.com/v1.2/sharing/detail' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"relationTxnId": "20230804021118097285",
"confId": "20230804021822097288"
}'Success Response Example (profit sharing succeeded)
{
"txnType": "SHARE_PROFIT",
"sharingStatus": "SUCCESS",
"reference": "9200",
"sharingType": 0,
"relationTxnId": "20230804021118097285",
"sharingConfId": "20230804021822097288",
"sourceMerCode": "M001000001",
"targetMerCode": "M001000002",
"sharingCurrency": "USD",
"txnCurrency": "USD",
"exchangeRate": 1.0,
"baseAmount": 13075,
"sourceSharingTxnAmount": -29,
"targetSharingTxnAmount": 29,
"sourceServiceFee": 0,
"targetServiceFee": 1,
"feeRate": {
"refundReturn": false,
"rateAlgorithm": 0,
"percentage": 2,
"fixedAmount": 0,
"minAmount": 0,
"maxAmount": 0,
"extraRefundFee": 0
}
}Success Response Example (profit sharing failed)
{
"txnType": "SHARE_PROFIT",
"sharingStatus": "FAIL",
"reference": "9200",
"sharingType": 0,
"relationTxnId": "20230804021118097285",
"sharingConfId": "20230804021822097288",
"sourceMerCode": "M001000001",
"targetMerCode": "M001000002",
"sharingCurrency": "USD",
"failReason": "sharing amount more than available amount"
}Failure Response Example (not executed yet or not found)
{
"code": 400,
"label": "N/A",
"message": "sharing history not exist"
}Response fields:
| Field | Explanation |
|---|---|
| txnType | SHARE_PROFIT: profit sharing, SHARE_REVERSE: reversal |
| sharingStatus | SUCCESS or FAIL |
| baseAmount | Base amount for percentage-based calculation (smallest currency unit) |
| sourceSharingTxnAmount / targetSharingTxnAmount | Sharing amount of the source merchant / recipient (smallest currency unit, negative = debit) |
| sourceServiceFee / targetServiceFee | Fee paid by the source merchant / recipient (smallest currency unit) |
| feeRate | The rate applied; percentage is in % |
| originSharingConfId | Reversal only: the original profit sharing configuration ID |
| failReason | Failure only: see common failure reasons in Profit Sharing Callback |
Cancel Profit Sharing
Pending order profit sharing and active global profit sharing can be canceled. Cancel is not allowed between 15:00 and 18:00 UTC (23:00 to 02:00 Beijing time) while profit sharing is being executed. Successful profit sharing can only be reversed.
Request
curl --location 'https://apitest.nihaopay.com/v1.2/sharing/cancel' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{
"confId": "20230719002724096890"
}'Success Response
{
"confId": "20230719002724096890",
"reason": "",
"txnStatus": "SUCCESS"
}Failure Response
{
"confId": "20230719002724096890",
"reason": "sharing config not exist",
"txnStatus": "FAIL"
}Common failure reasons (reason):
| reason | Explanation |
|---|---|
| sharing config not exist | The configuration does not exist |
| sharing config not belong to merchant | The configuration was not initiated by the current merchant |
| cancel is not allowed between 23:00 and 02:00 ... | Profit sharing is being executed; reverse after it finishes |
| sharing operation was success,cannot cancel | Profit sharing succeeded; it can only be reversed |
| operation failed, please check the transaction status. | The configuration status has changed (e.g. already canceled or failed) |
Query Delegated Merchants
Platform-type merchants query the associated merchants on whose behalf they can initiate profit sharing.
Request
curl --location 'https://apitest.nihaopay.com/v1.2/sharing/merchants' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data '{}'Response
{
"merchants": [
{ "merCode": "M001000001" },
{ "merCode": "M001000002" }
]
}Profit Sharing Callback
After each profit sharing is executed (success or failure), a JSON POST is sent to notifyUrl:
- The notification is sent once and is not retried. The request times out after 10 seconds and redirects are not followed.
- An HTTP 2xx response is treated as a successful notification.
notifyUrlmust be reachable from the public internet; private network addresses are not notified.- The callback is not signed. After receiving it, confirm the result with Query Current Profit Sharing Execution Result.
- Amount fields are in the smallest unit of the settlement currency;
rate.percentageis in %. - For a reversal,
txnTypeisSHARE_REVERSE,sourceMerCodeis the recipient of the original profit sharing (the party being debited),targetMerCodeis the source merchant of the original profit sharing, andoriginSharingConfId,originSharingTypeandoriginRateare also returned.
Profit Sharing Success Callback
{
"sharingStatus": "SUCCESS",
"txnType": "SHARE_PROFIT",
"sharingType": 0,
"reference": "TEST_20230803211516007112",
"sharingConfId": "20230803211516007112",
"relationTxnId": "20230803211516007111",
"sourceMerCode": "M001100001",
"targetMerCode": "M086100129",
"txnCurrency": "USD",
"stlCurrency": "USD",
"sharingCurrency": "USD",
"exchangeRate": 1.0,
"baseAmount": 2496,
"sourceSharingTxnAmount": -499,
"targetSharingTxnAmount": 499,
"sourceServiceFee": 0,
"targetServiceFee": 10,
"rate": {
"minAmount": 0,
"percentage": 2,
"txnCurrency": "USD",
"refundReturn": 0,
"fixedAmount": 0,
"maxAmount": 0
}
}Profit Sharing Failure Callback
{
"sharingStatus": "FAIL",
"txnType": "SHARE_PROFIT",
"sharingType": 0,
"reference": "TEST_20230803211516007112",
"sharingConfId": "20230803211516007112",
"relationTxnId": "20230803211516007111",
"sourceMerCode": "M001100001",
"targetMerCode": "M086100129",
"txnCurrency": "USD",
"stlCurrency": "USD",
"sharingCurrency": "USD",
"failReason": "sharing amount more than available amount"
}Common failure reasons during execution (failReason):
| failReason | Explanation |
|---|---|
| rate not found | No profit sharing rate is configured for the initiator; contact BD |
| sharing amount more than available amount | The sharing amount exceeds the remaining shareable amount |
| sharing amount less than minimum amount | The sharing amount is below 0.01 |
| sharing currency not match settlement currency | Sharing currency differs from the order's settlement currency |
| transaction already shared by global sharing config | The order was already shared by a global configuration |
| target merchant is not active / target merchant not exist | The recipient is not active or does not exist |
| target merchant has no settlement account in sharing currency | The recipient has no settlement account in the currency |
| sharing reverse amount more than origin sharing amount | The reversal amount exceeds the remaining reversible amount |
