Copper provides an API for all major CRUD operations related to Refunds.
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.
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. |
A Refund resource if object creation was successful.
curl https://api.usecopper.com/next/refunds \
-u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX: \
-d transaction=txn_XXXXXXXXXXXXXX \
-d amount=100
GET /refunds/{id}
Retrieves an existing Refund resource.
This API method only accepts a single parameter, the id
, via the URL path.
An Refund resource if a valid id
was provided.
curl https://api.usecopper.com/next/refunds/someid \
-u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX:
POST /refunds/{id}
Updates an existing Refund resource.
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. |
The updated Refund resource if object update was successful.
curl https://api.usecopper.com/next/refunds/someid \
-u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX: \
-d "metadata[hi]"="there"
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.
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. |
An object containing the matching refunds, if any. The response data format is described in more detail in the pagination list response format documentation.
curl https://api.usecopper.com/next/refunds \
-u sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXX: \
-d limit=3 \
-d transaction=txn_XXXXXXXXXXXXXX \
-G