Bulk Refund by Reference API

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 Only

Note: 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

HeaderTypeRequiredDescription
AuthorizationStringYesBearer token format: Bearer <YOUR_API_KEY>
Content-TypeStringYesMust be application/json
AcceptStringYesMust be application/json
X-SignatureStringYesRequired
X-TimestampIntegerYesRequired (UTC Unix timestamp).

1. Initiate Bulk Refund (/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

ParameterTypeRequired / OptionalConstraintsDescription
referenceStringRequiredMax: 500The reference identifier assigned during initial transaction creation (reference.id).
requireApprovalIntegerOptional0 or 1 (Default: 0)0 = Direct processing (refund generated immediately).
1 = Creates a pending approval request for merchant UPayments Dashboard review.
refundReasonStringOptionalStringReason for issuing the refund. Default: "Bulk Reference initiated by the merchant - UAPI".
notifyUrlStringOptionalURL, Max: 250Webhook URL to receive status notifications for refund transactions.
customerEmailStringOptionalEmail, Max: 50Customer email address for refund records.
customerMobileNumberStringOptionalMax: 12Customer mobile number for refund records.
customerNameStringOptionalStringCustomer 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 returns status: false ("You already refunded full amount").
  • Merchant Account Balance: UPayments verifies available settled balance. If the balance is insufficient, it returns a 200 response with status: false and error_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"
  }
}