# Refund purchase

Source: https://developer.avalara.com/avatax-for-bevalc/examples/example-refund/

# Refund purchase

As indicated earlier in this document, AvaTax supports the following [document types](https://developer.avalara.com/api-reference/avatax/rest/v2/models/enums/CreateTransactionModel%20%3E%20type/) for beverage alcohol transactions:`SalesInvoice` and`ReturnInvoice`.

This example shows how to refund a transaction using the [CreateTransaction API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/) with a`ReturnInvoice` document type. When refunding a transaction, AvaTax expects a positive quantity and a negative amount.

Keep in mind that when an item is returned, you still want to register refunded transactions using the [RegisterShipment](https://rest.avatax.com/swagger/ui/index.html?urls.primaryName=Alcohol%20Shipping%20Verification#/Shipping%20Verification/put_api_v2_companies__companyCode__transactions__transactionCode__shipment_registration) endpoint in order to adjust the volume metrics. Use`PUT` instead of`DELETE` to maintain a record of the original sale and the refunded transaction.

### Transaction request

The following transaction shows a request for returning packaged alcohol wine.

```
curl  -X POST  -H 'Accept: application/json'  -H 'Authorization: Basic aHR0cHdhdQNoOmY='  -H 'Content-Type: application/json'  --data '{    "type":"ReturnInvoice",    "code": "123434390853",    "companyCode":"DEFAULT",    "customerCode":"13434",    "date":"2020-12-30",    "commit":true,    "lines": [      {        "number":"1",        "quantity":10,        "amount":-100,        "taxCode":"PA2020300",        "itemCode":"12345",        "description":"Packaged alcohol wine",        "parameters":[            {                "name":"AlcoholRouteType",                "value":"DTC"            },            {                "name":"RecipientName",                "value":"John Smith"            },            {                "name":"ContainerSize",                "value":"0.75",                "unit":"Litre"            },            {                "name":"AlcoholContent",                "value":"12.5",                "unit":"Percentage"            },            {                "name":"PackSize",                "value":"12",                "unit":"Count"            },            {                "name":"NetVolume",                "value":"750",                "unit":"Millilitre"            }        ]      }    ],    "addresses": {      "shipFrom":{        "line1":"2100 S Floyd St",        "city":"Louisville",        "region":"KY",        "country":"US",        "postalCode":"40292"      },      "shipTo":{        "line1":"255 S King St",        "line2":"Suite 1200",        "city":"Seattle",        "region":"WA",        "country":"US",        "postalCode":"98104"      }    }  }'  'https://sandbox-rest.avatax.com/api/v2/transactions/create'
```

### Registration request

Call the RegisterShipment endpoint with`PUT` to adjust volume metrics appropriately. In the registration request, be sure to include your`companyCode` and the transaction`code`. In the transaction above, the`companyCode` is`DEFAULT`, and the transaction`code` is`123434390853`. Use`PUT` to maintain a record of both the original sale and the refund. Also, because this is a return invoice, be sure to include`documentType=ReturnInvoice` in the request. You will receive an "Entity not found" error if you omit this from the request because the document type defaults to`SalesInvoice`.

**TIP:** Only call the [RegisterShipment](https://rest.avatax.com/swagger/ui/index.html?urls.primaryName=Alcohol%20Shipping%20Verification#/Shipping%20Verification/put_api_v2_companies__companyCode__transactions__transactionCode__shipment_registration) endpoint when an item is returned. Do not call this endpoint for monetary-only refunds, where the customer still has the product.

```
curl    -X PUT    -H 'Accept: application/json'    -H 'Authorization: Basic aHR0cHdhdQNoOmY='    -H 'Content-Type: application/json'    'https://sandbox-rest.avatax.com/api/v2/companies/DEFAULT/transactions/123434390853/shipment/registration?documentType=ReturnInvoice'
```

### Response

The response returns 204 upon success.

[Previous](/avatax-for-bevalc/examples/example-unsupported-address)

[Next](/avatax-for-bevalc/examples/example-void)