Check out a multi-merchant cart
Create a single order for a cart that contains items from multiple merchants in the marketplace, and start a payment for the whole basket. Each item names the merchant it belongs to; items are validated against the marketplace catalog, commission is resolved per merchant, and one payment covers the entire order.
The response includes a client_secret to complete the payment on the
storefront and a per-merchant breakdown of gross, discount, commission, and net
amounts. Once payment succeeds, the order finalizes automatically β no further
call is required.
Discounts. Pass the optional discounts array to apply a merchantβs own
promotion or gift card to that merchantβs portion of the basket β each entry
names the merchant_store_id and an optional promotion_id and/or
gift_card_code, and the discount reduces only that merchantβs subtotal.
Marketplace-wide promotions run by the operator apply automatically; you do not
pass them. The response reports discount_total, the
operator_funded_discount (the share the operator funded), a per-merchant
discount_breakdown, and discount_amount plus merchant_gross on each
merchant_breakdown entry.
π‘οΈ The server is the price authority (anti-tampering). You never send money
amounts on this call β only identifiers. Each itemβs price is recomputed from the
marketplace catalog, and a discounts entry only names a promotion_id /
gift_card_code; the server independently resolves the actual discount that
merchantβs promotion or gift card grants (and the operator-funded share),
computes every gross, discount_amount, merchant_gross, commission, and the
payment total from those resolved values, and charges exactly that. A named
discount that doesnβt validate (expired, ineligible, wrong store) is rejected with
400 discount_invalid rather than silently applied. There is no client-supplied
discount_amount or per-item price to tamper with β a manipulated basket cannot
lower what is charged. The resolved breakdown is then held server-side and used
verbatim to finalize the order after payment succeeds; nothing the client sends
after checkout can change what each merchant is paid.
Shipping. Each merchantβs items are delivered, and priced, separately: one shipping
line per merchant. By default each merchantβs own delivery rates price their line, from
the shipping_destination (or the shipping_address, which is located when no
destination is sent). The marketplace may instead charge a flat rate per merchant, and may
set a free-shipping threshold: a merchant whose items total at least that much ships free.
To offer carrier options, send a street shipping_address and a parcel per merchant in
shipping_selections to POST /v1/cart/checkout/quote; to choose one, send its rate_id
here. Shipping is paid to whoever ships the items β the merchant, or the marketplace when
it ships on the merchantβs behalf. total_amount includes shipping, shipping_total
reports it, and shipping_breakdown lists each merchantβs line. A shipping amount is never
read from the request. The same computation runs on POST /v1/cart/checkout/quote, so the
shopper can see each line before paying.
Stock is reserved at checkout: the items are held against each merchantβs
inventory immediately so concurrent shoppers cannot oversell the last units,
and the hold becomes a real stock reduction when payment succeeds. If an item
cannot be held, the call returns 400 insufficient_stock and no order or
payment is created. Holds expire automatically if payment is never completed,
returning the stock to availability.
The shopper. Send the shopperβs credential to tie the purchase to them: a
Galactic Core shopper session in x-auth-token (also accepted as
x-customer-token), or an assertion signed by the marketplaceβs own backend in
x-external-auth. With neither, the checkout is a guest checkout. The purchase is
recorded against that credential, which is what later lets the shopper see it in
GET /v1/customers/me, return it, and dispute it. A guest purchase becomes
visible to an account once that account has verified its email address with a
one-time code.
Wallet. A signed-in shopper can spend their marketplace wallet balance: send
wallet_amount to spend up to that much, or use_wallet: true to spend as much
as the checkout allows. The balance is held while payment is pending and returned
if the payment fails or is abandoned. The charge never falls below the payment
providerβs minimum for the currency, so a wallet cannot pay for a whole basket.
The response reports wallet_applied, and total_amount is the amount charged
after it. Each merchant is still paid their full net: the marketplace operator
funds the wallet.
Currency: every price is charged in the marketplaceβs currency. A merchant who prices in
another currency is converted with the exchange rate the marketplace sets for that currency β
items, the merchantβs discounts, gift-card amounts and delivery fees alike, each rounded to
the marketplace currencyβs minor units. A merchant whose currency has no rate in the
marketplace cannot be bought from there (400 item_currency_unsupported).
Shipping: each merchantβs items are priced by that merchantβs delivery rates, converted to
the marketplaceβs currency with the marketplaceβs exchange rate; items the marketplace ships
itself are priced by the marketplaceβs own delivery rates (pricing: operator_rate). A
marketplace flat rate or free-shipping threshold overrides both.
Shipping errors: 400 shipping_destination_required when a merchantβs delivery rate needs
a location and none can be found, 400 shipping_not_deliverable when a merchant (or the
marketplace, for items it ships) does not deliver to the address, 400 shipping_currency_unsupported when the marketplace has no exchange rate for the currency a
merchantβs delivery rates are set in, 400 shipping_rate_invalid when a chosen carrier option is unknown,
expired, not in the marketplaceβs currency, or chosen for items the marketplace ships itself,
and 502 shipping_unavailable when shipping cannot be priced right now.
Requires the marketplace operator key.
Send an Idempotency-Key header to make a retry safe: a repeat of the same request with the
same key returns the purchase the first attempt created (200, the same order_group_id and
PaymentIntent) instead of creating a second order, holding stock twice or raising a second
charge. Keys are unique per marketplace and environment.
curl --request POST \
--url https://api.tybritelabs.com/v1/cart/checkout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"product_id": "11111111-1111-1111-1111-111111111111",
"variant_id": "22222222-2222-2222-2222-222222222222",
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"quantity": 2
}
],
"customer_email": "john.doe@example.com",
"customer_name": "John Doe",
"currency": "USD",
"shipping_address": {
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10118",
"country": "US"
},
"shipping_destination": {
"latitude": 40.7484,
"longitude": -73.9857
},
"discounts": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"promotion_id": "8a7b6c5d-1234-5678-9abc-def012345678",
"gift_card_code": "GC-XXXX-YYYY"
}
]
}
'import requests
url = "https://api.tybritelabs.com/v1/cart/checkout"
payload = {
"items": [
{
"product_id": "11111111-1111-1111-1111-111111111111",
"variant_id": "22222222-2222-2222-2222-222222222222",
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"quantity": 2
}
],
"customer_email": "john.doe@example.com",
"customer_name": "John Doe",
"currency": "USD",
"shipping_address": {
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10118",
"country": "US"
},
"shipping_destination": {
"latitude": 40.7484,
"longitude": -73.9857
},
"discounts": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"promotion_id": "8a7b6c5d-1234-5678-9abc-def012345678",
"gift_card_code": "GC-XXXX-YYYY"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
product_id: '11111111-1111-1111-1111-111111111111',
variant_id: '22222222-2222-2222-2222-222222222222',
merchant_store_id: '3f1a2b4c-1111-2222-3333-444455556666',
quantity: 2
}
],
customer_email: 'john.doe@example.com',
customer_name: 'John Doe',
currency: 'USD',
shipping_address: {
line1: '350 5th Ave',
city: 'New York',
state: 'NY',
postal_code: '10118',
country: 'US'
},
shipping_destination: {latitude: 40.7484, longitude: -73.9857},
discounts: [
{
merchant_store_id: '3f1a2b4c-1111-2222-3333-444455556666',
promotion_id: '8a7b6c5d-1234-5678-9abc-def012345678',
gift_card_code: 'GC-XXXX-YYYY'
}
]
})
};
fetch('https://api.tybritelabs.com/v1/cart/checkout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tybritelabs.com/v1/cart/checkout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'product_id' => '11111111-1111-1111-1111-111111111111',
'variant_id' => '22222222-2222-2222-2222-222222222222',
'merchant_store_id' => '3f1a2b4c-1111-2222-3333-444455556666',
'quantity' => 2
]
],
'customer_email' => 'john.doe@example.com',
'customer_name' => 'John Doe',
'currency' => 'USD',
'shipping_address' => [
'line1' => '350 5th Ave',
'city' => 'New York',
'state' => 'NY',
'postal_code' => '10118',
'country' => 'US'
],
'shipping_destination' => [
'latitude' => 40.7484,
'longitude' => -73.9857
],
'discounts' => [
[
'merchant_store_id' => '3f1a2b4c-1111-2222-3333-444455556666',
'promotion_id' => '8a7b6c5d-1234-5678-9abc-def012345678',
'gift_card_code' => 'GC-XXXX-YYYY'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tybritelabs.com/v1/cart/checkout"
payload := strings.NewReader("{\n \"items\": [\n {\n \"product_id\": \"11111111-1111-1111-1111-111111111111\",\n \"variant_id\": \"22222222-2222-2222-2222-222222222222\",\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"quantity\": 2\n }\n ],\n \"customer_email\": \"john.doe@example.com\",\n \"customer_name\": \"John Doe\",\n \"currency\": \"USD\",\n \"shipping_address\": {\n \"line1\": \"350 5th Ave\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10118\",\n \"country\": \"US\"\n },\n \"shipping_destination\": {\n \"latitude\": 40.7484,\n \"longitude\": -73.9857\n },\n \"discounts\": [\n {\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"promotion_id\": \"8a7b6c5d-1234-5678-9abc-def012345678\",\n \"gift_card_code\": \"GC-XXXX-YYYY\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tybritelabs.com/v1/cart/checkout")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"product_id\": \"11111111-1111-1111-1111-111111111111\",\n \"variant_id\": \"22222222-2222-2222-2222-222222222222\",\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"quantity\": 2\n }\n ],\n \"customer_email\": \"john.doe@example.com\",\n \"customer_name\": \"John Doe\",\n \"currency\": \"USD\",\n \"shipping_address\": {\n \"line1\": \"350 5th Ave\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10118\",\n \"country\": \"US\"\n },\n \"shipping_destination\": {\n \"latitude\": 40.7484,\n \"longitude\": -73.9857\n },\n \"discounts\": [\n {\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"promotion_id\": \"8a7b6c5d-1234-5678-9abc-def012345678\",\n \"gift_card_code\": \"GC-XXXX-YYYY\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tybritelabs.com/v1/cart/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"product_id\": \"11111111-1111-1111-1111-111111111111\",\n \"variant_id\": \"22222222-2222-2222-2222-222222222222\",\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"quantity\": 2\n }\n ],\n \"customer_email\": \"john.doe@example.com\",\n \"customer_name\": \"John Doe\",\n \"currency\": \"USD\",\n \"shipping_address\": {\n \"line1\": \"350 5th Ave\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10118\",\n \"country\": \"US\"\n },\n \"shipping_destination\": {\n \"latitude\": 40.7484,\n \"longitude\": -73.9857\n },\n \"discounts\": [\n {\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"promotion_id\": \"8a7b6c5d-1234-5678-9abc-def012345678\",\n \"gift_card_code\": \"GC-XXXX-YYYY\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"order_group_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"group_number": "MKT-100042",
"payment_intent_id": "<string>",
"client_secret": "<string>",
"currency": "USD",
"subtotal": 245,
"total_amount": 245,
"shipping_total": 15,
"shipping_breakdown": [
{
"merchant_store_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 6,
"pricing": "seller_rate",
"fulfilled_by": "seller",
"is_free": false,
"free_threshold": 75,
"description": "Local delivery",
"selected_rate_id": "<string>",
"rates": [
{
"rate_id": "<string>",
"provider": "USPS",
"service": "Priority Mail",
"amount": 8.1,
"currency": "USD",
"estimated_days": 2,
"source": "shippo"
}
]
}
],
"wallet_applied": 0,
"discount_total": 10,
"operator_funded_discount": 5,
"discount_breakdown": [
{
"merchant_store_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchant_discount": 5,
"gift_card_amount": 0,
"operator_funded_discount": 5
}
],
"merchant_breakdown": [
{
"merchant_store_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"gross_amount": 130,
"discount_amount": 10,
"merchant_gross": 120,
"operator_funded_discount": 0,
"fulfillment_mode": "merchant",
"shipping_charged": 6,
"shipping_amount": 6,
"shipping_retained": 0,
"shipping_commission": 0,
"shipping_pricing": "seller_rate",
"commission_amount": 12,
"net_amount": 114,
"commission_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}{
"order_group_id": "44444444-4444-4444-4444-444444444444",
"group_number": "MKT-100042",
"payment_intent_id": "pi_3Pxxxxxxxxxxxx",
"client_secret": "pi_3Pxxxxxxxxxxxx_secret_yyyyyyyy",
"currency": "USD",
"subtotal": 245,
"total_amount": 235.99,
"shipping_total": 5.99,
"wallet_applied": 0,
"discount_total": 15,
"operator_funded_discount": 5,
"discount_breakdown": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"merchant_discount": 10,
"gift_card_amount": 0,
"operator_funded_discount": 5
}
],
"shipping_breakdown": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"amount": 5.99,
"pricing": "seller_rate",
"fulfilled_by": "seller",
"is_free": false,
"free_threshold": null,
"description": "Local (within 10 km)",
"selected_rate_id": null
}
],
"merchant_breakdown": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"gross_amount": 245,
"discount_amount": 10,
"merchant_gross": 235,
"operator_funded_discount": 5,
"fulfillment_mode": "merchant",
"shipping_charged": 5.99,
"shipping_amount": 5.99,
"shipping_retained": 0,
"shipping_commission": 0,
"shipping_pricing": "seller_rate",
"commission_amount": 23.5,
"net_amount": 217.49,
"commission_rule_id": "7e6d5c4b-1234-5678-9abc-def012345678"
}
]
}{
"error": {
"code": "invalid_request",
"message": "Invalid request parameters",
"details": "The 'email' field is required"
}
}{
"error": {
"code": "unauthorized",
"message": "Missing or invalid Authorization header"
}
}{
"error": {
"code": "forbidden",
"message": "This operation requires a secret key. Publishable keys cover catalogue reads and the actions a shopper takes for themselves."
}
}{
"error": {
"code": "not_found",
"message": "Resource not found"
}
}{
"error": {
"code": "provider_not_live",
"message": "This marketplace has not finished connecting its payment account."
}
}{
"error": {
"code": "server_error",
"message": "An unexpected error occurred"
}
}{
"error": {
"code": "provider_error",
"message": "Payment initialization failed"
}
}Authorizations
API Key Authentication
Use your API key in the Authorization header:
Authorization: Bearer tybrite_sk_live_YOUR_KEY
Key Types:
Secret Keys (Server-Side Only):
- Format:
tybrite_sk_live_*(production) ortybrite_sk_test_*(sandbox) - Full read/write access to all endpoints
- β οΈ NEVER expose in client-side code or public repositories
- Required for: every write a shopper does not make for themselves, authentication, payment verification, AI recommendations
Publishable Keys (Client-Safe):
- Format:
tybrite_pk_live_*(production) ortybrite_pk_test_*(sandbox) - Catalogue reads, plus the actions a shopper takes for themselves
- β Safe for client-side JavaScript, mobile apps, and public code
- Allowed for: browsing products, search, CMS content, pricing queries, cart and wishlist, reviews, storefront events, and the Agent API's quotes, cart drafts and checkout intents
Endpoint-Specific Requirements:
- Authentication endpoints (
/v1/auth/*): Secret key required - Payment verification (
POST /v1/payments/verify): Secret key required - AI Recommendations (
POST /v1/recommendations): Secret key required - Semantic Search (
POST /v1/search): Both key types allowed (read-only operation) - Shopper actions (cart, wishlist, reviews, storefront events, Agent API quotes, cart drafts and checkout intents): Both key types allowed
- All other write operations: Secret key required
- All read operations: Both key types allowed
Using a publishable key for restricted operations returns 403 Forbidden.
Headers
A unique key for this checkout attempt. Repeating the request with the same key and the same body returns the original result with 200; the same key with a different body is refused with 409 idempotency_conflict.
255Session token of a shopper signed in through Galactic Core, tying the checkout to their account rather than treating it as a guest checkout. Optional; send at most one shopper credential.
Alias of x-auth-token.
A shopper assertion signed by the marketplace's own backend with the marketplace's signing secret, for marketplaces that run their own sign-in. The claim carries external_id, iat and exp (at most 300 seconds apart), and optionally email with email_verified: true. Optional; send at most one shopper credential.
Body
The cart line items to check out.
1Show child attributes
Show child attributes
ISO currency code for the order. Defaults to USD.
"USD"
Where the order is going (line1, line2, city, state, postal_code, country). Located to price shipping when shipping_destination is omitted.
Where the basket is going, used to price each merchant's delivery rates. Send coordinates, or a place name. When omitted, the shipping_address is located instead.
Show child attributes
Show child attributes
Optional per-merchant shipping choices: a carrier option (rate_id) returned by POST /v1/cart/checkout/quote. Without one, the merchant's own delivery rate applies.
Show child attributes
Show child attributes
Spend up to this much of the signed-in shopper's marketplace wallet on this checkout. Capped by the balance and by the payment provider's minimum charge.
Spend as much of the signed-in shopper's wallet as the checkout allows.
Optional per-merchant discounts. Each entry applies a merchant's own promotion and/or gift card to that merchant's portion of the basket, reducing only that merchant's subtotal. Marketplace-wide promotions run by the operator apply automatically and are not passed here.
Show child attributes
Show child attributes
Where the shopper came from, recorded so the sale is credited to the right traffic source in the merchant's reports. The same fields are also accepted at the top level of this request body if you already send them that way.
Show child attributes
Show child attributes
Response
A repeat of an earlier checkout with the same Idempotency-Key and body. The body is the original checkout's result, with the same order_group_id and payment_intent_id.
A created multi-merchant order awaiting payment. Use client_secret to
complete the payment on the storefront; the order finalizes automatically
once payment succeeds.
Identifier for the multi-merchant order.
Human-readable reference for the order.
"MKT-100042"
Identifier of the payment to complete on the storefront.
Secret used by the storefront payment form to complete the charge.
"USD"
245
The amount charged β the basket after every discount, plus shipping, less wallet_applied.
245
Shipping across every merchant, included in total_amount.
15
One shipping line per merchant.
Show child attributes
Show child attributes
How much of the shopper's marketplace wallet this checkout spends. Held while payment is pending and returned if the payment fails. Funded by the marketplace operator, so each merchant's net is unchanged.
0
Total discount applied across the whole basket β the sum of every merchant's own promotion and gift card discounts plus any marketplace-wide promotion run by the operator.
10
The portion of discount_total funded by the marketplace operator (for example a marketplace-wide promotion). The remainder is funded by individual merchants.
5
Per-merchant breakdown of how discounts were applied.
Show child attributes
Show child attributes
Per-merchant gross, discount, commission, and net amounts for this order.
Show child attributes
Show child attributes
curl --request POST \
--url https://api.tybritelabs.com/v1/cart/checkout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"product_id": "11111111-1111-1111-1111-111111111111",
"variant_id": "22222222-2222-2222-2222-222222222222",
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"quantity": 2
}
],
"customer_email": "john.doe@example.com",
"customer_name": "John Doe",
"currency": "USD",
"shipping_address": {
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10118",
"country": "US"
},
"shipping_destination": {
"latitude": 40.7484,
"longitude": -73.9857
},
"discounts": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"promotion_id": "8a7b6c5d-1234-5678-9abc-def012345678",
"gift_card_code": "GC-XXXX-YYYY"
}
]
}
'import requests
url = "https://api.tybritelabs.com/v1/cart/checkout"
payload = {
"items": [
{
"product_id": "11111111-1111-1111-1111-111111111111",
"variant_id": "22222222-2222-2222-2222-222222222222",
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"quantity": 2
}
],
"customer_email": "john.doe@example.com",
"customer_name": "John Doe",
"currency": "USD",
"shipping_address": {
"line1": "350 5th Ave",
"city": "New York",
"state": "NY",
"postal_code": "10118",
"country": "US"
},
"shipping_destination": {
"latitude": 40.7484,
"longitude": -73.9857
},
"discounts": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"promotion_id": "8a7b6c5d-1234-5678-9abc-def012345678",
"gift_card_code": "GC-XXXX-YYYY"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
product_id: '11111111-1111-1111-1111-111111111111',
variant_id: '22222222-2222-2222-2222-222222222222',
merchant_store_id: '3f1a2b4c-1111-2222-3333-444455556666',
quantity: 2
}
],
customer_email: 'john.doe@example.com',
customer_name: 'John Doe',
currency: 'USD',
shipping_address: {
line1: '350 5th Ave',
city: 'New York',
state: 'NY',
postal_code: '10118',
country: 'US'
},
shipping_destination: {latitude: 40.7484, longitude: -73.9857},
discounts: [
{
merchant_store_id: '3f1a2b4c-1111-2222-3333-444455556666',
promotion_id: '8a7b6c5d-1234-5678-9abc-def012345678',
gift_card_code: 'GC-XXXX-YYYY'
}
]
})
};
fetch('https://api.tybritelabs.com/v1/cart/checkout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tybritelabs.com/v1/cart/checkout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'product_id' => '11111111-1111-1111-1111-111111111111',
'variant_id' => '22222222-2222-2222-2222-222222222222',
'merchant_store_id' => '3f1a2b4c-1111-2222-3333-444455556666',
'quantity' => 2
]
],
'customer_email' => 'john.doe@example.com',
'customer_name' => 'John Doe',
'currency' => 'USD',
'shipping_address' => [
'line1' => '350 5th Ave',
'city' => 'New York',
'state' => 'NY',
'postal_code' => '10118',
'country' => 'US'
],
'shipping_destination' => [
'latitude' => 40.7484,
'longitude' => -73.9857
],
'discounts' => [
[
'merchant_store_id' => '3f1a2b4c-1111-2222-3333-444455556666',
'promotion_id' => '8a7b6c5d-1234-5678-9abc-def012345678',
'gift_card_code' => 'GC-XXXX-YYYY'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tybritelabs.com/v1/cart/checkout"
payload := strings.NewReader("{\n \"items\": [\n {\n \"product_id\": \"11111111-1111-1111-1111-111111111111\",\n \"variant_id\": \"22222222-2222-2222-2222-222222222222\",\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"quantity\": 2\n }\n ],\n \"customer_email\": \"john.doe@example.com\",\n \"customer_name\": \"John Doe\",\n \"currency\": \"USD\",\n \"shipping_address\": {\n \"line1\": \"350 5th Ave\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10118\",\n \"country\": \"US\"\n },\n \"shipping_destination\": {\n \"latitude\": 40.7484,\n \"longitude\": -73.9857\n },\n \"discounts\": [\n {\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"promotion_id\": \"8a7b6c5d-1234-5678-9abc-def012345678\",\n \"gift_card_code\": \"GC-XXXX-YYYY\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.tybritelabs.com/v1/cart/checkout")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"product_id\": \"11111111-1111-1111-1111-111111111111\",\n \"variant_id\": \"22222222-2222-2222-2222-222222222222\",\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"quantity\": 2\n }\n ],\n \"customer_email\": \"john.doe@example.com\",\n \"customer_name\": \"John Doe\",\n \"currency\": \"USD\",\n \"shipping_address\": {\n \"line1\": \"350 5th Ave\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10118\",\n \"country\": \"US\"\n },\n \"shipping_destination\": {\n \"latitude\": 40.7484,\n \"longitude\": -73.9857\n },\n \"discounts\": [\n {\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"promotion_id\": \"8a7b6c5d-1234-5678-9abc-def012345678\",\n \"gift_card_code\": \"GC-XXXX-YYYY\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tybritelabs.com/v1/cart/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"product_id\": \"11111111-1111-1111-1111-111111111111\",\n \"variant_id\": \"22222222-2222-2222-2222-222222222222\",\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"quantity\": 2\n }\n ],\n \"customer_email\": \"john.doe@example.com\",\n \"customer_name\": \"John Doe\",\n \"currency\": \"USD\",\n \"shipping_address\": {\n \"line1\": \"350 5th Ave\",\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"postal_code\": \"10118\",\n \"country\": \"US\"\n },\n \"shipping_destination\": {\n \"latitude\": 40.7484,\n \"longitude\": -73.9857\n },\n \"discounts\": [\n {\n \"merchant_store_id\": \"3f1a2b4c-1111-2222-3333-444455556666\",\n \"promotion_id\": \"8a7b6c5d-1234-5678-9abc-def012345678\",\n \"gift_card_code\": \"GC-XXXX-YYYY\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"order_group_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"group_number": "MKT-100042",
"payment_intent_id": "<string>",
"client_secret": "<string>",
"currency": "USD",
"subtotal": 245,
"total_amount": 245,
"shipping_total": 15,
"shipping_breakdown": [
{
"merchant_store_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 6,
"pricing": "seller_rate",
"fulfilled_by": "seller",
"is_free": false,
"free_threshold": 75,
"description": "Local delivery",
"selected_rate_id": "<string>",
"rates": [
{
"rate_id": "<string>",
"provider": "USPS",
"service": "Priority Mail",
"amount": 8.1,
"currency": "USD",
"estimated_days": 2,
"source": "shippo"
}
]
}
],
"wallet_applied": 0,
"discount_total": 10,
"operator_funded_discount": 5,
"discount_breakdown": [
{
"merchant_store_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"merchant_discount": 5,
"gift_card_amount": 0,
"operator_funded_discount": 5
}
],
"merchant_breakdown": [
{
"merchant_store_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"gross_amount": 130,
"discount_amount": 10,
"merchant_gross": 120,
"operator_funded_discount": 0,
"fulfillment_mode": "merchant",
"shipping_charged": 6,
"shipping_amount": 6,
"shipping_retained": 0,
"shipping_commission": 0,
"shipping_pricing": "seller_rate",
"commission_amount": 12,
"net_amount": 114,
"commission_rule_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}{
"order_group_id": "44444444-4444-4444-4444-444444444444",
"group_number": "MKT-100042",
"payment_intent_id": "pi_3Pxxxxxxxxxxxx",
"client_secret": "pi_3Pxxxxxxxxxxxx_secret_yyyyyyyy",
"currency": "USD",
"subtotal": 245,
"total_amount": 235.99,
"shipping_total": 5.99,
"wallet_applied": 0,
"discount_total": 15,
"operator_funded_discount": 5,
"discount_breakdown": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"merchant_discount": 10,
"gift_card_amount": 0,
"operator_funded_discount": 5
}
],
"shipping_breakdown": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"amount": 5.99,
"pricing": "seller_rate",
"fulfilled_by": "seller",
"is_free": false,
"free_threshold": null,
"description": "Local (within 10 km)",
"selected_rate_id": null
}
],
"merchant_breakdown": [
{
"merchant_store_id": "3f1a2b4c-1111-2222-3333-444455556666",
"gross_amount": 245,
"discount_amount": 10,
"merchant_gross": 235,
"operator_funded_discount": 5,
"fulfillment_mode": "merchant",
"shipping_charged": 5.99,
"shipping_amount": 5.99,
"shipping_retained": 0,
"shipping_commission": 0,
"shipping_pricing": "seller_rate",
"commission_amount": 23.5,
"net_amount": 217.49,
"commission_rule_id": "7e6d5c4b-1234-5678-9abc-def012345678"
}
]
}{
"error": {
"code": "invalid_request",
"message": "Invalid request parameters",
"details": "The 'email' field is required"
}
}{
"error": {
"code": "unauthorized",
"message": "Missing or invalid Authorization header"
}
}{
"error": {
"code": "forbidden",
"message": "This operation requires a secret key. Publishable keys cover catalogue reads and the actions a shopper takes for themselves."
}
}{
"error": {
"code": "not_found",
"message": "Resource not found"
}
}{
"error": {
"code": "provider_not_live",
"message": "This marketplace has not finished connecting its payment account."
}
}{
"error": {
"code": "server_error",
"message": "An unexpected error occurred"
}
}{
"error": {
"code": "provider_error",
"message": "Payment initialization failed"
}
}
