BBetterLife APIBY THE GLITZ HUB
Developer reference · v2Sandbox supported
BetterLife / Developer Platform

One API.
Catalog to customer order.

WooCommerce products and Hiobuy marketplace discovery, with customer orders managed in your WordPress dashboard.

https://api.shoponbetterlifeapp.comExplore order handoff →
Reference25 primary endpoints

Current routes, legacy aliases, parameters and copyable examples.

China marketplaceHiobuy sandbox

Mock discovery works with test keys. Live data requires approved marketplace authorization.

Customer ordersWordPress dashboard

The order bridge sends customer order details to WooCommerce for manual purchasing.

Get started

Credentials stay on the server

Catalog access and paid-order submission use different authentication rules.

SettingPurposeUsage
API_KEYOptional BetterLife catalog protectionEmpty in the current setup. If configured, clients send Authorization: Bearer or X-API-Key.
HIOBUY_API_KEYSupplier accesshio_test_… for mock data; hio_live_… for production. Store only in server .env.
WOOCOMMERCE_CONSUMER_KEY + WOOCOMMERCE_CONSUMER_SECRETWordPress accessRead permission for live categories/variations; read/write permission for orders.
ORDER_BRIDGE_KEYPaid-order backend credentialSend as X-Order-Bridge-Key from a trusted backend. Never embed in browser/mobile code.

Hiobuy production keys require per-marketplace authorization. Sandbox keys skip that requirement and return mock responses. The app’s optional BetterLife key is separate from all provider credentials.

Hiobuy’s commercial requirements expect purchases through its procurement API. Obtain approval for your manual purchasing workflow before enabling production catalog access.

Hiobuy authentication ↗ · Production access requirements ↗

Your order workflow

When does an order appear in WordPress?

When your trusted payment backend submits the confirmed order to the bridge.

01 / CHECKOUT
Customer chooses itemsNative or supplier products, with selected size/color and quantity.
02 / WALLET
Backend confirms paymentValidate the user, final selling total and successful wallet debit.
03 / HANDOFF
POST /api/v2/ordersCreate the WooCommerce order and record the confirmed payment reference.
04 / WORDPRESS
You purchase manuallyOpen WooCommerce → Orders and use supplier links and selected options.

The order bridge records customer details, line items, quantities, selected options, supplier links and wallet references. It checks WooCommerce’s calculated total before marking the order paid.

The API does not deduct wallet balances. Browsing and adding to cart do not create WordPress orders. Your existing checkout must connect to a trusted backend that calls this endpoint; frontend and wallet code are outside this project.

Order item fields

FieldMeaning
sourcewoocommerce or hiobuy.
name / quantity / totalProduct name, positive integer quantity, full line total as a decimal string. total already covers the quantity.
product_id / variation_idNative WooCommerce product ID and optional chosen variation ID.
supplier_product_id / supplier_urlRequired for Hiobuy items. Supplier URL is used for manual purchasing.
variant / image / channelOptional selected options, image URL and marketplace name; stored as visible order-item metadata.

Retries and recovery

Use the same external order reference, wallet transaction reference and unchanged body on retries. Completed retries return the saved WordPress order ID. An unknown create outcome requires reconciliation against WooCommerce before another create attempt. Keep the debit and order payload in your payment backend until delivery is resolved.

A Hiobuy sandbox key only changes supplier data. Order submission still writes to the configured WooCommerce store and may trigger emails or stock changes. Use a test WordPress store for valid order tests.
Endpoint reference

Health

Process checks for the current and legacy API.

GET/api/v2/healthAPI process healthPublic⌄

No request fields required.

Returns service, version, status and timestamp. This reports the Node process; it does not verify database, wallet or supplier availability.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/health'
GET/api/v1/healthLegacy API process healthPublic⌄

No request fields required.

Legacy health response without the version field.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/health'
Endpoint reference

WooCommerce catalog

Browse local products, fetch complete categories, and select native variations.

GET/api/v2/productsBrowse the local WooCommerce catalogCatalog · optional API key⌄
FieldWhereDetails
pageOptional queryPositive integer; defaults to 1.
per_pageOptional queryPage size; defaults to 20, maximum 100.
categoryOptional queryWooCommerce category ID.
orderbyOptional querydate, id, title, price or modified; defaults to date.
orderOptional queryasc or desc; defaults to desc.

Returns data plus meta.total, page, per_page and pages. Products are served from the local MySQL sync.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/products?page=1&per_page=20'
GET/api/v2/products/searchSearch the local catalogCatalog · optional API key⌄
FieldWhereDetails
qRequired querySearch text; search is accepted as an alias.
pageOptional queryPositive integer; defaults to 1.
per_pageOptional queryPage size; defaults to 20, maximum 100.
categoryOptional queryWooCommerce category ID.

Returns products ordered by relevance. Empty search text returns an empty list.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/products/search?q=shirt&page=1&per_page=20'
GET/api/v2/products/:idRead a local productCatalog · optional API key⌄
FieldWhereDetails
idRequired pathWooCommerce product ID.

Returns a single published product with images, categories and available raw attributes/variation references. Returns 404 when not found.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/products/123'
GET/api/v2/products/:id/variationsChoose native product sizes and colorsCatalog · optional API key⌄
FieldWhereDetails
idRequired pathPublished, visible WooCommerce parent product ID.
pageOptional queryPositive integer; defaults to 1.
per_pageOptional queryPage size; defaults to 20, maximum 100.

Fetches published variations directly from WooCommerce, including variation ID, attributes, selling price, stock and image. Use the chosen variation_id in the order item. Requires WooCommerce read credentials.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/products/123/variations?page=1&per_page=20'
GET/api/v2/categoriesLoad the complete category listCatalog · optional API key⌄

No request fields required.

Loads every WooCommerce category page, including empty categories. Each item includes id, name, slug, parent, description, image, count and product_count. Cached for 15 minutes. Counts come from WooCommerce; product listings still use the local database.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/categories'
GET/api/v2/products/latestRecent local updatesCatalog · optional API key⌄
FieldWhereDetails
pageOptional queryPositive integer; defaults to 1.
per_pageOptional queryPage size; defaults to 20, maximum 100.
categoryOptional queryWooCommerce category ID.

Sorts by local updated_at descending. This date reflects synchronization, not the original publication date. This v2 route does not currently use Redis response caching.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/products/latest?per_page=20'
GET/api/v2/products/featuredExisting product selectionCatalog · optional API key⌄
FieldWhereDetails
per_pageOptional queryDefaults to 20; maximum 100.
categoryOptional queryWooCommerce category ID.

Current behavior selects recently updated products on page 1. WooCommerce featured flags are not filtered by this implementation. This v2 route does not currently use Redis response caching.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/products/featured?per_page=20'
Endpoint reference

Hiobuy marketplace catalog

Search and inspect supplier products. The configured sandbox key returns mock marketplace data.

POST/api/v1/hiobuy/products/searchSearch marketplace productsCatalog · optional API key⌄
FieldWhereDetails
channelRequired JSON1688 or taobao.
keywordRequired JSONSearch term.
page / page_sizeOptional JSONDefaults to 1 / 20; Taobao maximum 20 per page, 1688 maximum 100.
languageOptional JSONDefaults to en.
category_idsOptional JSONComma-separated numeric 1688 category IDs; supported only with channel 1688.

Hiobuy returns items, total and pagination inside data. Use items[].id for product detail. Supplier prices retain their supplied currency.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/search' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "channel": "1688",
  "keyword": "shirt",
  "page": 1,
  "page_size": 20,
  "language": "en"
}'
POST/api/v1/hiobuy/products/detailRead product details and supplier variantsCatalog · optional API key⌄
FieldWhereDetails
channelRequired JSON1688, taobao or weidian.
id / product_id / url / mi_id / tao_passwordIdentifier requiredSupply a supported product identifier. Pass an opaque Taobao search ID as id, not product_id.
languageOptional JSONDefaults to en.

Product information is inside data.product, including available variants. Refresh Taobao IDs before checkout because they can rotate. Retain the supplier URL for manual purchasing.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/detail' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "channel": "1688",
  "id": "ID_FROM_SEARCH",
  "language": "en"
}'
POST/api/v1/hiobuy/products/parseLook up a pasted marketplace linkCatalog · optional API key⌄
FieldWhereDetails
urlRequired JSONHTTP(S) marketplace product link without embedded credentials.
channelOptional JSON1688, taobao or weidian; omit to let Hiobuy detect it.
languageOptional JSONDefaults to en.

Returns product details inside data.product. For Taobao share text use detail with tao_password instead.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/parse' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "url": "https://detail.1688.com/offer/554456348334.html",
  "language": "en"
}'
POST/api/v1/hiobuy/products/upload-imageUpload an image for reuseCatalog · optional API key⌄
FieldWhereDetails
channelRequired JSON1688 or taobao.
image_base64Image inputRequired for Taobao; also supported for 1688. Up to 4 MiB decoded. A supported image data-URL prefix is stripped.
image_urlAlternative JSON1688 only; a public HTTP(S) image URL.

Returns data.image_id for image search. Replace the example URL with an actual accessible image. Upload responses are not cached; JSON request limit is 6 MiB.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/upload-image' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "channel": "1688",
  "image_url": "https://example.com/product.jpg"
}'
POST/api/v1/hiobuy/products/search-by-imageFind products using an imageCatalog · optional API key⌄
FieldWhereDetails
channelRequired JSON1688 or taobao.
image_id / image_base64 / image_urlImage input requiredReuse an uploaded image ID or provide image data.
image_addressAlternative JSONExisting image URL for 1688 only.
page / page_sizeOptional JSONDefaults to 1 / 20; same limits as keyword search.
language / keyword / regionOptional JSONLanguage defaults to en; keyword refines results; region is a crop-box string.

Returns the standard Hiobuy product list inside data.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/search-by-image' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "channel": "1688",
  "image_id": "ID_FROM_UPLOAD",
  "page": 1,
  "page_size": 20,
  "language": "en"
}'
POST/api/v1/hiobuy/products/top-listBrowse a 1688 category rankingCatalog · optional API key⌄
FieldWhereDetails
channelRequired JSON1688 only.
rank_idRequired JSONRanking/category ID.
rank_typeRequired JSONRanking type, for example hot, complex or goodPrice.
limitOptional JSONDefaults to 10; range 1–20.
languageOptional JSONDefaults to en.

Returns Hiobuy ranking data inside data. Ranked item field names can differ from keyword search; adapt the frontend parser.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/top-list' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "channel": "1688",
  "rank_id": "10165",
  "rank_type": "hot",
  "limit": 10,
  "language": "en"
}'
GET/api/v1/hiobuy/products/channelsCheck marketplace capabilitiesCatalog · optional API key⌄

No request fields required.

Returns the capability information provided by Hiobuy for the configured app/key. Available capabilities and sandbox fixtures depend on the provider.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/products/channels'
GET/api/v1/hiobuy/categoriesBrowse the official 1688 category treeCatalog · optional API key⌄
FieldWhereDetails
parent_idOptional queryOmit for the full tree; use 0 for root nodes without children; another ID returns its direct children.

Category nodes contain id, name and optional cn/children. Uses the official public category JSON, cached for one day. This is separate from WooCommerce categories.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/hiobuy/categories?parent_id=0'
Endpoint reference

Existing China app URLs

Keep the GET URLs already used by your app; their provider is now Hiobuy.

GET/api/v1/china/products/searchExisting app search URLCatalog · optional API key⌄
FieldWhereDetails
keywordRequired queryq is also accepted.
platformOptional queryDefaults to taobao; channel is an alias. Search supports taobao and 1688.
page / sizeOptional queryDefaults to 1 / 20; page_size is an alias; Taobao maximum 20.
langOptional queryDefaults to en; language is an alias.
category_idsOptional queryComma-separated IDs for 1688 only.

This URL now calls Hiobuy. The outer success/cached/data wrapper is retained; product data and IDs use the Hiobuy format.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/china/products/search?keyword=shirt&platform=1688&size=20'
GET/api/v1/china/products/:idExisting app product detail URLCatalog · optional API key⌄
FieldWhereDetails
idRequired pathURL-encoded Hiobuy product ID.
platformOptional queryDefaults to taobao; supports taobao, 1688 and weidian. channel is an alias.
langOptional queryDefaults to en; language is an alias.

Supply the same marketplace used for the search. Former supplier IDs are not interchangeable with Hiobuy IDs.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v1/china/products/ID_FROM_SEARCH?platform=1688'
Endpoint reference

WordPress customer orders

Every route in this section requires the server-only order bridge credential.

POST/api/v2/ordersSend a confirmed wallet order to WordPressTrusted backend only⌄
FieldWhereDetails
external_order_idRequired JSONUnique app order reference; preserve across retries.
wallet_transaction_idRequired JSONUnique confirmed wallet transaction reference; cannot fund another order.
paid_amount / currencyRequired JSONPositive decimal string and uppercase currency code, for example 25000.00 / NGN.
billing / shippingRequired JSONObjects with first_name, address_1, city and uppercase two-letter country; contact details and other address fields are optional.
itemsRequired JSON1–100 items; see the full example and item field table below.
shipping_totalOptional JSONNon-negative decimal string for delivery cost.
customer_idOptional JSONPositive WooCommerce user ID; omit for a guest order.
customer_noteOptional JSONCustomer note, up to 2,000 characters.

Creates a pending WooCommerce order, compares its calculated total and currency with the confirmed wallet amount, then records payment. First success returns HTTP 201 and order_id; an identical completed retry returns HTTP 200 with duplicate: true. WooCommerce tax/plugin settings can change the final total.

This example creates a real order in the configured WordPress store. A Hiobuy sandbox key does not make WooCommerce a sandbox. Use a test store for this request.
cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/orders' \
  -X POST -H 'Content-Type: application/json' \
  -H 'X-Order-Bridge-Key: <SERVER_ONLY_KEY>' \
  --data '{
  "external_order_id": "app-order-1001",
  "wallet_transaction_id": "wallet-txn-1001",
  "paid_amount": "25000.00",
  "currency": "NGN",
  "billing": {
    "first_name": "Ada",
    "last_name": "Example",
    "address_1": "1 Example Road",
    "city": "Lagos",
    "country": "NG",
    "email": "customer@example.com"
  },
  "shipping": {
    "first_name": "Ada",
    "last_name": "Example",
    "address_1": "1 Example Road",
    "city": "Lagos",
    "country": "NG"
  },
  "items": [
    {
      "source": "hiobuy",
      "supplier_product_id": "ID_FROM_HIOBUY",
      "supplier_url": "https://detail.1688.com/offer/554456348334.html",
      "name": "Blue shirt",
      "quantity": 2,
      "total": "24000.00",
      "variant": "Blue / L",
      "channel": "1688",
      "image": "https://example.com/shirt.jpg"
    }
  ],
  "shipping_total": "1000.00"
}'
GET/api/v2/ordersList a customer’s WordPress ordersTrusted backend only⌄
FieldWhereDetails
customer_idRequired queryPositive WooCommerce customer ID; the trusted backend must verify ownership.
page / per_pageOptional queryDefaults to 1 / 20; maximum 100 per page.
statusOptional querypending, processing, on-hold, completed, cancelled, refunded or failed.

Returns data and pagination meta. Guest orders can be retrieved using a known app reference or WordPress order ID through the trusted backend.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/orders?customer_id=123&page=1&per_page=20' \
  -H 'X-Order-Bridge-Key: <SERVER_ONLY_KEY>'
GET/api/v2/orders/:idRead current order details and statusTrusted backend only⌄
FieldWhereDetails
idRequired pathPositive WooCommerce order ID.

Returns customer addresses, payment reference, current status and items with selected supplier metadata. Internal order keys and unrelated plugin metadata are excluded. The trusted backend must verify customer ownership.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/orders/123' \
  -H 'X-Order-Bridge-Key: <SERVER_ONLY_KEY>'
GET/api/v2/orders/by-reference/:external_order_idCheck delivery of an app orderTrusted backend only⌄
FieldWhereDetails
external_order_idRequired pathApp reference previously submitted to the bridge.

Returns external_order_id, delivery_state and the current linked WordPress order. If delivery is uncertain and no WordPress ID is recorded, order is null and reconciliation is required. Returns 404 for an unknown reference.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/v2/orders/by-reference/app-order-1001' \
  -H 'X-Order-Bridge-Key: <SERVER_ONLY_KEY>'
Endpoint reference

Catalog administration

Administrative sync tools. These routes should be restricted to your server or trusted operators.

GET/api/admin/sync/statusInspect catalog synchronizationServer / admin⌄

No request fields required.

Returns persistent WooCommerce sync state from MySQL. Use from server/admin tools.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/admin/sync/status'
POST/api/admin/sync/woocommerceTrigger a catalog syncServer / admin⌄
FieldWhereDetails
max_pagesOptional JSONPositive integer page limit; omitted runs a full sync.

Runs the sync inside the HTTP request. For large catalogs, use node scripts/sync-woocommerce.js through CLI/cron. Restrict these admin routes at the proxy/network layer; they currently share optional API_KEY authentication with catalog routes.

cURL
curl -sS 'https://api.shoponbetterlifeapp.com/api/admin/sync/woocommerce' \
  -X POST -H 'Content-Type: application/json' \
  --data '{
  "max_pages": 2
}'
Compatibility

Existing app URLs remain available

Use the same method and request shape unless the alias notes otherwise.

Current endpointAlias
/api/v2/products/api/v1/shop/products
/api/v2/products/search/api/v1/shop/search
/api/v2/products/:id/api/v1/shop/products/:id
/api/v2/products/:id/variations/api/v1/shop/products/:id/variations
/api/v2/products/latest/api/v1/shop/products/latest
/api/v2/products/featured/api/v1/shop/products/featured
/api/v2/categories/api/v1/shop/categories
/api/v1/hiobuy/*/api/v1/china/* (same methods and bodies)

GET China routes accept platform/size/lang as aliases for channel/page_size/language. Their payloads now contain Hiobuy data. Old supplier IDs must be refreshed through Hiobuy.

Integration contract

Response shapes and errors

Inspect HTTP status, success, code and upstream_code where present.

Catalog response

JSON
{
  "success": true,
  "cached": false,
  "data": {
    "channel": "1688",
    "items": [],
    "total": 0,
    "page": 1,
    "page_size": 20
  }
}

Hiobuy fields are nested inside data. Native WooCommerce lists return a data array and a separate meta object. Some v2 selection routes omit cached. Hiobuy selling prices are returned in NGN at ₦220/CNY plus 70% markup by default. Use selling_price.amount/currency or price.display_amount/display_currency. The supplier originals remain in CNY. Edit CNY_NGN_RATE and HIOBUY_MARKUP_PERCENT in .env, then restart the API.

Order submission response

JSON
{
  "success": true,
  "data": {
    "duplicate": false,
    "order_id": 123,
    "status": "processing",
    "total": "25000.00",
    "currency": "NGN"
  }
}

WooCommerce controls the resulting status. Order retrieval returns current WordPress information; an identical completed submission retry returns the saved delivery result.

Supplier authentication error

JSON
{
  "success": false,
  "error": "Hiobuy request failed (401)",
  "code": "UPSTREAM_ERROR",
  "upstream_code": "CHANNEL_NOT_AUTHORIZED",
  "request_id": "req_example"
}

INVALID_API_KEY identifies a rejected key. CHANNEL_NOT_AUTHORIZED identifies missing marketplace authorization. Preserve request_id when contacting provider support.

HTTPCodeAction / meaning
400INVALID_REQUESTCheck required fields, marketplace, pagination or image input.
401UnauthorizedMissing/wrong bridge key, or optional BetterLife API key when configured.
404CATEGORY_NOT_FOUND / ORDER_NOT_FOUND / PRODUCT_NOT_FOUNDResource is unavailable. Local product 404 responses may omit a code.
409ORDER_CONFLICT / PAYMENT_ALREADY_USED / ORDER_BUSYReused reference with changed details, reused wallet transaction, or submission in progress.
409PAYMENT_TOTAL_MISMATCH / PAYMENT_CONFLICTWordPress total/currency differs from payment, or payment reference conflicts. Review the payment and order.
409ORDER_REQUIRES_REVIEWUnknown delivery outcome or cancelled/refunded/failed order. Reconcile before retrying.
429UPSTREAM_ERRORSupplier rejected the request due to rate/quota limits. Inspect upstream_code.
502UPSTREAM_ERROR / INVALID_UPSTREAM_RESPONSESupplier/WordPress rejected a request or returned invalid data.
502PAYMENT_NOT_RECORDEDWooCommerce has not confirmed the payment; review or retry the unchanged submission.
502 / 504UPSTREAM_UNAVAILABLEConnection failure or timeout. Avoid blindly repeating uncertain order creation.
503NOT_CONFIGUREDRequired supplier, WordPress or order-bridge credentials are missing.
Implementation

Connect each call to the right layer

Discovery belongs in the app. Confirmed payments and private order access belong in your trusted backend.

Frontend: render Hiobuy search cards

JavaScript · frontend
const API_BASE = 'https://api.shoponbetterlifeapp.com';

async function searchChinaProducts(keyword) {
  const query = new URLSearchParams({
    keyword, platform: '1688', size: '20', lang: 'en'
  });
  const response = await fetch(`${API_BASE}/api/v1/china/products/search?${query}`);
  const result = await response.json();
  if (!response.ok || !result.success) throw new Error(result.error || 'Search failed');
  return (result.data.items || []).map(product => ({
    id: product.id,
    name: product.title?.translated || product.title?.original || '',
    image: product.image,
    supplierUrl: product.source_url,
    price: product.selling_price?.amount,
    currency: product.selling_price?.currency,
    supplierAmount: product.price?.original_amount,
    supplierCurrency: product.price?.original_currency
  }));
}

Display price and currency to customers. Supplier values remain available for purchasing. Load product detail to select data.product.variants; each variant has its own selling_price. The trusted wallet backend must calculate final totals from the selected SKU, quantity, shipping and tax.

Backend: deliver the confirmed order

JavaScript · trusted backend
// Trusted backend only, after validating the user and wallet debit.
// confirmedOrder contains the documented order payload and final selling totals.
const response = await fetch(`${process.env.BETTERLIFE_API_URL}/api/v2/orders`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Order-Bridge-Key': process.env.ORDER_BRIDGE_KEY
  },
  body: JSON.stringify(confirmedOrder)
});
const result = await response.json();
if (!response.ok || !result.success) {
  // Retain the debit + order reference and handle retry/reconciliation.
  throw new Error(result.code || result.error);
}
const wordpressOrderId = result.data.order_id;

BETTERLIFE_API_URL is a setting in your calling backend. Keep the bridge secret there and on the API server. The backend must enforce customer ownership for every order read.

Operations

Deploy and verify through SSH

Back up the live files and database, then preserve your production .env during updates.

  1. Upload the endpoint bundle into /www/wwwroot/api.shoponbetterlifeapp.com/.
  2. Import database/migrations/001_order_submissions.sql into the existing API database once, if not already done. Do not reimport the catalog schema.
  3. Keep valid WooCommerce credentials, a Hiobuy test key and a server-only order bridge key.
  4. Run the checks and restart the systemd service.
SSH
cd /www/wwwroot/api.shoponbetterlifeapp.com/
node --test tests/*.test.js
systemctl restart betterlife-api.service

Wait until Node is listening, then run:

SSH · live smoke check
node scripts/test-api.js

The smoke check reads health, categories and supplier data. Its empty order payload verifies authentication/validation without creating an order or deducting wallet money. It does not verify WordPress write permission or actual checkout delivery.

For a real order test, use a test WooCommerce store and the documented POST order payload, then inspect WooCommerce → Orders. Retry the same payload and confirm that the order ID stays the same.