# The refund model

Source: https://developers.swell.is/backend-api/refunds/the-refund-model

## Fields

- `id` (objectId): Unique identifier for the refund.
- `account_card_id` (objectId): ID of the customer's credit card on file used to make the refund, if applicable.
- `amount` (currency, required): Refund amount denominated in `currency`. Default: `{"$formula":"parent.amount_refundable"}`.
- `async` (boolean, auto): Indicates the refund is processed asynchronously. The refund will be updated in the future while `success` is undefined.
- `card` (object): Credit card details used to make the refund, if applicable.
  - `token` (string, required)
  - `exp_month` (int)
  - `exp_year` (int)
  - `brand` (string)
  - `last4` (string)
  - `test` (boolean)
  - `address_check` (string)
  - `zip_check` (string)
  - `cvc_check` (string)
- `currency` (string): Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
- `currency_rate` (float): Currency percentage used in calculating the fixed refund amount.
- `date_async_update` (date): The date of the next time the payment status will be updated.
- `date_created` (date, auto): Date and time the refund was created.
- `date_updated` (date, auto): Date and time the refund was last updated.
- `error` (object): An object describing an error that occurred while interacting with the payment gateway, if applicable.
  - `code` (string): Unique error code.
  - `message` (string): A message describing the error.
- `gateway` (string): ID of the payment gateway that was used to process the refund.
- `method` (string, required): 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. Default: `{"$formula":"parent.method"}`.
- `number` (string, auto): Unique incremental refund number assigned automatically.
- `order` (Order): Expandable link to the order the refund was applied to, if applicable.
- `order_id` (objectId): ID of the order the refund was applied to, if applicable. Default: `{"$formula":"parent.order_id"}`.
- `parent` (Payment): Expandable link to the payment.
- `parent_id` (objectId, required): ID of the payment the refund was issued for.
- `reason` (string): Reason for which the refund was issued.
- `reason_message` (string): A brief message describing the reason for the refund.
- `status` (enum, auto): Status of the refund. Can be `pending`, which is awaiting async processing, `error`, or `success`. Possible values: `pending`, `void`, `error`, `success`. Default: `"pending"`.
- `subscription` (Subscription): Expandable link to the subscription the refund was applied to, if applicable.
- `subscription_id` (objectId, auto): ID of the subscription the refund was applied to, if applicable. Default: `{"$formula":"parent.subscription_id"}`.
- `success` (boolean): 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_id` (string, auto): External identifier returned by a payment gateway, if applicable.

## Example response

```json
{
  "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"
}
```
