API Documentation v1.0

Complete integration guide for secure.checkout.best - a white-label checkout platform with Stripe Connect payments, real-time inventory management, and overlay cart widgets.

Overview

secure.checkout.best provides a complete checkout infrastructure for e-commerce platforms. It handles payment processing via Stripe Connect, inventory management with row-level locking, and provides embeddable widgets for any website.

Base URL

https://secure.checkout.best

Integration Flow

1. Provision Store 2. Embed Widget 3. Create Session 4. Process Payment 5. Receive Webhook

Authentication

Internal API (app.buildmyonlinestore.com)

All internal API endpoints require the X-Internal-Secret header:

X-Internal-Secret: your_internal_api_secret
Security: Never expose the internal API secret in client-side code. All internal API calls should be made server-to-server.

Consumer Authentication

Consumer endpoints use JWT Bearer tokens:

Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

GFAVIP SSO (Merchants)

Merchant authentication flows through GFAVIP Simple SSO. Include the token in internal API calls:

X-GFAVIP-Token: gfavip_token_here

Quick Start Guide

For app.buildmyonlinestore.com

When a merchant creates a store, provision it in secure.checkout.best:

POST /api/internal/stores
Content-Type: application/json
X-Internal-Secret: your_secret

{
  "name": "My Store",
  "catalog_id": "550e8400-e29b-41d4-a716-446655440000",
  "gfavip_user_id": "user_123",
  "email": "merchant@example.com",
  "webhook_url": "https://app.buildmyonlinestore.com/webhooks/checkout"
}

For db.51exports.com

secure.checkout.best proxies product data from your catalog API:

GET /api/v1/products/{catalog_id}/{sku}
# Proxies to: db.51exports.com/api/products/{catalog_id}/{sku}
Caching: Product data is cached for 60 seconds to reduce load on db.51exports.com.

Store Management

POST /api/internal/stores

Create a new store in the checkout system. Called by app.buildmyonlinestore.com when a merchant creates a store.

Headers

NameValue
X-Internal-SecretYour internal API secret Required
X-GFAVIP-TokenGFAVIP auth token Optional

Request Body

FieldTypeDescription
namestringStore name Required
catalog_iduuidCatalog ID from db.51exports.com Required
gfavip_user_idstringGFAVIP user ID for merchant
emailstringMerchant email
stripe_account_idstringStripe Connect account ID
statement_descriptorstringAppears on customer statements
logo_urlstringStore logo URL
brand_colorstringHex color (default: #3b82f6)
webhook_urlstringURL for order notifications

Response (201 Created)

{
  "id": "550e8400-e29b-41d4-a716-446655440001",
  "merchant_id": "550e8400-e29b-41d4-a716-446655440002",
  "name": "My Store",
  "catalog_id": "550e8400-e29b-41d4-a716-446655440000",
  "stripe_account_id": "acct_1234567890",
  "brand_color": "#3b82f6",
  "created_at": "2025-11-25T12:00:00Z"
}
PATCH /api/internal/stores/{store_id}

Update an existing store's configuration.

Allowed Fields

FieldTypeDescription
namestringStore name
stripe_account_idstringStripe Connect account
statement_descriptorstringStatement text
logo_urlstringLogo URL
brand_colorstringBrand color hex
webhook_urlstringWebhook URL
GET /api/internal/stores/{store_id}

Retrieve store details by ID.

Widget Integration

Add the checkout widget to any website with a single script tag:

<script src="https://secure.checkout.best/widget.js" data-store="YOUR_STORE_ID"></script>

Add to Cart Buttons

Opens the cart overlay and adds the product:

<button class="checkout-best-add" 
        data-sku="PROD-001" 
        data-name="Product Name" 
        data-price="19.99">
  Add to Cart
</button>

Buy Now Buttons

Adds the product and immediately proceeds to checkout:

<button class="checkout-best-buy" 
        data-sku="PROD-001" 
        data-name="Product Name" 
        data-price="19.99">
  Buy Now
</button>

Button Classes

ClassBehavior
checkout-best-addAdds item to cart and opens the cart overlay
checkout-best-buyAdds item to cart and immediately proceeds to checkout
checkout-best-btnSame as checkout-best-add (legacy support)

Button Data Attributes

AttributeDescription
data-skuProduct SKU Required
data-nameProduct name Required
data-pricePrice in dollars (19.99 = $19.99) Required*
data-price-centsPrice in cents (1999 = $19.99) - alternative to data-price
data-imageProduct image URL
data-quantityDefault quantity (default: 1)
Pricing: Use either data-price (dollars) or data-price-cents (cents). Examples: data-price="40" or data-price-cents="4000" both equal $40.00.

JavaScript API

// Add item programmatically
CheckoutBest.addToCart({
  sku: 'PROD-001',
  name: 'Product Name',
  price_cents: 1999,
  quantity: 1,
  image_url: 'https://example.com/image.jpg'
});

// Open cart overlay
CheckoutBest.openCart();

// Get cart contents
const cart = CheckoutBest.getCart();

// Clear cart
CheckoutBest.clearCart();

Checkout Sessions

POST /api/v1/sessions

Create a checkout session with encrypted token. Rate limited to 10 requests per minute per IP.

Request Body

{
  "store_id": "550e8400-e29b-41d4-a716-446655440001",
  "cart": [
    {
      "sku": "PROD-001",
      "name": "Product Name",
      "price_cents": 1999,
      "quantity": 2,
      "image_url": "https://example.com/image.jpg",
      "catalog_id": "cat_001",
      "catalog_owner_id": "user_xyz",
      "product_cost_cents": 1200
    }
  ],
  "metadata": {
    "source": "chatgpt",
    "conversation_id": "conv_abc123",
    "agent_type": "acp"
  }
}

Cart Item Fields

FieldTypeDescription
skustringProduct SKU Required
namestringProduct name
price_centsintegerPrice in cents (1999 = $19.99)
quantityintegerQuantity Required
image_urlstringProduct image URL
catalog_idstringCatalog ID for multi-catalog attribution
catalog_owner_idstringCatalog owner ID for payouts
product_cost_centsintegerWholesale cost in cents (for margin calculation)

Metadata Fields (ACP Integration)

FieldTypeDescription
sourcestringPurchase source: direct, widget, api, chatgpt, acp, claude, gemini
conversation_idstringAI conversation ID for attribution tracking
agent_typestringType of AI agent (e.g., acp, plugin)

Response (201 Created)

{
  "session_id": "550e8400-e29b-41d4-a716-446655440003",
  "checkout_url": "https://secure.checkout.best/checkout/gAAAAABk...",
  "expires_at": "2025-11-26T12:00:00Z",
  "source": "chatgpt"
}
Token Security: Checkout tokens are encrypted with Fernet and expire after 24 hours. Tokens are regenerated after successful use to prevent replay attacks.
POST /api/v1/checkout/process

Process a checkout session, create order, and optionally create consumer account.

Request Body

{
  "token": "gAAAAABk...",
  "email": "customer@example.com",
  "shipping_address": {
    "name": "John Doe",
    "line1": "123 Main St",
    "city": "New York",
    "state": "NY",
    "postal_code": "10001",
    "country": "US"
  },
  "create_account": true,
  "password": "securepassword123"
}

Response (201 Created)

{
  "order_id": "550e8400-e29b-41d4-a716-446655440004",
  "total_cents": 3998,
  "currency": "usd",
  "status": "pending",
  "requires_payment": true,
  "consumer_token": "eyJhbGciOiJIUzI1NiIs..."
}

Products API

Product data is proxied from db.51exports.com with 60-second caching.

GET /api/v1/products/{catalog_id}/{sku}

Get a single product by SKU from the specified catalog.

GET /api/v1/products/{catalog_id}

Get all products in a catalog.

Inventory Management

Inventory operations use row-level database locking to prevent overselling.

POST /api/v1/inventory/reserve

Reserve inventory for a checkout session. Uses SELECT FOR UPDATE to prevent race conditions.

Request Body

{
  "session_id": "550e8400-e29b-41d4-a716-446655440003",
  "catalog_id": "550e8400-e29b-41d4-a716-446655440000",
  "items": [
    { "sku": "PROD-001", "quantity": 2 },
    { "sku": "PROD-002", "quantity": 1 }
  ]
}

Response

{
  "success": true,
  "reservations": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440005",
      "sku": "PROD-001",
      "quantity": 2,
      "status": "reserved"
    }
  ]
}
POST /api/v1/inventory/confirm

Confirm inventory reservations after successful payment.

{ "session_id": "550e8400-e29b-41d4-a716-446655440003" }
POST /api/v1/inventory/release

Release inventory reservations (e.g., abandoned cart, failed payment).

{ "session_id": "550e8400-e29b-41d4-a716-446655440003" }

Payments

POST /api/v1/payments/create-intent

Create a Stripe PaymentIntent for an order. Uses the store's Stripe Connect account.

Request Body

{ "order_id": "550e8400-e29b-41d4-a716-446655440004" }

Response

{
  "client_secret": "pi_xxx_secret_xxx",
  "payment_intent_id": "pi_xxx",
  "amount": 3998,
  "currency": "usd"
}

Webhooks

Stripe Webhook

POST /webhook/stripe

Receives Stripe webhook events. Handles payment_intent.succeeded and payment_intent.payment_failed.

Verification: Webhook signatures are verified using PLATFORM_STRIPE_WEBHOOK_SECRET.

Order Sync Webhook (to app.buildmyonlinestore.com)

When an order is paid, we POST to the store's webhook_url:

POST {store.webhook_url}
Content-Type: application/json
X-Webhook-Source: checkout.best

{
  "event": "order.paid",
  "order_id": "550e8400-e29b-41d4-a716-446655440004",
  "store_id": "550e8400-e29b-41d4-a716-446655440001",
  "total_cents": 3998,
  "currency": "usd",
  "customer_email": "customer@example.com",
  "items": [
    {
      "sku": "PROD-001",
      "name": "Product Name",
      "quantity": 2,
      "price_cents": 1999,
      "catalog_id": "cat_001",
      "catalog_owner_id": "user_xyz",
      "product_cost_cents": 1200
    }
  ],
  "shipping_address": { ... },
  "source": "chatgpt",
  "conversation_id": "conv_abc123",
  "created_at": "2025-11-25T12:30:00Z"
}

Webhook Item Fields

FieldDescription
catalog_idCatalog ID for multi-catalog order attribution
catalog_owner_idOwner of the catalog (for payout calculations)
product_cost_centsWholesale cost for margin/profit calculation

Webhook Metadata Fields

FieldDescription
sourcePurchase source (direct, widget, chatgpt, acp, etc.)
conversation_idAI conversation ID for attribution (ACP purchases)

Error Handling

All errors return JSON with consistent format:

{
  "error": "Human-readable error message",
  "error_code": "MACHINE_READABLE_CODE"
}

Common Error Codes

CodeHTTP StatusDescription
VALIDATION_ERROR400Invalid request data
UNAUTHORIZED401Missing or invalid authentication
NOT_FOUND404Resource not found
RATE_LIMITED429Too many requests
INTERNAL_ERROR500Server error

Rate Limits

EndpointLimit
POST /api/v1/sessions10 requests per minute per IP
All other endpoints100 requests per minute per IP