ValulogDashboard

Refunds on buy-one-get-one-free orders

Published

With a buy-one-get-one-free offer, one unit is paid for and one is free. When something comes back, you need to know which line carried the discount. Valulog records that at the time of sale.

Record which unit was discounted

A BUY_X_GET_Y rule names how many units qualify (buy_quantity), how many get the discount (get_quantity) and how much off they get in basis points (10000 = free). With cheapest_first set, the cheapest eligible units get the discount.

For socks at £8.00 and £6.00 on a buy-one-get-one-free rule, the £6.00 pair is free: its line is recorded as paid £0.00, and the £8.00 line as paid £8.00.

Refund what was paid for the line

Refunding the £8.00 line returns £8.00. A refund of the free line is refused with INSUFFICIENT_REFUNDABLE, because nothing was paid for it.

Whether a customer who returns the paid item may keep the free one is your returns policy. Valulog does not decide it; it gives you the exact paid amount per line so your policy can be applied consistently.

Partial quantities

If a line has several units, refund any number of them with quantity. Valulog tracks units and pence already refunded on each line and refuses anything beyond what was bought or paid.

Buy one get one free (request body)
{
  "currency": "GBP",
  "items": [
    { "id": "line-1", "sku": "SOCKS-A", "unit_price_cents": 800, "quantity": 1 },
    { "id": "line-2", "sku": "SOCKS-B", "unit_price_cents": 600, "quantity": 1 }
  ],
  "discounts": [
    { "rule_id": "BOGOF", "type": "BUY_X_GET_Y", "buy_quantity": 1,
      "get_quantity": 1, "get_discount_basis_points": 10000 }
  ]
}
// → line-1 final_cents 800, line-2 final_cents 0

Valulog is not a payment processor and does not give tax advice. Payments stay with your payment provider; Valulog records how prices, discounts and refunds were calculated.

Run this exact payload in Sandbox

Buy one get one free: calculate the basket, then refund 1 unit of line-1 from the frozen snapshot. Free test key, no card.

# 1. Calculate and freeze the basket (needs jq to read the transaction_id)
TX=$(curl -s https://api.valulog.com/v1/calculate \
  -H "Authorization: Bearer $VALULOG_KEY" \
  -H "Idempotency-Key: demo-bogof-calc" \
  -H "Content-Type: application/json" \
  -d '{
  "currency": "GBP",
  "items": [
    {
      "id": "line-1",
      "sku": "SOCKS-A",
      "unit_price_cents": 800,
      "quantity": 1
    },
    {
      "id": "line-2",
      "sku": "SOCKS-B",
      "unit_price_cents": 600,
      "quantity": 1
    }
  ],
  "discounts": [
    {
      "rule_id": "BOGOF",
      "type": "BUY_X_GET_Y",
      "buy_quantity": 1,
      "get_quantity": 1,
      "get_discount_basis_points": 10000,
      "cheapest_first": true,
      "application_base": "REMAINING_BALANCE"
    }
  ]
}' | jq -r .transaction_id)

# 2. Refund 1 unit(s) of line-1 from the frozen snapshot
curl https://api.valulog.com/v1/refunds \
  -H "Authorization: Bearer $VALULOG_KEY" \
  -H "Idempotency-Key: demo-bogof-refund-1" \
  -H "Content-Type: application/json" \
  -d "{\"transaction_id\": \"$TX\", \"line_item_id\": \"line-1\", \"quantity\": 1, \"reason\": \"Customer return\"}"
Try it here first, no sign-in

The button keeps this payload in your browser and opens your dashboard (sign in with your email first if you are not already), where it is ready to run with your vl_test_ key.

Change the numbers and watch the refund

No sign-in. Edit the basket and the discount rules, then refund a line. This runs Valulog’s own pricing engine (engine 1.3.0) in your browser: nothing is sent or stored, and the IDs, hash and timestamps are generated for this simulation.

Basket (prices in pence)
LineSKUUnit priceQtyDiscountableRemove
line-1
line-2
Discount rules (applied in this order)

Result: how each discount was split

Refund part of the order

Refunds come from the frozen line, not today’s prices. Refund the same line again to see the over-refund guard; the last unit takes any leftover penny.

POST /v1/calculate · … response

…

Copies a ready-to-run curl script for this exact basket and refund, and keeps it on your dashboard. Free sandbox: no card, 1,000 operations a month.

Related