Skip to Content
Docs
Orders

Refund an order

POST/orders/{order_id}/refund

Refunds all or part of an order. This is the only way to refund an order: POST /v1/refunds for an order's charge returns 422 with use_order_refund.

  • Without amount or line_items, it refunds what's left.
  • With line_items, it refunds those quantities, and their tax. Shipping is refunded only with include_shipping.
  • With amount alone, it refunds that amount, which can't be more than what's left.
  • When the order has an invoice, Pay.com issues a credit note.

It returns the refund, the same object the main API's refunds return, which GET /v1/refunds/{id} also finds. Pay.com sends the usual refund events and order.refunded.

If the payment processor's answer doesn't arrive, it returns 502 with refund_unconfirmed: the order shows the refund as pending until Pay.com confirms it, and a retry with the same idempotency key returns the same answer, never a second refund.

Headers

AuthorizationstringRequired
HTTP Basic auth: your API key as the password, with an empty username. See Authentication.
idempotency-keystring

A unique key, such as a UUID, that makes a POST safe to retry. Pay.com keeps each key for 24 hours, separately for each workspace. A retry with the same key, endpoint and body gets the first response. Another endpoint or body gets 400 idempotency_error, and a retry while the first is running gets 409.

Path parameters

order_idstringRequired

The order's ID (ord_).

Parameters

amountinteger

Defaults to what's left, or to the items' amounts with line_items.

line_itemsarray of objects
Show 2 child parametersHide child parameters
line_itemstringRequired

The order's line item (oli_).

quantityintegerRequired
include_shippingboolean

With line_items, also refunds the shipping.

Default: false

reasonstring
referencestring
metadataobject

Your key-value pairs. Up to 50 keys of 40 characters, with string values of up to 500 characters.

Returns

The refund.

idstring
resourcestring
statusstring

One of pending, succeeded or failed.

amountinteger
currencystring

Three-letter ISO currency code, in lowercase.

orderstring or null

The order it refunds, or null for a renewal invoice's refund.

invoicestring or null

The renewal invoice it refunds.

chargestring
Show 9 more attributesShow fewer attributes
line_itemsarray of objects
Show 3 child attributesHide child attributes
line_itemstring
quantityinteger
amountinteger
amount_shippinginteger
credit_notestring or null
customer_reference_idstring
reasonstring or null
referencestring or null
metadataobject

Your key-value pairs. Up to 50 keys of 40 characters, with string values of up to 500 characters.

createdstring
test_modeboolean

Errors

400
The request is invalid.
401
The API key is missing or wrong.
403
The key's permissions don't allow this route.
404
No such object in this workspace and environment.
409
A request with this idempotency key is still running.
422
The request is valid but can't be done. Codes include: - amount_mismatch: amount doesn't equal the line items' total. - price_inactive, product_inactive: an item can't be sold. - currency_mismatch: the items or rates use different currencies. - no_shipping_rate: an item ships and no active rate covers the session's currency. - checkout_not_open: the session is completed or expired. - order_not_refundable: the order is fully refunded, or under a dispute. - amount_exceeds_refundable: more than what's left to refund. - quantity_exceeds_refundable: more of an item than was sold and not yet refunded. - order_not_shippable: shipped_at was sent for an order with nothing that ships. - shipping_rate_inactive: a rate in shipping_options is archived. - tax_exceeds_amount: inclusive tax figures are more than an item's amount. - refund_failed: the payment method refused the refund. Nothing was refunded. - custom_css_not_approved: the draft's changed custom CSS isn't approved yet. - default_profile: your default design profile can't be archived. - profile_not_published: the design profile has nothing published yet, so sessions and links can't use it and it can't be your default. - profile_archived: the design profile is archived, so new sessions and links can't use it and it can't be your default. - display_name_required: the draft to publish has no display_name. - low_contrast: white text on colors.accent, or colors.text on colors.background, is under 4.5:1. - number_in_use: the next number is one the series has already used. - tax_rate_required: a subscription sent with your own tax figures has a tax_breakdown entry without a percentage_decimal or a flat_amount, so it can't be applied to renewals. - seller_engine_conflict: the request names an external engine for a sale that can resolve to Pay.com as seller. - engine_not_allowed_for_seller: the engine can't run a subscription this seller sells. - processor_not_allowed_for_seller: Pay.com sells only on accounts it controls, and the processor isn't one of them. - engine_capability_missing: the engine or its connection can't do what the request needs. - connection_not_ready: the engine's connection isn't connected, or needs action. - product_refused: a product failed review for merchant of record, and you can't sell it yourself in this request. Subscription and seller refusals come at creation, never at renewal.
502
refund_unconfirmed: the processor's answer didn't arrive. The refund shows as pending, and a retry with the same idempotency key returns this answer again, never a second refund.
Was this page helpful?