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.
Call through Alter
Section titled “Call through Alter”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 osfrom alter_sdk import Appfrom 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()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
body | Model | Required within parent | Expand Refund Payment — request body — body |
Referenced models: Refund Payment — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Refund Payment — response body |
Referenced models: Refund Payment — response body
Schemas
Section titled “Schemas”15 more schemas are linked from the tables above, on the schema pages.
Refund Payment — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Defines 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`. |
errors | array | Optional | Information about errors encountered during the request. |
errors[] | Model | Each item | Expand Get Shift — response body — errors item |
refund | Model | Optional | Expand 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Describes a request to refund a payment using [RefundPayment](api-endpoint:Refunds-RefundPayment). |
amount_money | Model | Required within parent | Expand 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_allocations | JSON | Optional | |
app_fee_allocations (anyOf 1) | array | Alternative | Details 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)[] | Model | Each item | Expand Create Payment — request body — body app fee allocations item |
app_fee_allocations (anyOf 2) | null | Alternative | |
app_fee_money | JSON | Optional | |
app_fee_money (anyOf 1) | Model | Alternative | Expand 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) | null | Alternative | |
cash_details | JSON | Optional | |
cash_details (anyOf 1) | Model | Alternative | Expand 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) | null | Alternative | |
customer_id | JSON | Optional | |
customer_id (anyOf 1) | string | Alternative | The [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) | null | Alternative | |
destination_id | JSON | Optional | |
destination_id (anyOf 1) | string | Alternative | The 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) | null | Alternative | |
external_details | JSON | Optional | |
external_details (anyOf 1) | Model | Alternative | Expand 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) | null | Alternative | |
idempotency_key | string | Required within parent | A 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_id | JSON | Optional | |
location_id (anyOf 1) | string | Alternative | The 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) | null | Alternative | |
payment_id | JSON | Optional | |
payment_id (anyOf 1) | string | Alternative | The unique ID of the payment being refunded. Required when unlinked=false, otherwise must not be set. |
payment_id (anyOf 2) | null | Alternative | |
payment_version_token | JSON | Optional | |
payment_version_token (anyOf 1) | string | Alternative | Used 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) | null | Alternative | |
reason | JSON | Optional | |
reason (anyOf 1) | string | Alternative | A description of the reason for the refund. Maximum length: 192 |
reason (anyOf 2) | null | Alternative | |
team_member_id | JSON | Optional | |
team_member_id (anyOf 1) | string | Alternative | An optional [TeamMember](entity:TeamMember) ID to associate with this refund. Maximum length: 192 |
team_member_id (anyOf 2) | null | Alternative | |
unlinked | JSON | Optional | |
unlinked (anyOf 1) | boolean | Alternative | Indicates 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) | null | Alternative |
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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents 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. |
category | string | Required within parent | Indicates 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 |
code | Model | Required within parent | Expand Get Shift — response body — errors item code The specific code of the error. See [ErrorCode](#type-errorcode) for possible values |
detail | string | Optional | A human-readable description of the error for debugging purposes. |
field | string | Optional | The 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | One recipient location's portion of the application fee. |
location_id | string | Optional | The location receiving this application-fee allocation. |
amount_money | Model | Optional | Expand 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | One recipient location's portion of the application fee. |
location_id | string | Optional | The location receiving this application-fee allocation. |
amount_money | Model | Optional | Expand Pay Order — response body — order total money |
Referenced models: Pay Order — response body — order total money
Policy, approvals and errors
Section titled “Policy, approvals and errors”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"}