Saltar al contenido principal

Overview

POST /developer/v1/refund refunds a sale by its payment id. It works the same for every way a payment is charged: a payment link, a one-time payment, a terminal charge sent as a payment intent, or a charge to a saved card. Your integration does not need to know which endpoint created the sale, only the id that GET /developer/v1/payment returns.
These examples call the production host. While you build, replace https://api-harmony.compago.com with https://demo-api-harmony.compago.com and use a key from the Demo dashboard. See Environments.

Refund a payment

Once the bank was asked, the answer is 201 with the refund, whatever the bank said. A refund that went through reads SUCCEEDED and the payment now reads status: "REFUNDED" with its refundedAt. A refund the bank declined reads FAILED with failureReason: "DECLINED", and the sale stays paid.

Full refunds only, for now

Every sale is refunded in full: the whole charge, sale and tip, goes back to the card or account it came from. amount is optional. If you send it, it must be the payment’s chargedAmount; any other amount is refused with 400 PARTIAL_REFUND_NOT_SUPPORTED and nothing is refunded. Partial refunds will be accepted here, with the same request, for the payment methods that support them.

The rules

The same rules apply as to every refund through the API:
  • The same day. A sale can be refunded until 10:30 PM Mexico City time on the day it was approved (10:00 PM for American Express). After that, refund it from the dashboard.
  • Meses sin intereses. A Super MSI sale cannot be refunded through the API once a monthly installment was collected.
  • Compago’s fee. When your refund terms keep the fee, it is taken from what you have pending to settle. See Refunds and fees.
  • Store integrations. A sale charged by an integration that refunds its own orders (such as Shopify) is refunded there, so the order and the money never disagree.

Errors

Every error body is { "message", "code" }. Branch on code.
A request that times out may still have refunded the sale. Retry it: a sale already refunded answers 409 ALREADY_REFUNDED, never a second refund. Then read the refund with GET /developer/v1/refund?paymentId=....

List and read refunds

GET /developer/v1/refund lists your organization’s refunds, newest first, with the same pagination as every other list. Filter by paymentId to get the refund of one sale. GET /developer/v1/refund/{id} reads one.

Next steps

Refund API reference

The endpoint’s full schema.

Refunds and fees

What a refund costs and when it is refused.