# Charge credit card at time of booking (API example)

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

# Charge credit card at time of booking (API example)

Learn how to create a transaction that charges a credit card at the time of booking, including key parameters and an example request.

In this example, a guest arrives at your motel and is seeking a room for 2 nights. In this case, you’ll create a single transaction that charges the credit card at the time of booking. Additionally, the transaction includes the following information:

-   This example uses `alocationCode` of `SEATAC1` for the address rather than a physical address.

-   This example also includes `areportingLocationCode`. Including `alocationCode` and `areportingLocationCode` ensures that AvaTax pulls in the attributes/parameters that were configured when the location was set up.

-   The document type `isSalesInvoice`.

-   `TheNumberOfNights` is the only [parameter](https://developer.avalara.com/api-reference/avatax/rest/v2/models/TransactionLineParameterModel/) specified on this transaction. AvaTax will pull in additional parameters that were specified when the `SEATAC1` location was configured.

**Example request**:

```
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": {
      "locationCode": "SEATAC1"
    }
  },
  "parameters":[
    {
      "name":"NumberOfNights",
      "value":"2",
      "unit": "Count"
    }
  ]
}
      ],
      "type": "SalesInvoice",
      "date": "2021-05-20",
      "code": "2021-05-20-ABC",
      "companyCode": "ROSEBUDMOTELS",
      "customerCode": "ABC",
      "reportingLocationCode": "SEATAC1",
      "commit": true,
      "currencyCode": "USD",
      "description": "Lodging"
    }'
    'https://sandbox-rest.avatax.com/api/v2/transactions/create'
```