• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Refund payment

POST /v2/refunds

Refunds a payment.

You can refund the entire payment amount or a portion of it. You can use this endpoint to refund a card payment or record a refund of a cash or external payment. For more information, see Refund Payment.


Permissions
PAYMENTS_WRITE
Guide
Refund a payment
Try in API Explorer
Name Description
idempotency_key
string

Required

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.

Min Length 1
amount_money
Money

Required

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.

The currency code must match the currency associated with the business that is charging the card.

app_fee_money
Money

Beta

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.

To set this field, PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS OAuth permission is required. For more information, see Permissions.

payment_id
string

The unique ID of the payment being refunded. Must not be provided if unlinked=true. Required if unlinked=false or unlinked is unset.

destination_id
string

The ID indicating where funds will be refunded to, if this is an unlinked refund. This can be any of the following: A token generated by Web Payments SDK or RSDK2; a card-on-file identifier. Required for requests specifying unlinked=true. Otherwise, if included when unlinked=false, will throw an error.

unlinked
boolean

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.

location_id
string

The location ID associated with the unlinked refund. Required for requests specifying unlinked=true. Otherwise, if included when unlinked=false or unset, will throw an error.

Max Length 50
customer_id
string

The 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 Customers API. Only allowed when unlinked=true.

reason
string

A description of the reason for the refund.

Max Length 192
payment_version_token
string

Beta

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.

team_member_id
string

An optional TeamMember ID to associate with this refund.

Max Length 192

Response Fields

Name Description
errors
Error [ ]

Information about errors encountered during the request.

refund
PaymentRefund

The successfully created PaymentRefund.

Examples

You are viewing an old version of the API
POST /v2/refunds
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
  • Node.js
curl https://connect.squareup.com/v2/refunds \
  -X POST \
  -H 'Square-Version: 2022-11-16' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "9b7f2dcf-49da-4411-b23e-a2d6af21333a",
    "payment_id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
    "amount_money": {
      "amount": 1000,
      "currency": "USD"
    },
    "app_fee_money": {
      "amount": 10,
      "currency": "USD"
    },
    "reason": "Example"
  }'
Response JSON
{
  "refund": {
    "id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY_KlWP8IC1557ddwc9QWTKrCVU6m0JXDz15R2Qym5eQfR",
    "status": "PENDING",
    "amount_money": {
      "amount": 1000,
      "currency": "USD"
    },
    "payment_id": "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY",
    "order_id": "1JLEUZeEooAIX8HMqm9kvWd69aQZY",
    "created_at": "2021-10-13T21:23:19.116Z",
    "updated_at": "2021-10-13T21:23:19.508Z",
    "app_fee_money": {
      "amount": 10,
      "currency": "USD"
    },
    "location_id": "L88917AVBK2S5",
    "reason": "Example"
  }
}

Error Descriptions

400 Bad request AMOUNT_TOO_HIGH

The requested payment amount is too high for the provided payment source.

>
400 Bad request CARD_TOKEN_USED

The provided card token (nonce) was already used to process the payment or refund.

>
400 Bad request INVALID_CARD

The credit card cannot be validated based on the provided details.

>
400 Bad request INVALID_CARD_DATA

Generic error - the provided card data is invalid.

>
400 Bad request PAYMENT_NOT_REFUNDABLE

The payment is not refundable. For example, the payment has been disputed and is no longer eligible for refunds.

>
400 Bad request REFUND_AMOUNT_INVALID

The requested refund amount exceeds the amount available to refund.

>
400 Bad request REFUND_DECLINED

Request failed - The card issuer declined the refund.

>
400 Bad request
{
  "errors": [
    {
      "code": "AMOUNT_TOO_HIGH",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}