Skip to content
Developers

Search the guides, the API reference and the changelog.

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.

On this page

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. This guide covers the types themselves.

Types you can send

productTypeUse it forFields
physicalGoods you shipRegular line
digitalGoods with no deliveryRegular line
shipping_feeShippingRegular line
discountA discount as its own lineRegular line
depositA depositRegular line
surchargeA feeRegular line
gift_cardBuying or redeeming a gift cardproductType, name, giftCardAmount, and optionally reference and imageUrl
sales_taxThe order's sales tax, US onlyproductType, name, reference, totalTaxAmount
adjustmentA goodwill amount, in refunds onlyRegular 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.

  • A positive giftCardAmount means the customer buys a gift card.
  • A negative giftCardAmount means the customer pays with a gift card.
{
  "productType": "gift_card",
  "reference": "giftcard-123",
  "name": "Gift Card",
  "giftCardAmount": -1200
}

Effect on the totals

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

CartamountIncVatamountExVat
A shirt, 80.00 ex VAT at 25%100008000
The same cart, 12.00 paid by gift card88008000

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.

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.

{
  "productType": "sales_tax",
  "name": "Sales tax",
  "reference": "sales_tax",
  "totalTaxAmount": 160
}
FieldTypeRequiredDescription
productTypestringYessales_tax
namestringYesDisplay name, up to 256 characters
referencestringYesYour reference for the line
totalTaxAmountintegerYesThe 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:

{
  "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 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.
{
  "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
        }
      ]
    }
  }
}