Carts and prices
Each configuration has its own price. Your page sends the design to your server, and your server asks huesix what it costs.
How it works
-
The embed has
cart. The shopper presses Add to cart, and your page getshuesix:add-to-cartwith the configuration. -
Your page sends your server the design: its
productIdandshareCode. Never a price. - Your server asks the quote API for that product and code, and adds the line at the price it answers, keeping the share code with it.
- The configurator’s button waits for your answer, then says it’s added (or shows your error).
Using a shop huesix has a plugin for? It does all of this for you: see below.
On the page
<script type="module" src="https://www.huesix.com/embed/huesix.js"></script>
<huesix-configurator cart src="https://www.huesix.com/studio/api/public/<workspace>/<product>/manifest.hxp">
</huesix-configurator>
<script type="module">
const configurator = document.querySelector('huesix-configurator');
configurator.addEventListener('huesix:add-to-cart', (event) => {
const { productId, shareCode } = event.detail.configuration;
// Straight away, not after an await: the button waits for this.
event.detail.waitUntil(
fetch('/cart/lines', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ productId, shareCode }),
}).then(async (response) => {
// A rejection's message is shown to the shopper.
if (!response.ok) throw new Error((await response.json()).error);
}),
);
});
</script>
On your server
Each product’s quote address is its manifest’s address with
manifest.hxp replaced by quote. Keep the products you sell on
your server, and never take an address or a price from the browser.
const HUESIX = 'https://www.huesix.com/studio/api/public/<workspace>';
// The huesix products you sell (their ids, as in the configuration).
const SOLD = new Set(['solitaire-ring', 'tennis-bracelet']);
export async function addLine({ productId, shareCode }) {
if (!SOLD.has(productId)) throw new CartError(400, 'That isn’t for sale here.');
const response = await fetch(
`${HUESIX}/${productId}/quote?code=${encodeURIComponent(shareCode)}`,
);
if (!response.ok) throw new CartError(502, 'Prices can’t be checked just now. Try again.');
const quote = await response.json();
if (!quote.priced) throw new CartError(400, 'That isn’t for sale.');
return cart.add({
productId,
shareCode: quote.shareCode, // as it will be made (repaired if it broke a rule)
price: quote.price.subtotal, // before huesix's tax: your shop adds its own
currency: quote.price.currency,
description: quote.summary
.map((line) => `${line.group}: ${line.options.map((o) => o.name).join(', ')}`)
.join('; '),
link: quote.shareUrl, // opens the design in 3D, for the order
});
}
$huesix = 'https://www.huesix.com/studio/api/public/<workspace>';
$sold = ['solitaire-ring', 'tennis-bracelet'];
$line = json_decode(file_get_contents('php://input'), true);
if (!in_array($line['productId'], $sold, true)) {
http_response_code(400);
exit(json_encode(['error' => 'That isn’t for sale here.']));
}
$url = $huesix . '/' . rawurlencode($line['productId'])
. '/quote?code=' . rawurlencode($line['shareCode']);
$quote = json_decode(file_get_contents($url), true);
if (!$quote || !$quote['priced']) {
http_response_code(400);
exit(json_encode(['error' => 'That isn’t for sale.']));
}
add_to_cart($line['productId'], $quote['shareCode'], $quote['price']['subtotal'],
$quote['price']['currency'], $quote['shareUrl']);
import requests
from urllib.parse import quote as escape
HUESIX = "https://www.huesix.com/studio/api/public/<workspace>"
SOLD = {"solitaire-ring", "tennis-bracelet"}
def add_line(product_id: str, share_code: str):
if product_id not in SOLD:
raise CartError(400, "That isn’t for sale here.")
response = requests.get(
f"{HUESIX}/{product_id}/quote", params={"code": share_code}, timeout=10
)
response.raise_for_status()
quote = response.json()
if not quote["priced"]:
raise CartError(400, "That isn’t for sale.")
return cart.add(product_id, quote["shareCode"], quote["price"]["subtotal"],
quote["price"]["currency"], quote["shareUrl"])
Check again at checkout, too: a product published since may cost something else now.
The quote API
GET https://www.huesix.com/studio/api/public/<workspace>/<product>/quote?code=<share code>
Try it: this asks the quote API for real, with one of our example products (or yours, once you’ve given it on the start page).
Public: no key, any origin (selling online is on the Starter plan and up). It prices the live version with the same engine as the configurator.
| Parameter | |
|---|---|
code |
The share code, URL-encoded (up to 4,000 characters). Empty: the product’s defaults. |
v |
A published version, instead of the live one. Only from your own records: an older version may be cheaper. |
product |
A collection’s: which of its products (below). |
{
"productId": "solitaire-ring",
"version": 3,
"shareCode": "band*classic.metal*rose-gold.setting*halo.stone*ruby",
"selection": { "band": ["classic"], "metal": ["rose-gold"], "setting": ["halo"], "stone": ["ruby"] },
"valid": true,
"missing": [],
"arrangement": null,
"personalised": false,
"priced": true,
"price": {
"currency": "AED",
"base": 4200,
"lines": [
{ "label": "Stone: Ruby", "amount": -900, "ref": "stone:ruby" },
{ "label": "Setting: Halo", "amount": 1100, "ref": "setting:halo" }
],
"subtotal": 4400,
"tax": 220,
"total": 4620,
"display": 4620,
"formatted": "AED 4,620.00"
},
"summary": [{ "groupId": "stone", "group": "Stone", "options": [{ "id": "ruby", "name": "Ruby" }] }],
"bom": [{ "sku": "AUR-SOL", "name": "Aurelia Solitaire", "quantity": 1 }],
"leadTimeDays": 10,
"files": [{ "id": "logo", "name": "Your logo", "url": "https://…" }],
"shareUrl": "https://www.huesix.com/<workspace>/solitaire-ring?o=Xw3k9Qp2LmZa"
}
-
shareCodeandselectionare the design as it will be sold. One that breaks the product’s rules (tampered with, or from before a change) comes back repaired, withvalid: false; so does one with a required engraving left empty. Show the shopper what changed, or refuse it. -
missingnames required personalisations left empty, andarrangementsays why a modular arrangement can’t be ordered. Either means the design can’t be made: refuse it, even if you sell repaired codes.personalisedis true for a shopper’s text or logo: don’t cache those quotes. -
Charge
price.subtotal, which is before huesix’s tax, when your shop adds its own (and set huesix’s tax rate to 0 in Options → Pricing).price.linesare the options and rules that change it. priced: false: the product is for exploring only. Don’t sell it.-
files(only with logos) are shoppers’ logos, for making it.shareUrlopens the design in 3D: keep it with the order. Usually it carries a saved design’s id (?o=); under heavy use it carries the code itself (?hx-<product>=). -
Answers are cached for a minute (a day with
v), so a price can be up to two minutes old just after you publish. -
Errors are
{"error": "…"}: 400 for a code that’s too long or a bad version; 402 when the workspace’s plan doesn’t sell online, or it’s suspended; 404 when the product (or that version) isn’t published, orproductisn’t one of the collection’s.
Collections
In a collection, the design is of the product shown, and
configuration.productId says which. Either quote that product at its own
address, as above, or quote at the collection’s address with &product=,
which huesix only prices when it’s one of the collection’s:
GET …/<workspace>/<collection>/quote?product=<productId>&code=<share code>
huesix checkout
No shop, or one whose cart can’t take a configured price? huesix checkout is a shop of its own: a basket of designs priced by huesix, a checkout page, orders in Studio, and receipts for shoppers. You’re paid straight into your own accounts, through the ways to be paid you add; huesix never holds the money.
- Add one or more ways to be paid in Studio → Integrations → Checkout and orders → Ways to be paid.
- Under Your shop, set the countries you deliver to (the checkout then asks for an address), a delivery charge and the basket total from which it’s free, and the sites shoppers may come back to.
- Turn on huesix checkout in a product’s Publish step (Sell online → Any website: huesix checkout), and publish it.
Orders come to Studio → Orders, numbered from 1001, and by webhook. Owners and admins get an email about each, and the shopper a receipt. Sell with the configurator’s Buy now, or draw your own basket and checkout with the shop API.
Ways to be paid
Studio checks each one’s settings with the provider before keeping them, sealed, and never shows a secret again. Shoppers see the ways that take the order’s currency, in the order you list them.
| Provider | Where | How the shopper pays |
|---|---|---|
| Stripe, with your own key | Worldwide | Stripe Checkout |
| Stripe through huesix (Stripe Connect) | Worldwide | Stripe Checkout, on your connected Stripe account. Only when huesix’s admins turn it on. |
| PayPal | Worldwide | PayPal’s approval page |
| Adyen | Worldwide | A payment link (Pay by Link) |
| Checkout.com | Europe, Middle East | Its Hosted Payments Page. It needs the shopper’s country, so only for shops that deliver. |
| Square | US, Canada, UK, Ireland, France, Spain, Australia, Japan | A payment link |
| Mollie | Europe | Mollie’s checkout |
| Razorpay | India | A payment link |
| Paystack | Africa | Paystack’s checkout |
| Flutterwave | Africa | Flutterwave Standard |
| Tap Payments | UAE, Saudi Arabia, Kuwait, Bahrain, Qatar, Oman, Egypt | Tap’s hosted page |
| PayTabs | Gulf, Middle East, North Africa | The Hosted Payment Page of your account’s region |
| Telr | UAE, Saudi Arabia | Telr’s hosted page |
| N-Genius (Network International) | UAE, Africa | N-Genius’s payment page |
| Bank transfer | Anywhere | The order is placed at once, and your bank details are shown and emailed. You mark it paid in Studio. |
| Pay on delivery | Anywhere you deliver | The order is placed at once, with your words shown. You mark it paid in Studio. |
Stripe through huesix is there only when huesix’s admins turn it on. Connect with Stripe then makes you a Stripe account with Stripe’s own sign-up, and payments are charged straight on it, with huesix’s fee (if any) as Stripe’s application fee. With a Stripe key of your own as well, cards are paid through your key.
How an order is marked paid
Nothing a browser sends marks an order paid. When a shopper comes back from a payment page, a provider’s webhook names an order, or the order is opened, huesix asks the provider itself, with your keys, and marks the order paid only when the amount and currency are the order’s.
Webhooks are optional, since a shopper coming back checks too; with one, a payment is seen even when its shopper doesn’t come back. Providers send them to:
POST https://www.huesix.com/studio/api/pay/webhook/<provider>/<workspace id>
Studio shows this address, to copy, for each gateway that needs it set up in its own dashboard. Stripe with your own key has an address of its own, also shown in Studio.
Buy now on a configurator
A product sold with huesix checkout shows Buy now in its configurator, without the
cart attribute. When Stripe is your only way to be paid, Buy now goes
straight to Stripe Checkout. Otherwise it opens huesix’s checkout page for the design,
where the shopper chooses how to pay. Either way it takes the whole tab, and
huesix:checkout tells your page the address first. Back on the product’s
page, ?hx-paid=<product id> makes the configurator thank the shopper.
A page whose huesix:add-to-cart listener calls
event.detail.waitUntil() or event.preventDefault() keeps the
design for its own cart instead.
The shop API
For a page that draws its own basket and checkout. Public: no key, any origin. huesix prices every design from its share code, so your page never sends a price.
GET https://www.huesix.com/studio/api/shop/<workspace>
POST https://www.huesix.com/studio/api/shop/<workspace>/cart
POST https://www.huesix.com/studio/api/shop/<workspace>/orders
GET https://www.huesix.com/studio/api/shop/<workspace>/orders/<id>?key=<key>
POST https://www.huesix.com/studio/api/shop/<workspace>/orders/<id>/pay
Every call takes an optional language: en, ar,
fr, de, es, it, pt,
ru or zh, in a POST’s body or as ?language= on a
GET; without one, the browser’s language. Messages, amounts and address fields come back
in that language. An order keeps the one it was made with: its checkout page and the
shopper’s receipt are in it too.
Errors are {"error": "…"}, worded for the shopper: show them as they are.
404 for a shop, product or order it doesn’t know (or the wrong key); 409 when a design’s
product has changed or isn’t sold with huesix checkout, or the order is already placed;
410 for an order too old to pay; 422 for a basket or details it can’t take; 429 for too
many tries; 402 when the shop can’t sell online just now; 502 when a provider couldn’t
open the payment.
The shop
GET https://www.huesix.com/studio/api/shop/<workspace>
{
"name": "Aurelia Jewellers",
"language": "en",
"methods": [
{ "id": "stripe", "name": "Card", "kind": "gateway", "instructions": null, "live": true },
{ "id": "bank-transfer", "name": "Bank transfer", "kind": "manual", "instructions": "IBAN …", "live": true }
],
"shipping": ["AE", "US"], // countries you deliver to; null: no address asked
"addressForms": { // each one’s own address fields; null label: not asked
"AE": { "regionLabel": "Emirate", "regionRequired": true, "postcodeLabel": null, "postcodeRequired": false },
"US": { "regionLabel": "State", "regionRequired": true, "postcodeLabel": "ZIP code", "postcodeRequired": true }
},
"deliveryFee": { // null: none
"amount": 25, "freeOver": 500, // any currency: its charge, free from freeOver
"byCurrency": { "USD": { "amount": 10, "freeOver": 150 } } // a charge of its own
}
}
methods are all your ways to be paid; an order lists the ones that take its
currency. kind: "manual" is paid outside huesix: show its
instructions. live: false is a test account. Delivery is in
whole units of the order’s currency, before tax: the currency’s own charge when it has
one, else the one for any currency.
A basket
POST https://www.huesix.com/studio/api/shop/<workspace>/cart
{ "items": [{ "product": "solitaire-ring", "code": "band*classic.metal*rose-gold.setting*halo.stone*ruby", "quantity": 1 }] }
{
"currency": "AED",
"lines": [{
"product": "solitaire-ring",
"name": "Aurelia Solitaire",
"code": "band*classic.metal*rose-gold.setting*halo.stone*ruby",
"quantity": 1,
"summary": [{ "group": "Stone", "options": ["Ruby"] }],
"unit": "AED 4,620.00",
"total": "AED 4,620.00",
"image": "https://…/poster.webp"
}],
"subtotal": "AED 4,620.00", // the designs, with tax
"tax": "AED 220.00", // null: none
"delivery": null, // null: free, or nothing to deliver
"total": "AED 4,620.00"
}
-
Up to 30 designs, 1 to 20 of each, of products sold with huesix checkout, all in one
currency.
productis the product’s id, as in its address and inconfiguration.productId;codeis its share code. - Each is priced from its share code with the product’s live version, as the quote API prices it, and refused with the shopper’s reason when it can’t be sold.
- Amounts are written for shoppers, with the products’ tax in them.
An order
POST https://www.huesix.com/studio/api/shop/<workspace>/orders
{
"items": [{ "product": "solitaire-ring", "code": "band*classic.metal*rose-gold.setting*halo.stone*ruby", "quantity": 1 }],
"returnUrl": "https://shop.example/rings/solitaire", // optional: where the shopper comes back to
"ownCheckout": true // optional: your page draws the checkout
}
→ 201 { "id": "…", "key": "…", "url": "https://www.huesix.com/studio/pay/<id>?k=<key>" }
-
The basket is priced again, as above. The order is made before anyone pays, with a
secret
keyfor the shopper’s links: keepidandkeytogether. - It’s in Studio only once it’s placed: paid, or chosen to be paid outside huesix. After a week it can’t be paid; one never placed is cleared after a month.
-
returnUrlmust be on one of your shop’s sites (anyhttps://page when none are listed).ownCheckoutneeds one. urlis huesix’s checkout page for it.
GET https://www.huesix.com/studio/api/shop/<workspace>/orders/<id>?key=<key>
{
"id": "…",
"number": 1001, // null until it’s placed
"shop": "Aurelia Jewellers",
"shopSlug": "<workspace>",
"logo": "https://…/logo.svg", // the shop’s logo in Studio; null: none
"language": "en", // the order’s, unless ?language= asked for another
"placed": true,
"payment": "paid", // or unpaid, failed, refunded
"status": "new", // then processing, shipped, done or cancelled
"method": { "id": "paypal", "name": "PayPal", "kind": "gateway", "instructions": null },
"methods": [], // ways to pay it, while it isn’t placed
"currency": "AED",
"items": [{
"name": "Aurelia Solitaire",
"quantity": 1,
"summary": [{ "group": "Stone", "options": ["Ruby"] }],
"unit": "AED 4,620.00",
"total": "AED 4,620.00",
"image": "https://…/poster.webp",
"link": "https://www.huesix.com/<workspace>/solitaire-ring?o=Xw3k9Qp2LmZa"
}],
"subtotal": "AED 4,620.00",
"tax": "AED 220.00",
"delivery": null,
"total": "AED 4,620.00",
"shipping": ["AE", "SA"],
"addressForms": { "AE": { … }, "SA": { … } }, // as the shop’s, in the order’s language
"customer": { "name": "Sam Lee", "email": "sam@example.com", "phone": null },
"address": { "line1": "…", "line2": null, "city": "Dubai", "state": null, "postal_code": null, "country": "AE" },
"returnUrl": "https://shop.example/rings/solitaire",
"expired": false, // true: too old to pay, start again
"live": true // false: a test payment
}
While its payment is still to come, huesix asks the provider before answering, so this
is the order as it stands. Not placed, with payment unpaid or failed, the
shopper can pay again.
POST https://www.huesix.com/studio/api/shop/<workspace>/orders/<id>/pay
{
"key": "…",
"method": "paypal", // an id from the order’s methods
"customer": { "name": "Sam Lee", "email": "sam@example.com", "phone": "+971 50 123 4567" },
"address": { // when the shop delivers (shipping isn’t null)
"line1": "Villa 12, Street 4",
"line2": "",
"city": "Dubai",
"state": "",
"postalCode": "",
"country": "AE"
}
}
→ { "url": "https://…", "placed": false }
-
nameandemailare needed (the receipt goes there), andphonewhen the shop delivers. An address needsline1,city, acountryyou deliver to, and thestateandpostalCodeitsaddressFormsentry requires. They’re kept sealed. (The order answers the address withpostal_code.) -
placed: false: send the shopper tourl, the provider’s payment page, in the whole tab. -
placed: true: a way paid outside huesix (a bank transfer, pay on delivery) placed the order at once. Show it, or go tourl, which confirms it.
huesix’s checkout page
Without a checkout of your own, make the order and send the shopper to its
url. The page shows the basket, asks for the shopper’s details, offers the
ways to pay, and shows the order once it’s placed, laid out for phones first.
https://www.huesix.com/studio/pay/<id>?k=<key>
Back from a payment, the shopper goes to your returnUrl once the order is
paid, with ?hx-order=<id>&hx-key=<key>, and to huesix’s
page when it isn’t, to see why and try again. Without a returnUrl, huesix’s
page shows the order.
Your own checkout
Make the order with ownCheckout: true and a returnUrl, get it
for its ways to pay and totals, and pay it. Whatever became of the payment,
the shopper comes back to your returnUrl with
?hx-order=<id>&hx-key=<key>: get the order and show it,
paid or ready to try again.
const SHOP = 'https://www.huesix.com/studio/api/shop/<workspace>';
// The bag becomes an order, with the ways it can be paid.
async function startCheckout(bag) {
const { id, key } = await shop('/orders', {
items: bag.map((d) => ({ product: d.productId, code: d.shareCode, quantity: d.quantity })),
returnUrl: location.origin + location.pathname,
ownCheckout: true,
});
sessionStorage.setItem('order', JSON.stringify({ id, key }));
showCheckout(await shop(`/orders/${id}?key=${encodeURIComponent(key)}`));
}
// The shopper's choice and details.
async function pay({ id, key }, method, customer, address) {
const paying = await shop(`/orders/${id}/pay`, { key, method, customer, address });
if (!paying.placed) return void (location.href = paying.url); // the provider's page
showPlaced(await shop(`/orders/${id}?key=${encodeURIComponent(key)}`));
}
// Back from a payment page: the order as it stands.
const back = new URLSearchParams(location.search);
if (back.get('hx-order') && back.get('hx-key')) {
const order = await shop(
`/orders/${back.get('hx-order')}?key=${encodeURIComponent(back.get('hx-key'))}`,
);
if (order.placed) showPlaced(order);
else showCheckout(order); // failed, or not paid yet: they can pay again
}
async function shop(path, body) {
const response = await fetch(SHOP + path, body && {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body),
});
const answer = await response.json();
// Worded for the shopper: show it as it is.
if (!response.ok) throw new Error(answer.error);
return answer;
}
A working example: Aurelia Solitaire, built headless, a whole shop drawn on this API. The ring, its bag and its checkout are in the page’s own design.
Shop plugins
huesix’s plugins check prices with the quote API when a design goes into the cart, again on the cart and at checkout, and keep the design’s options, part numbers and 3D link with each order. Download them from a product’s Publish step in Studio (Sell online), or from Integrations → Shops.
| Shop | What you install |
|---|---|
| Shopify | The huesix app and its theme block. Connect the store in Integrations → Shops, then create or choose the Shopify product in Publish → Sell online. A pricing function charges each configuration inside Shopify. |
| WooCommerce | A WordPress plugin (huesix-woocommerce.zip). |
| Magento and Adobe Commerce |
A module (huesix-magento.zip), unzipped in Magento’s root folder.
|
| PrestaShop 8 and 9 | A module (huesix-prestashop.zip). |
| Shopware 6.5, 6.6 and 6.7 | A plugin (huesix-shopware.zip). |
| OpenCart 4 |
An extension (huesix_opencart.ocmod.zip), uploaded without renaming
it.
|
| BigCommerce | A storefront script added with Script Manager, and the store’s API token in Integrations → BigCommerce. |
| Wix |
huesix checkout with a Custom element, or Velo files for the Wix checkout
(huesix-wix.zip).
|
Each takes a product’s configurator link (its manifest address; on BigCommerce, a custom
field named huesix), with the shop’s own price for the product set to the
price before options. The plugins sell single products; for a collection, link each of
its products to a shop product of its own.