Split by Percentage After Transaction Integration
Use this integration to split a completed transaction by percentage using the payment_split API.
In this mode, define type as percentage and distribute split values in aggregatorSubAmt.
Prerequisites
Before you start, ensure the following:
- Your parent merchant account is activated for Split Settlements.
- Child merchants have completed onboarding process and are marked Completed/Active .
- You have your parent merchant
keyandsalt, along with the child merchant(s) key. - You have server-side logic to generate hash and process webhooks/You have the
payuIdof the already completed parent transaction.
Verify the payment status to confirm the transaction is successful before initiating the split
Prepare the var1 JSON payload with the required split details and partner-specific parameters
Generate a secure hash for the API request to ensure data integrity and authentication
Make the API call to the payment_split endpoint to execute the split on the verified transaction
Step 1: Verify the Payment
After completing the payment using the Collect Payment (_payment) API, perform this step to verify the payment.
Reference: Refer to any of the following API Reference pages for the sample request/response for collecting payments using the Collection (_payment) API:
Upon receiving the response, PayU recommends performing a reconciliation step to validate all transaction details. You can verify your payments using either of the following methods:
Upon receiving the response, PayU recommends you performing a reconciliation step to validate all transaction details.
You can verify your payments using either of the following methods:
Configure the webhooks to monitor the status of payments.
Webhooks enable a server to communicate with another server by sending an HTTP callback or message.
These callbacks are triggered by specific events or instances and operate at the server-to-server (S2S) level.
Know how to manage Webhooks for Payments.
Environment
| Test Environment | https://test.payu.in/merchant/postservice.php?form=2 |
| Production Environment | https://info.payu.in/merchant/postservice.php?form=2 |
Note: The hash logic for Verify Payment API is:
sha512(key|command|var1|salt) sha512
Sample request
curl --request POST
--url 'https://test.payu.in/merchant/postservice?form=2'
--header 'Content-Type: application/x-www-form-urlencoded'
--data key=JPM7Fg
--data command=verify_payment
--data var1=IhfgcZnXR4o4nB
--data hash=a0ae79fdd66c875af6e9b21c4a67f1822deb00f2df5e9f0b1948f3222f536a9bf741b24efbb1874ca0f84f76b036e6c0d641581d0100f7abe4aeed2f3264f5c9
Sample response
If credit card payment is made, the response is similar to the following:
{
"status":0,
"msg":"0 out of 1 Transactions Fetched Successfully",
"transaction_details":
{
"IhfgcZnXR4o4nB":
{
"mihpayid":"Not Found",
"status":"Not Found"
}
}
}If txnID is not found, the response is similar to the following:
{
"status":0,
"msg":"0 out of 1 Transactions Fetched Successfully",
"transaction_details":
{
"IhfgcZnXR4o4nB":
{
"mihpayid":"Not Found",
"status":"Not Found"
}
}
}Response parameters
| Parameter | Description | Example |
|---|---|---|
| status | This parameter returns the status of web service call. The status can be any of the following:
| 0 |
| msg | This parameter returns the reason string. | For example, any of the following messages are displayed:
|
| transaction_details | This parameter contains the response in a JSON format. For more information refer to JSON fields description for transaction_details parameter . | |
| request_id | PayU Request ID for a request in a Transaction. For example, a transaction can have a refund request. | 7800456 |
| bank_ref_num | This parameter returns the bank reference number. If the bank provides after a successful action. | 204519474956 |
To learn more about the possible error codes and their description, refer to Error Codes.
Step 2: Prepare var1 JSON payload
Set type as percentage and ensure total percentage is 100.
{
"type": "percentage",
"payuId": "403993715525003544",
"splitInfo": {
"merchantKey1": {
"aggregatorSubTxnId": "subtxn-per-after-001",
"aggregatorSubAmt": "53.33",
"aggregatorCharges": "13.33"
},
"merchantKey2": {
"aggregatorSubTxnId": "subtxn-per-after-002",
"aggregatorSubAmt": "46.67"
}
}
}Important: Ensure total percentage across split entries equals
100.00.
Step 3: Generate hash
Use:
sha512(key|command|var1|salt)Where:
command=payment_splitvar1= compact JSON string from Step 1
Step 4: Call payment_split API
Environment endpoints:
- Test:
https://test.payu.in/merchant/postservice.php?form=2 - Production:
https://info.payu.in/merchant/postservice.php?form=2
Sample request:
curl -X POST "https://test.payu.in/merchant/postservice.php?form=2" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "key=vDy3i7" \
-d "command=payment_split" \
-d 'var1={"type":"percentage","payuId":"403993715525003544","splitInfo":{"merchantKey1":{"aggregatorSubTxnId":"subtxn-per-after-001","aggregatorSubAmt":"53.33","aggregatorCharges":"13.33"},"merchantKey2":{"aggregatorSubTxnId":"subtxn-per-after-002","aggregatorSubAmt":"46.67"}}}' \
-d "hash=<generated_hash>"Sample success response:
{
"status": 1,
"message": "Splits creation successful.",
"splitStatus": "success",
"splitSegments": [
{
"merchantKey": "merchantKey1",
"amount": 53.33,
"subvention_amount": 0,
"txnId": "subtxn-per-after-001",
"additional_charges": 0,
"transaction_fee": 53.33
},
{
"merchantKey": "merchantKey2",
"amount": 46.67,
"subvention_amount": 0,
"txnId": "subtxn-per-after-002",
"additional_charges": 0,
"transaction_fee": 46.67
}
]
}Updated 3 months ago
