# Refund a cancelled reservation (API example)

Source: https://developer.avalara.com/hospitality-integration-guide/xdq9088696058040/

# Refund a cancelled reservation (API example)

Learn how to process a refund for a cancelled reservation, including creating and managing transactions.

In this scenario, a guest is cancelling a reservation and receiving a refund. Be sure to review your refund policy when refunding cancelled reservations.

In this scenario, a guest books a reservation at a Bed and Breakfast. The merchant charges the full amount on the credit card at the time of booking. The customer then cancels the reservation within the merchant's timeframe for receiving a full refund.

## Transaction 1

-   The document date is May 20, 2021.

-   The document type is `SalesInvoice`.

-   The document code is `Smith-5-20`.

-   The [parameters](https://developer.avalara.com/api-reference/avatax/rest/v2/models/TransactionLineParameterModel/) specified on this transaction are:

    -   `NumberOfNights`

    -   `EstablishmentType`

**View example**:

```
curl
    -X POST
    -H 'Accept: application/json'
    -H 'Authorization: Basic ${btoa(`:`)}'
    -H 'Content-Type: application/json'
    --data '{
      "lines": [
{
  "number": "1",
  "quantity": 1,
  "amount": 100,
  "taxCode": "SL090200",
  "description": "Lodging",
  "addresses": {
    "singleLocation": {
      "line1": "255 South King St, Suite 1200",
      "city": "Seattle",
      "region": "WA",
      "country": "US",
      "postalCode": "98104"
    }
  },
  "parameters":[
    {
      "name":"NumberOfNights",
      "value":"5",
      "unit": "Count"
    },
    {
      "name": "EstablishmentType",
      "value": "BedAndBreakfast"
    }
  ]
}
      ],
      "type": "SalesInvoice",
      "date": "2021-05-20",
      "code": "SMITH-5-20",
      "companyCode": "ROSEBANDB",
      "customerCode": "SMITH",
      "commit": true,
      "currencyCode": "USD",
      "description": "Lodging"
    }'
    'https://sandbox-rest.avatax.com/api/v2/transactions/create'
```

## Transaction 2

-   The document date is May 25, 2021.

-   The document type is `ReturnInvoice`.

-   The [parameters](https://developer.avalara.com/api-reference/avatax/rest/v2/models/TransactionLineParameterModel/) specified in the original invoice are also specified in the return invoice. Failing to include these parameters will likely result in a difference between the tax calculated in the original sales invoice and in the return invoice.

-   Set a negative value for the line item `amount`.

-   Set the `transactiondate` to the current date; set the tax `overridetaxDate` to the original invoice date.

**View example**:

```
curl
    -X POST
    -H 'Accept: application/json'
    -H 'Authorization: Basic ${btoa(`:`)}'
    -H 'Content-Type: application/json'
    --data '{
      "lines": [
{
  "number": "1",
  "quantity": 1,
  "amount": -100,
  "taxCode": "SL090200",
  "description": "Lodging",
  "addresses": {
    "singleLocation": {
      "line1": "255 South King St, Suite 1200",
      "city": "Seattle",
      "region": "WA",
      "country": "US",
      "postalCode": "98104"
    }
  },
  "parameters":[
    {
      "name":"NumberOfNights",
      "value":"5",
      "unit": "Count"
    },
    {
      "name": "EstablishmentType",
      "value": "BedAndBreakfast"
    }
  ]
}
      ],
      "taxOverride":{
"type": "TaxDate",
"taxDate":"2021-05-20",
"reason": "Return"
      },
      "type": "ReturnInvoice",
      "date": "2021-05-25",
      "code": "SMITH-5-20",
      "companyCode": "ROSEBANDB",
      "customerCode": "SMITH",
      "commit": true,
      "currencyCode": "USD",
      "description": "Lodging"
    }'
    'https://sandbox-rest.avatax.com/api/v2/transactions/create'
```