Skip to Content
Docs

Refund a charge

Return all or part of a settled charge to the customer through POST /v1/refunds.

Return funds from a successful charge to the customer's original payment method using POST /v1/refunds. Unlike canceling a hold, which releases funds that were only reserved, a refund moves settled funds and can take several business days to appear on the customer's statement.

Requirements

Before you start, make sure you have:

  • The id of the successful charge (chrg_...).
  • Your API credentials. The examples use the sandbox (https://api.sandbox.pay.com/v1) with an sk-pay-com-sandbox- key.
  • A unique idempotency-key header for each request, and the same key when you retry.

Create a refund

Follow these steps to issue a full or partial refund and track its status.

  1. 1

    Send the refund request

    Call POST /v1/refunds with the charge ID in charge. Omit amount_to_refund to refund the full remaining balance, or pass an integer in minor units (for example, 5000 for $50.00 USD) for a partial refund.

    Omit amount_to_refund to return the entire remaining balance of the charge.

    POST https://api.sandbox.pay.com/v1/refunds

    {
      "charge": "chrg_687103334154240000"
    }
  2. 2

    Check the refund status

    A 201 response returns the refund object. Inspect its status field:

    • succeeded: The refund was accepted and funds are returning to the customer.
    • pending: The payment method confirms refunds asynchronously. Wait for the refund.succeeded or refund.failed webhook.

    If the refund is declined (for example, because the card is closed or the refund window has passed), the API returns HTTP 400 with error.type: "payment_method_error", error.code: "card_declined", error.decline_code, error.message, and error.refund set to the refund ID.

  3. 3

    Listen for webhooks

    Subscribe to these webhook events and verify every signature before acting on them:

    • refund.succeeded: The refund succeeded, and the funds are being returned to the customer.
    • refund.failed: The refund was declined. You can use this event to alert your support team for a manual review.
    • charge.refunded: Fires on every successful full or partial refund. refunded becomes true when the charge balance reaches zero.

You can also refund a charge through POST /v1/charges/{id}/refund. It takes the charge from the URL path and ignores a charge field in the body. Otherwise, both endpoints accept the same request body and return identical responses.

Error handling

Common refund validation errors and how to resolve them:

ScenarioError messageResolution
Refund exceeds remaining balanceRequested amount exceeded refundable, or no refundable amount left (HTTP 422)Check the charge's amount_refunded field to see how much is still refundable.
Charge already fully refundedRequested amount exceeded refundable, or no refundable amount left (HTTP 422)The charge balance is zero. No further refunds are possible.
Unknown charge IDUnable to find charge with id chrg_… (HTTP 404)Verify charge contains a valid charge ID from your workspace.
Malformed charge IDThe charge provided is not a valid charge id (HTTP 400)Pass the full chrg_... ID returned when the charge was created.

Next steps

Related payment and webhook guides:

  • Create a charge: Accept card and alternative payments through the API.
  • Hold and capture: Cancel a hold before capture to avoid issuing a refund.
  • Webhooks: Set up webhook endpoints and verify signatures.
Was this page helpful?