Skip to content

Square: Refund Payment

Square refunds.refundPayment: arguments, response, policy and SDK examples.

← Refunds operations · Get started

Operation square.refundpayment

Provider route: POST /v2/refunds. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/square with npm, or alter-sdk-square with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { SquareIntegration } from "@alter-ai/square";
async function execute(input: Parameters<SquareIntegration["refunds"]["refundPayment"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new SquareIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.refunds.refundPayment(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_square import SquareIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = SquareIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.refunds.refund_payment(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
bodyModelRequired within parentExpand Refund Payment — request body — body

Referenced models: Refund Payment — request body — body

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Refund Payment — response body

Referenced models: Refund Payment — response body

15 more schemas are linked from the tables above, on the schema pages.

Refund Payment — response body
FieldTypePresenceDescription and constraints
$objectRootDefines the response returned by
[RefundPayment](api-endpoint:Refunds-RefundPayment).

If there are errors processing the request, the `refund` field might not be
present, or it might be present with a status of `FAILED`.
errorsarrayOptionalInformation about errors encountered during the request.
errors[]ModelEach itemExpand Get Shift — response body — errors item
refundModelOptionalExpand Refund Payment — response body — refund
The successfully created `PaymentRefund`.

Referenced models: Get Shift — response body — errors item, Refund Payment — response body — refund

Refund Payment — request body — body
FieldTypePresenceDescription and constraints
$objectRootDescribes a request to refund a payment using [RefundPayment](api-endpoint:Refunds-RefundPayment).
amount_moneyModelRequired within parentExpand Create Payment — request body — body tip money
The amount of money to refund.

This amount cannot be more than the `total_money` value of the payment minus the total
amount of all previously completed refunds for this payment.

This amount must be specified in the smallest denomination of the applicable currency
(for example, US dollar amounts are specified in cents). For more information, see
[Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).

The currency code must match the currency associated with the business
that is charging the card.
app_fee_allocationsJSONOptional
app_fee_allocations (anyOf 1)arrayAlternativeDetails pertaining to contributors to the refund of the application fee.
The sum of the amounts in the app_fee_allocations must equal the app_fee_money amount, if
present. If populated, an allocation must be present for every party that expects to contribute
a portion of the refunded application fee, including the application developer.
app_fee_allocations (anyOf 1)[]ModelEach itemExpand Create Payment — request body — body app fee allocations item
app_fee_allocations (anyOf 2)nullAlternative
app_fee_moneyJSONOptional
app_fee_money (anyOf 1)ModelAlternativeExpand Create Payment — request body — body tip money
The amount of money the developer contributes to help cover the refunded amount.
This amount is specified in the smallest denomination of the applicable currency (for example,
US dollar amounts are specified in cents).

The value cannot be more than the `amount_money`.

You can specify this parameter in a refund request only if the same parameter was also included
when taking the payment. This is part of the application fee scenario the API supports. For more
information, see [Take Payments and Collect Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees).

To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required.
For more information, see [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions).
app_fee_money (anyOf 2)nullAlternative
cash_detailsJSONOptional
cash_details (anyOf 1)ModelAlternativeExpand Refund Payment — request body — body cash details change back money, seller supplied money
Additional details required when recording an unlinked cash refund (`destination_id` is CASH).
cash_details (anyOf 2)nullAlternative
customer_idJSONOptional
customer_id (anyOf 1)stringAlternativeThe [Customer](entity:Customer) ID of the customer associated with the refund.
This is required if the `destination_id` refers to a card on file created using the Cards
API. Only allowed when `unlinked=true`.
customer_id (anyOf 2)nullAlternative
destination_idJSONOptional
destination_id (anyOf 1)stringAlternativeThe ID indicating where funds will be refunded to. Required for unlinked refunds. For more
information, see [Process an Unlinked Refund](https://developer.squareup.com/docs/refunds-api/unlinked-refunds).

For refunds linked to Square payments, `destination_id` is usually omitted; in this case, funds
will be returned to the original payment source. The field may be specified in order to request
a cross-method refund to a gift card. For more information,
see [Cross-method refunds to gift cards](https://developer.squareup.com/docs/payments-api/refund-payments#cross-method-refunds-to-gift-cards).
destination_id (anyOf 2)nullAlternative
external_detailsJSONOptional
external_details (anyOf 1)ModelAlternativeExpand Refund Payment — request body — body external details source, source id, type
Additional details required when recording an unlinked external refund
(`destination_id` is EXTERNAL).
external_details (anyOf 2)nullAlternative
idempotency_keystringRequired within parentA unique string that identifies this `RefundPayment` request. The key can be any valid string
but must be unique for every `RefundPayment` request.

Keys are limited to a max of 45 characters - however, the number of allowed characters might be
less than 45, if multi-byte characters are used.

For more information, see [Idempotency](https://developer.squareup.com/docs/working-with-apis/idempotency).
Minimum length: 1
location_idJSONOptional
location_id (anyOf 1)stringAlternativeThe location ID associated with the unlinked refund.
Required for requests specifying `unlinked=true`.
Otherwise, if included when `unlinked=false`, will throw an error.
Maximum length: 50
location_id (anyOf 2)nullAlternative
payment_idJSONOptional
payment_id (anyOf 1)stringAlternativeThe unique ID of the payment being refunded.
Required when unlinked=false, otherwise must not be set.
payment_id (anyOf 2)nullAlternative
payment_version_tokenJSONOptional
payment_version_token (anyOf 1)stringAlternativeUsed for optimistic concurrency. This opaque token identifies the current `Payment`
version that the caller expects. If the server has a different version of the Payment,
the update fails and a response with a VERSION_MISMATCH error is returned.
If the versions match, or the field is not provided, the refund proceeds as normal.
payment_version_token (anyOf 2)nullAlternative
reasonJSONOptional
reason (anyOf 1)stringAlternativeA description of the reason for the refund.
Maximum length: 192
reason (anyOf 2)nullAlternative
team_member_idJSONOptional
team_member_id (anyOf 1)stringAlternativeAn optional [TeamMember](entity:TeamMember) ID to associate with this refund.
Maximum length: 192
team_member_id (anyOf 2)nullAlternative
unlinkedJSONOptional
unlinked (anyOf 1)booleanAlternativeIndicates that the refund is not linked to a Square payment.
If set to true, `destination_id` and `location_id` must be supplied while `payment_id` must not
be provided.
unlinked (anyOf 2)nullAlternative

Referenced models: Create Payment — request body — body app fee allocations item, Refund Payment — request body — body cash details change back money, seller supplied money, Refund Payment — request body — body external details source, source id, type, Create Payment — request body — body tip money

Get Shift — response body — errors item
FieldTypePresenceDescription and constraints
$objectRootRepresents an error encountered during a request to the Connect API.

See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information.
categorystringRequired within parentIndicates which high-level category of error has occurred during a
request to the Connect API.
The high-level category for the error.
See [ErrorCategory](#type-errorcategory) for possible values
Known values: API_ERROR, AUTHENTICATION_ERROR, INVALID_REQUEST_ERROR, RATE_LIMIT_ERROR, PAYMENT_METHOD_ERROR, REFUND_ERROR, MERCHANT_SUBSCRIPTION_ERROR, EXTERNAL_VENDOR_ERROR
codeModelRequired within parentExpand Get Shift — response body — errors item code
The specific code of the error.
See [ErrorCode](#type-errorcode) for possible values
detailstringOptionalA human-readable description of the error for debugging purposes.
fieldstringOptionalThe name of the field provided in the original request (if any) that
the error pertains to.

Referenced models: Get Shift — response body — errors item code

Create Payment — request body — body app fee allocations item
FieldTypePresenceDescription and constraints
$objectRootOne recipient location's portion of the application fee.
location_idstringOptionalThe location receiving this application-fee allocation.
amount_moneyModelOptionalExpand Create Payment — request body — body tip money

Referenced models: Create Payment — request body — body tip money

Refund Payment — response body — refund app fee allocations item
FieldTypePresenceDescription and constraints
$objectRootOne recipient location's portion of the application fee.
location_idstringOptionalThe location receiving this application-fee allocation.
amount_moneyModelOptionalExpand Pay Order — response body — order total money

Referenced models: Pay Order — response body — order total money

SDK function policy ID: square.refundpayment. Catalog operation: RefundPayment. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Required provider scopes: ["PAYMENTS_WRITE"]

Pinned headers: {"Square-Version": "2026-11-18"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.