# Order line types

Every cart line has a productType. Most lines take a price and a tax rate, but gift cards and the US sales tax line take a single amount instead. This guide shows which fields each type takes and how they affect the totals.

Every line in your cart has a `productType`. It tells Briqpay what the line is, and it decides which fields the line takes. The general rules for amounts, tax rates and totals are in [Amounts and the cart](https://developer.briqpay.com/docs/payment-module.md#amounts-and-the-cart). This guide covers the types themselves.

## Types you can send

| `productType`  | Use it for                                                            | Fields                                                                             |
| -------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `physical`     | Goods you ship                                                        | Regular line                                                                       |
| `digital`      | Goods with no delivery                                                | Regular line                                                                       |
| `shipping_fee` | Shipping                                                              | Regular line                                                                       |
| `discount`     | A discount as its own line                                            | Regular line                                                                       |
| `deposit`      | A deposit                                                             | Regular line                                                                       |
| `surcharge`    | A fee                                                                 | Regular line                                                                       |
| `gift_card`    | Buying or redeeming a gift card                                       | `productType`, `name`, `giftCardAmount`, and optionally `reference` and `imageUrl` |
| `sales_tax`    | The order's sales tax, US only                                        | `productType`, `name`, `reference`, `totalTaxAmount`                               |
| `adjustment`   | A goodwill amount, in [refunds](https://developer.briqpay.com/api-reference/refund-a-capture.md) only | Regular line                                                                       |

A regular line requires `productType`, `name`, `quantity`, `quantityUnit`, `unitPrice` and `taxRate`. You can also send `reference`, `discountPercentage`, `unitDiscountAmountIncVat`, `imageUrl`, `unitPriceIncVat`, `totalAmount` and `totalVatAmount`. A cart holds at most 256 lines.

Any other value, or any field a type doesn't list, is rejected. This includes `unitPrice` on a gift card line that has a `giftCardAmount`, and on a sales tax line.

## Gift cards

A gift card is a line with `productType: "gift_card"` and a `giftCardAmount` in minor units. It has no `quantity`, `unitPrice`, `taxRate` or discount fields.

> [!NOTE]
> An older gift card format, a regular line with `quantity` 1 and `taxRate` 0, is still accepted. Don't use it for new integrations.

- A positive `giftCardAmount` means the customer buys a gift card.
- A negative `giftCardAmount` means the customer pays with a gift card.

```json title="Redeeming a gift card"
{
  "productType": "gift_card",
  "reference": "giftcard-123",
  "name": "Gift Card",
  "giftCardAmount": -1200
}
```

```json title="Buying a gift card"
{
  "productType": "gift_card",
  "reference": "giftcard-456",
  "name": "Gift Card",
  "giftCardAmount": 1500
}
```

### Effect on the totals

A gift card line has no tax. It counts towards `amountIncVat` and never towards `amountExVat`.

| Cart                                   | `amountIncVat` | `amountExVat` |
| -------------------------------------- | -------------- | ------------- |
| A shirt, 80.00 ex VAT at 25%           | 10000          | 8000          |
| The same cart, 12.00 paid by gift card | 8800           | 8000          |

Because of this, `amountIncVat` can be lower than `amountExVat`, or zero, when a gift card pays for the order.

### Capture and refund

Include the gift card line when you capture or refund, so the amounts add up. Use the same `name` and `reference` as on the original line. Briqpay doesn't compare a tax rate for gift cards.

A gift card line is tracked by amount, not by quantity. A capture or refund can carry part of the original `giftCardAmount`, as long as it doesn't go past what's left of the line.

> [!NOTE]
> Payment providers can treat gift cards differently. Tell your payment providers if you sell or accept gift cards, in case they have their own requirements.

## Sales tax

In some markets, such as the US, sales tax is shown as its own line and not added to the product prices. For that, add one `sales_tax` line to the cart with the whole order's tax in `totalTaxAmount`. Calculate the amount yourself, for example with a tax engine.

```json title="Sales tax line"
{
  "productType": "sales_tax",
  "name": "Sales tax",
  "reference": "sales_tax",
  "totalTaxAmount": 160
}
```

| Field            | Type    | Required | Description                                      |
| ---------------- | ------- | -------- | ------------------------------------------------ |
| `productType`    | string  | Yes      | `sales_tax`                                      |
| `name`           | string  | Yes      | Display name, up to 256 characters               |
| `reference`      | string  | Yes      | Your reference for the line                      |
| `totalTaxAmount` | integer | Yes      | The order's sales tax in minor units. 0 or more. |

The rules:

- The session's `country` must be `US`. In any other country the cart is rejected.
- Don't mix it with tax rates. If any other line has a `taxRate` above 0, the cart is rejected. Set `taxRate` to `0` on the other lines.
- Send one line with the final tax for the whole order.

The tax counts towards `amountIncVat` and never towards `amountExVat`:

```json title="A cart with sales tax"
{
  "currency": "USD",
  "amountIncVat": 2160,
  "amountExVat": 2000,
  "cart": [
    {
      "productType": "physical",
      "reference": "shirt123",
      "name": "T-shirt",
      "quantity": 1,
      "quantityUnit": "pc",
      "unitPrice": 2000,
      "taxRate": 0
    },
    {
      "productType": "sales_tax",
      "reference": "sales_tax",
      "name": "Sales tax",
      "totalTaxAmount": 160
    }
  ]
}
```

On capture and refund, the line is matched by `name` and `reference`. Its `totalTaxAmount` can be lower than the original, so you can capture or refund part of the tax.

## Lines for refunds

[Refund a capture](https://developer.briqpay.com/api-reference/refund-a-capture.md) takes the same lines as a capture, plus `adjustment`. The cart of a refund is checked against the capture, with two exceptions:

- **`adjustment`** is not checked against the capture. Use it for goodwill refunds, such as a partial refund for a damaged item. It takes the regular line fields.
- **`surcharge` with a negative `unitPrice`** is not checked against the capture either. Use it to withhold a fee, such as a return fee, from the refund.

```json title="Refund with a return fee"
{
  "captureId": "a068120f-a4f0-46b7-89cf-4b62e8abcf4c",
  "data": {
    "order": {
      "amountIncVat": 2388,
      "amountExVat": 1910,
      "currency": "SEK",
      "cart": [
        {
          "productType": "physical",
          "reference": "testproduct1",
          "name": "Test product",
          "quantity": 2,
          "quantityUnit": "pc",
          "unitPrice": 1200,
          "taxRate": 2500
        },
        {
          "productType": "surcharge",
          "reference": "Surcharge-1",
          "name": "Return shipping fee",
          "quantity": 1,
          "quantityUnit": "pc",
          "unitPrice": -490,
          "taxRate": 2500
        }
      ]
    }
  }
}
```

```json title="Goodwill refund"
{
  "captureId": "a068120f-a4f0-46b7-89cf-4b62e8abcf4c",
  "data": {
    "order": {
      "amountIncVat": 2875,
      "amountExVat": 2300,
      "currency": "SEK",
      "cart": [
        {
          "productType": "adjustment",
          "reference": "Adjustment-1",
          "name": "Damaged item partial refund",
          "quantity": 1,
          "quantityUnit": "pc",
          "unitPrice": 2300,
          "taxRate": 2500
        }
      ]
    }
  }
}
```

> [!IMPORTANT]
> You can't send `adjustment` when you create a session, update a session, capture or update the cart. Only refunds accept it. The refund still can't be larger than what's left of the capture.
