Backend API

Refunds are issued against a payment. The sum of refunds can't exceed the total payment amount. Related orders and invoices are automatically updated with refund totals.

Fields

idobjectId

Unique identifier for the refund.

amountcurrencyrequired

Refund amount denominated in currency.

methodstringrequired

Method of refund. Can be card, account, amazon, paypal, or any one of the manual methods defined in payment settings. Defaults to the original payment method.

parent_idobjectIdrequired

ID of the payment the refund was issued for.

asyncbooleanauto

Indicates the refund is processed asynchronously. The refund will be updated in the future while success is undefined.

currencystring

Three-letter ISO currency code in uppercase. Defaults to the store's base currency.

date_createddateauto

Date and time the refund was created.

date_updateddateauto

Date and time the refund was last updated.

errorobject

An object describing an error that occurred while interacting with the payment gateway, if applicable.

numberstringauto

Unique incremental refund number assigned automatically.

order_idobjectId

ID of the order the refund was applied to, if applicable.

orderOrder

Expandable link to the order the refund was applied to, if applicable.

parentPayment

Expandable link to the payment.

reason_messagestring

A brief message describing the reason for the refund.

statusenumauto

Status of the refund. Can be pending, which is awaiting async processing, error, or success.

subscription_idobjectIdauto

ID of the subscription the refund was applied to, if applicable.

subscriptionSubscription

Expandable link to the subscription the refund was applied to, if applicable.

successboolean

Indicates the refund was successful. When an error occurs with a payment gateway, this value will be false and error field will be populated.

transaction_idstringauto

External identifier returned by a payment gateway, if applicable.

date_async_updatedate

The date of the next time the payment status will be updated.

The refund model
{
  "id": "60f199509111e70000000042",
  "amount": 20,
  "method": "card",
  "parent_id": "60f199509111e70000000045",
  "async": false,
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.293Z",
  "date_updated": "2021-07-16T14:36:00.293Z",
  "error": null,
  "number": 102934,
  "order_id": "60f199509111e70000000044",
  "reason_message": "Customer returned EX2001",
  "status": "success",
  "success": true,
  "transaction_id": "re_1XNoXdEAeofUkt5SrbA6Swow"
}

To issue a refund, create a refund with the amount and method to return to the customer. A refund can be issued with a different method than the original payment. The total amount refunded can't exceed the total payment amount.

Arguments

amountcurrencyrequired

Refund amount denominated in currency.

parent_idobjectIdrequired

ID of the payment the refund was issued for.

methodstring

Method of refund. Can be card, account, amazon, paypal, or any one of the manual methods defined in payment settings. Defaults to the original payment method.

POST/payments:refunds
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.post('/payments:refunds', {
  amount: 20,
  parent_id: '60f199509111e70000000047',
  method: 'card'
});
Response
{
  "id": "60f199509111e70000000042",
  "amount": 20,
  "method": "card",
  "parent_id": "60f199509111e7000000004a",
  "async": false,
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.293Z",
  "date_updated": "2021-07-16T14:36:00.293Z",
  "error": null,
  "number": 102934,
  "order_id": "60f199509111e70000000044",
  "reason_message": "Customer returned EX2001",
  "status": "success",
  "success": true,
  "transaction_id": "re_1XNoXdEAeofUkt5SrbA6Swow"
}

Retrieve an existing refund using the ID that was returned when created.

Arguments

idobjectIdrequired

The id of the refund to retrieve.

expandstring

Expanding link fields and child collections is performed using the expand argument.

  • For example, expand=account would return a related customer account if one exists.

When the field represents a collection, you can specify the query limit.

  • For example, expand=variants:10 would return up to 10 records of the variants collection.

See expanding for more details.

fieldsstring

Return only the specified fields in the result. For example fields=name,slug would return only the fields name and slug in the response. Supports nested object and array fields using dot-notation, for example, items.product_id. The category id is always returned.

includestring

Include one or more arbitrary queries in the response, possibly related to the main query.

See including for more details.

GET/payments:refunds/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/payments:refunds/{id}', {
  id: '60f199509111e7000000004c'
});
Response
{
  "id": "60f199509111e70000000050",
  "amount": 20,
  "method": "card",
  "parent_id": "60f199509111e70000000051",
  "async": false,
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.293Z",
  "date_updated": "2021-07-16T14:36:00.293Z",
  "error": null,
  "number": 102934,
  "order_id": "60f199509111e70000000044",
  "reason_message": "Customer returned EX2001",
  "status": "success",
  "success": true,
  "transaction_id": "re_1XNoXdEAeofUkt5SrbA6Swow"
}

Return a list of refunds.

Arguments

expandstring

Expand link fields and child collections by using the expand argument.

  • For example, expand=account would return a related customer account if one exists.

When the field represents a collection, you can specify the query limit.

  • For example, expand=variants:10 would return up to 10 records of the variants collection.

See expanding for more details.

fieldsstring

Returns only the specified fields in the result.

  • For example fields=name,slug would return only the fields name and slug in the response.

Supports nested object and array fields using dot-notation.

  • For example, items.product_id. The product id is always returned.
includeobject

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limitint

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

pageint

The page number of results to return given the specified or default limit.

searchstring

A text search is performed using the search argument. Searchable fields are defined by the model.

  • For example, search=red would return records containing the word "red" anywhere in the defined text fields.

See searching for more details.

sortstring

Expression to sort results by using a format similar to a SQL sort statement.

  • For example, sort=name asc would return records sorted by name ascending.

See sorting for more details.

whereobject

An object with criteria to filter the result.

  • For example, active=true would return records containing a field active with the value true.

It's also possible to use query operators, for example, $eq, $ne, $gt, and more.

See querying for more details.

GET/payments:refunds
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/payments:refunds', {
  limit: 25,
  page: 1
});
Response
{
  "count": 51,
  "results": [
    {
      "id": "60f199509111e70000000042",
      "amount": 20,
      "method": "card",
      "parent_id": "60f199509111e70000000055",
      "async": false,
      "currency": "USD",
      "date_created": "2021-07-16T14:36:00.293Z",
      "date_updated": "2021-07-16T14:36:00.293Z",
      "error": null,
      "number": 102934,
      "order_id": "60f199509111e70000000044",
      "reason_message": "Customer returned EX2001",
      "status": "success",
      "success": true,
      "transaction_id": "re_1XNoXdEAeofUkt5SrbA6Swow"
    },
    {...},
    {...}
  ],
  "page": 1,
  "pages": {
    "1": {
      "start": 1,
      "end": 25
    },
    "2": {
      "start": 26,
      "end": 50
    },
    "2": {
      "start": 51,
      "end": 51
    }
  }
}