The Refunds API allows you to refund payments, either in full or partially. You can refund card payments or record refunds for cash or external payments.
Client Methods
List Refunds
Retrieves a list of refunds for the account making the request.
client . Refunds . List ( ctx context . Context , request * square . ListRefundsRequest ) ( * square . ListPaymentRefundsResponse , error )
request
*square.ListRefundsRequest
Request parameters for listing refunds Indicates the start of the time range to retrieve each PaymentRefund for, in RFC 3339 format. Default: The current time minus one year.
Indicates the end of the time range to retrieve each PaymentRefund for, in RFC 3339 format. Default: The current time.
The order in which results are listed:
ASC - Oldest to newest
DESC - Newest to oldest (default)
A pagination cursor returned by a previous call to this endpoint.
Limit results to the location supplied. By default, results are returned for all locations.
If provided, only refunds with the given status are returned.
If provided, only returns refunds whose payments have the indicated source type. Current values include CARD, BANK_ACCOUNT, WALLET, CASH, and EXTERNAL.
The maximum number of results to be returned in a single page. Default: 100 (also the maximum allowed value).
SortField
*square.ListPaymentRefundsRequestSortField
The field used to sort results by. The default is CREATED_AT.
response
*square.ListPaymentRefundsResponse
The list of payment refunds
request := & square . ListRefundsRequest {
BeginTime : square . String ( "2024-01-01T00:00:00Z" ),
EndTime : square . String ( "2024-12-31T23:59:59Z" ),
SortOrder : square . String ( "DESC" ),
LocationID : square . String ( "location_id" ),
Limit : square . Int ( 10 ),
SortField : square . ListPaymentRefundsRequestSortFieldCreatedAt . Ptr (),
}
response , err := client . Refunds . List ( context . TODO (), request )
if err != nil {
log . Fatal ( err )
}
Refund Payment
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.
client . Refunds . RefundPayment ( ctx context . Context , request * square . RefundPaymentRequest ) ( * square . RefundPaymentResponse , error )
request
*square.RefundPaymentRequest
required
Request parameters for refunding a payment A unique string that identifies this RefundPayment request. Keys can be any valid string but must be unique for every RefundPayment request.
The amount of money to refund. Cannot be more than the total_money value of the payment minus the total amount of all previously completed refunds.
The amount of money the developer contributes to help cover the refunded amount. This is part of the application fee scenario.
The unique ID of the payment being refunded. Required when unlinked=false.
The ID indicating where funds will be refunded to. Required for unlinked refunds.
Indicates that the refund is not linked to a Square payment. If set to true, destination_id and location_id must be supplied.
The location ID associated with the unlinked refund. Required for requests specifying unlinked=true.
The Customer ID of the customer associated with the refund. Required if destination_id refers to a card on file.
A description of the reason for the refund.
Used for optimistic concurrency. This opaque token identifies the current Payment version that the caller expects.
response
*square.RefundPaymentResponse
The refund details
request := & square . RefundPaymentRequest {
IdempotencyKey : "9b7f2dcf-49da-4411-b23e-a2d6af21333a" ,
AmountMoney : & square . Money {
Amount : square . Int64 ( int64 ( 1000 )),
Currency : square . CurrencyUsd . Ptr (),
},
AppFeeMoney : & square . Money {
Amount : square . Int64 ( int64 ( 10 )),
Currency : square . CurrencyUsd . Ptr (),
},
PaymentID : square . String ( "R2B3Z8WMVt3EAmzYWLZvz7Y69EbZY" ),
Reason : square . String ( "Customer requested refund" ),
}
response , err := client . Refunds . RefundPayment ( context . TODO (), request )
if err != nil {
log . Fatal ( err )
}
Get Refund
Retrieves a specific refund using the refund_id.
client . Refunds . Get ( ctx context . Context , request * square . GetRefundsRequest ) ( * square . GetPaymentRefundResponse , error )
The unique ID for the desired PaymentRefund.
response
*square.GetPaymentRefundResponse
The refund details
request := & square . GetRefundsRequest {
RefundID : "refund_id" ,
}
response , err := client . Refunds . Get ( context . TODO (), request )
if err != nil {
log . Fatal ( err )
}
Key Concepts
Refund Types
Linked Refunds : Refunds tied to a specific Square payment. The payment_id field is required.
Unlinked Refunds : Refunds not tied to a Square payment (e.g., cash refunds). Requires unlinked=true, destination_id, and location_id.
Partial Refunds
You can refund a portion of a payment by specifying an AmountMoney less than the original payment amount. The refund amount cannot exceed the payment total minus any previously completed refunds.
Refund Status
Refunds can have the following statuses:
PENDING: The refund is being processed
COMPLETED: The refund has been completed
REJECTED: The refund was rejected
FAILED: The refund failed
Learn More