Refunds API

Copper provides an API for all major CRUD operations related to Refunds.

Create a Refund

POST /refunds

Creates a new Refund resource.

When you create a new Refund, you must specify a Transaction on which to create it.

Creating a new Refund will refund a Transaction that has previously been created but not yet refunded. Funds will be refunded to the credit or debit card that was originally charged.

You can optionally Refund only part of a charge. You can do so multiple times, until the entire charge has been refunded.

Once entirely refunded, a charge can’t be refunded again. This method will return an error when called on an already-refunded Transaction, or when trying to refund more money than is left on a Transaction.

Parameters

The following parameters can be specified when creating a new Refund:

Parameter Type Required? Description
transaction string Required The Transaction id to refund.
amount integer Optional A positive integer representing the number of sub-units to refund in the charge currency. Can refund only up to the remaining, unrefunded amount on the transaction. If no amount is specified, default will be assumed to be the entire unrefunded amount remaining on the Transaction.
reason string Optional The reason for the refund. Default is null.
metadata object Optional Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

Returns

A Refund resource if object creation was successful.

Example

curl https://api.usecopper.com/next/refunds \
    -u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX: \
    -d transaction=txn_XXXXXXXXXXXXXX \
    -d amount=100

Retrieve a Refund

GET /refunds/{id}

Retrieves an existing Refund resource.

Parameters

This API method only accepts a single parameter, the id, via the URL path.

Returns

An Refund resource if a valid id was provided.

Example

curl https://api.usecopper.com/next/refunds/someid \
    -u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX:

Update a Refund

POST /refunds/{id}

Updates an existing Refund resource.

Parameters

Only the metadata Refund property can be updated using this API. To unset the metadata parameter or any of its sub-properties, post an empty value for it.

Parameter Type Description
metadata object Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

Returns

The updated Refund resource if object update was successful.

Example

curl https://api.usecopper.com/next/refunds/someid \
    -u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX: \
    -d "metadata[hi]"="there"

List Refunds

GET /refunds

Returns one or more Refund resources. The Refunds are returned in sorted order, with the most recent Refunds appearing first. For convenience, the 10 most recent Refunds are always available by default on the Transaction object.

Parameters

This API accepts the base pagination parameters. In addition, you may provide the following parameters to further refine your query:

Parameter Type Required? Description
transaction string Optional A Transaction identifier to filter the response list to only Refunds for the specified Transaction.

Returns

An object containing the matching refunds, if any. The response data format is described in more detail in the pagination list response format documentation.

Example

curl https://api.usecopper.com/next/refunds \
    -u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX: \
    -d limit=3 \
    -d transaction=txn_XXXXXXXXXXXXXX \
    -G