The Bulk Refund by Reference API suite allows merchants to trigger and monitor refunds across multiple captured transactions that share a common reference identifier . Instead of issuing separate refund API calls for each individual transaction, merchants can initiate a single bulk refund request . UPayments automatically identifies all eligible captured payments, checks refundable amounts and merchant balances, and processes the refunds asynchronously via background queue workers.
Single Merchant Transactions OnlyNote: The Bulk Refund by Reference feature is designed for single-merchant transactions and does not support Multi merchant Refunds
Authentication & Headers
The endpoint requires merchant authentication via a Bearer API token and HMAC signature verification
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | String | Yes | Bearer token format: Bearer <YOUR_API_KEY> |
Content-Type | String | Yes | Must be application/json |
Accept | String | Yes | Must be application/json |
X-Signature | String | Yes | Required |
X-Timestamp | Integer | Yes | Required (UTC Unix timestamp). |
1. Initiate Bulk Refund (/bulk-refund-by-reference)
/bulk-refund-by-reference)Dispatches asynchronous refund processing jobs for all captured transactions matching the specified merchant reference.
- URL:
https://sandboxapi.upayments.com/api/v1/bulk-refund-by-reference - HTTP Method:
POST
Request Parameters
| Parameter | Type | Required / Optional | Constraints | Description |
|---|---|---|---|---|
reference | String | Required | Max: 500 | The reference identifier assigned during initial transaction creation (reference.id). |
requireApproval | Integer | Optional | 0 or 1 (Default: 0) | 0 = Direct processing (refund generated immediately).1 = Creates a pending approval request for merchant UPayments Dashboard review. |
refundReason | String | Optional | String | Reason for issuing the refund. Default: "Bulk Reference initiated by the merchant - UAPI". |
notifyUrl | String | Optional | URL, Max: 250 | Webhook URL to receive status notifications for refund transactions. |
customerEmail | String | Optional | Email, Max: 50 | Customer email address for refund records. |
customerMobileNumber | String | Optional | Max: 12 | Customer mobile number for refund records. |
customerName | String | Optional | String | Customer name for refund records. |
Business Rules & Validations
- Transaction Discovery: The gateway selects transactions belonging to the authenticated merchant where
result = 'CAPTURED',reference = :reference - Refundable Balance Check: Computes
remainingAmount = original_amount_paid - sum_of_prior_refunds. If all transactions under the reference are already fully refunded (remainingAmount <= 0), the API returnsstatus: false("You already refunded full amount"). - Merchant Account Balance: UPayments verifies available settled balance. If the balance is insufficient, it returns a
200response withstatus: falseanderror_code: "insufficient_balance". - Queue Processing: Eligible transactions are batched into chunks of 50 for efficient background queue execution.
Example Request
{
"reference": "ORD_REF_892341",
"requireApproval": 0,
"refundReason": "Customer returned multiple items from order",
"notifyUrl": "https://merchant.example.com/webhooks/refunds",
"customerEmail": "[email protected]",
"customerName": "Some One",
"customerMobileNumber": "+96598765432"
}
Response Payloads
Success: Direct Refund Generated (requireApproval = 0) or Approval Requested (requireApproval = 1)
{
"status": true,
"message": "Refund invoice generated successfully",
"data": {
"reference": "ORD_REF_892341",
"totalRefunds": 2
}
}Error: No Eligible Transactions Found
{
"status": false,
"message": "Transaction not found",
"data": []
}Error: Already Fully Refunded
{
"status": false,
"message": "You already refunded full amount",
"data": []
}Error: Insufficient Merchant Balance
{
"status": false,
"message": "Insufficient balance",
"data": {
"error_code": "insufficient_balance"
}
}