Integrating with Dujiao-Next
About 1116 words
When Dujiao-Next (dujiao-next) connects to xstock as a downstream storefront, it works through its own "upstream integration" protocol: you enter a root address and Key/Secret in a connection, and the admin panel purchases through APIs such as ping, products, and orders. The xstock adapter layer is responsible for translating these into the platform's standard commands, so you do not need to write any code specifically for Dujiao-Next — just fill in its admin panel form.
Version note
This article is based on the integration protocol of dujiao-next v1.6.1. The adapter layer is still in integration testing, and fields are subject to what both sides actually verify.
Check downstream support first
For the full support scope, integration steps, and capability boundaries, see Downstream Support → Dujiao-Next Admin Integration; this page is a field-level mapping, useful for cross-checking during integration testing.
Connection configuration
In the Dujiao-Next admin panel, go to "Integration Management → Connection Management" and create a new connection:
| Form field | What to enter |
|---|---|
| Name | Any name, for example "xstock" |
| Root address | The integration address issued by xstock (the adapter layer appends the protocol path) |
| API Key / Secret | The store credentials shown in "Store Details" in the portal |
| Protocol | dujiao-next |
| Callback URL | The public address where your storefront receives callbacks |
| Retry / markup / exchange rate | According to your operational settings |
After saving, click "Test Connection" to trigger a connectivity check.
API mapping
| Dujiao-Next call | xstock equivalent | Description |
|---|---|---|
POST /ping | ping | Connectivity and signature verification; returns site name, balance, currency, and tier |
GET /categories | get_categories | Category catalog (including hierarchy and product counts) |
GET /products | get_goods | Product list (including SKUs) |
GET /products/:id | No separate call needed | get_goods already returns full SKUs, which the adapter layer uses directly |
POST /orders | post_order | Single-line order; the adapter layer converts sku_id+quantity into one line |
GET /orders/:id | get_orders | Queries by upstream order number and returns the aggregated status |
POST /orders/:id/cancel | req_cancel | Cancellable before delivery |
| Upstream callbacks | Events such as order.fulfilled | The adapter layer converts them into Dujiao-Next callback bodies carrying the delivery content |
Identifier alignment
Dujiao-Next's product, SKU, and order fields are all auto-increment INTEGERs, so xstock uniformly returns numeric IDs externally, along with a stable, readable code:
| Dujiao-Next | xstock | Description |
|---|---|---|
category.id (int) | category_id (int64) | Root category has parent_id=0 |
category.slug | guid | The local Dujiao slug and the xstock guid live in different namespaces; map using the numeric ID or guid |
category.icon | thumb | Category image address (URL string) |
product.id (int) | goods_id (int64) | Written directly into upstream_product_id |
product.slug | guid | Product GUID string |
sku.id (int) | sku_id (int64) | Written directly into upstream_sku_id |
sku.sku_code | sku_code | DEFAULT for single-spec products; unique only within the same product |
| (cross-product identifier) | skus[].guid | A global string identifier for a SKU, unique across products, suitable for persistent mapping |
order_id (int) | order_id (int64) | Creation, query, cancellation, and callbacks all use the same number |
order_no | order_no | Business order number string, retained on both chains |
Numeric IDs are protocol aliases issued by the platform: they are never reused or rebound, and their values stay within the JavaScript safe integer range. The platform's internal GUID primary keys are not exposed externally.
Field mapping
Products and SKUs
| Dujiao-Next field | xstock field | Notes |
|---|---|---|
product.id | goods_id | Numeric identifier; can be stored directly in an INTEGER field |
product.slug | guid | Readable string identifier, used for display and mapping |
product.title | title | Multilingual object, mapped directly; downstream takes values by language tag |
product.category_id | category_id | Corresponds to the categories returned by get_categories |
product.fulfillment_type | fulfillment_type | auto/manual/service |
product.skus[].id | skus[].sku_id | Used for ordering |
product.skus[].sku_code | skus[].sku_code | Unique within the same product; DEFAULT for single-spec products |
product.skus[].spec_values | skus[].spec_values | Specification key-value pairs |
sku.price_amount | skus[].prices[] | Upstream is single-currency; we return a multi-currency array, so take the default price from the response default_ccy, or the matching currency by ccy |
sku.stock_status | skus[].stock_status | Identical enum |
sku.stock_quantity | skus[].stock_quantity | -1 means unlimited |
product.images | images | Array of image URLs; upstream must provide them |
product.tags | tags | Array of tags |
product.price_amount (products without SKUs) | prices[] | Product-level multi-currency prices; sold by these when skus is empty |
product.manual_form_schema | manual_deliver_schema | Manual delivery field definitions, in JSON Schema form |
Ordering
| Dujiao-Next field | xstock field | Notes |
|---|---|---|
sku_id | items[0].sku_id | Single-line order |
quantity | items[0].qty | Quantity as a string |
manual_form_data | items[0].input | Required for manual products |
downstream_order_no | req_id | Idempotency key; retries of the same order must use the same value |
trace_id | Recorded by the adapter layer | Does not enter business fields |
callback_url | The callback URL configured on the store | Governed by the portal configuration; arbitrary values in the request body are not allowed |
Orders and callbacks
| Dujiao-Next field | xstock field |
|---|---|
order_id / order_no | order_id (numeric) / order_no (string) |
amount / currency | total.amt / total.ccy |
status | status (aggregated status) |
items[] | lines[] |
fulfillment.payload | delivers[].content of get_orders |
fulfillment.delivery_data | Structured delivery (account fields) |
downstream_order_no | req_id (returned verbatim in callbacks) |
Status mapping
xstock status | Dujiao-Next handling |
|---|---|
paid | Paid, awaiting delivery |
fulfilling | Fulfilling |
delivered / completed | Delivered, triggers local delivery |
canceled | Canceled |
xstock also returns three dimension-specific states, accept_state, fulfill_state, and fund_state; the adapter layer presents the aggregated status externally while keeping the details in the raw response.
Signing and protocol differences
| Item | Dujiao-Next | xstock |
|---|---|---|
| Path | /api/v1/upstream/* | /dist/api/v1/{cmd} |
| Auth headers | Dujiao-Next-* | X-Xstock-* |
| Signature string | METHOD\nPATH\nTIMESTAMP\nMD5(BODY) | timestamp\ncmd\nSHA256(body or query) |
| Response | {ok, ...} | jcmd envelope (code=0 for success) |
The xstock-side Dujiao-Next adapter layer converts these differences, so the storefront always sees the protocol it is familiar with.
Integration test order
- Create a store in the portal, get the Key/Secret, and configure the callback URL.
- Create a connection in the Dujiao-Next admin panel; "Test Connection" should return success and the balance.
- Pull the category catalog first, then the product list, establish the mappings, and enable them.
- Place a small test order and confirm the charge, delivery, and callback.
- Walk through cancellation and after-sales, confirming that statuses are reported back correctly.
Troubleshooting
| Symptom | Check first |
|---|---|
| Test connection fails (401) | Is the Key/Secret for the current store, and is the time offset over 300 seconds? |
| Products cannot be pulled | Has the store enabled catalog.read, and are the products is_active? |
| Order rejected for insufficient balance | Is the portal balance sufficient to hold the order amount? |
| No callback received | Has the callback URL passed validation, and does it return 2xx within 5 seconds? |
| Status not updated | Is processing idempotent by event_id, and is merging done by occurred_at? |