Use cases
Worked examples with real request bodies and the amounts the API returns for them.
How to refund one line of a discounted order
When an order-wide discount is spread across lines, a single-line refund must give back what was paid for that line. Here is how Valulog works it out.
Refunds on buy-one-get-one-free orders
Buy X get Y offers make returns awkward. Valulog records which unit was free and refunds what was actually paid for each line, from a frozen snapshot.
Prevent double refunds with idempotency keys
Retries, double-clicks and webhook redeliveries can refund twice. Valulog requires an Idempotency-Key on every write and guards each line in the database.
An audit trail for discounts and refunds
Keep a tamper-evident record of how each order total and refund was reached: frozen, hashed snapshots, a refund ledger per line and an integrity check.
How to split a discount across line items
Share a percentage or fixed discount across order lines in whole pence, including leftover pennies, and keep that split for later refunds.
Why money APIs should use integers, not floats
Floating-point types cannot store many decimal amounts exactly. Here is how Valulog keeps every price, discount and refund in integer minor units instead.
How to stack discounts without confusing the refund
When two discounts apply to one order, the second can use the original line value or what is left after the first. That choice changes each line’s refund later.
Try it: basket and partial refund simulator
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.
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.
Who these use cases are for
They are written for developers and finance teams who build or run shops, marketplaces and order systems, and who have to answer one awkward question reliably: when a customer returns part of a discounted order, how much should they get back?
Each use case starts from a real basket, shows the exact request you send to /v1/calculate or /v1/refunds, and gives the amounts the API returns for it. Every amount is an integer in minor units (pence or cents), so the examples add up to the penny.
The pattern behind every example
- Send the basket and its discount rules once, at checkout. Valulog splits each discount across the lines and stores a frozen, hashed snapshot.
- Keep the
transaction_idit returns alongside your order. - When a line comes back, ask for the refund from that snapshot. The amount is worked out from what was actually paid for that line, never recalculated from today’s prices or rules.
- Send an
Idempotency-Keywith every write, so a retried request returns the original result and never refunds twice.
Valulog is not a payment processor and does not give tax advice: you still pay refunds out through your own provider. To try any example yourself, follow the five-minute quickstart with a free sandbox key (no card, 1,000 operations a month). Paid plans start at £49 a month, including any VAT due; see pricing.