Bỏ qua tới nội dung

Tích hợp

Kết nối POS, vận chuyển, thanh toán: gọi action của adapter. · 9 endpoint

Danh sách tích hợp đã cấu hình

GET/api/v1/integrationsScope: integrations:read

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/integrations" \
  -H "Authorization: Bearer dpk_xxx"

Thêm tích hợp (credential được mã hoá, không bao giờ trả ra)

POST/api/v1/integrationsScope: integrations:manage

Body (JSON)

type
bắt buộc
"kiotviet" | "haravan" | "sapo" | "nhanh" | "pancake" | "casso" | "sepay" | "ghn" | "ghtk" | "telegram_bot"Xem GET /integrations/types
name
tuỳ chọn
string
max 100
Bỏ trống = tên loại tích hợp
enabled
tuỳ chọn
boolean
default true
credentials
bắt buộc
objectKhoá theo GET /integrations/types
settings
tuỳ chọn
object

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/integrations" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"type":"ghn","credentials":{"token":"ghn_xxx","shopId":"123456"},"settings":{"environment":"production"}}'

Một tích hợp (không có credential)

GET/api/v1/integrations/{integrationId}Scope: integrations:read

Tham số

integrationId
path · bắt buộc
string
max 200

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/integrations/{integrationId}" \
  -H "Authorization: Bearer dpk_xxx"

Sửa tích hợp: tên, cài đặt, credential (bỏ trống = giữ cũ), bật/tắt

PATCH/api/v1/integrations/{integrationId}Scope: integrations:manage

Tham số

integrationId
path · bắt buộc
string
max 200

Body (JSON)

name
tuỳ chọn
string
max 100
enabled
tuỳ chọn
boolean
credentials
tuỳ chọn
object
settings
tuỳ chọn
object

Lệnh mẫu

bash
curl -X PATCH "http://127.0.0.1:9900/api/v1/integrations/{integrationId}" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","enabled":false,"credentials":{}}'

Xoá tích hợp (workflow dùng tích hợp này sẽ báo lỗi khi chạy)

DELETE/api/v1/integrations/{integrationId}Scope: integrations:manage

Tham số

integrationId
path · bắt buộc
string
max 200

Lệnh mẫu

bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/integrations/{integrationId}" \
  -H "Authorization: Bearer dpk_xxx"

Gọi một action của adapter (vd: lookupOrder, createOrder, getTracking)

POST/api/v1/integrations/{integrationId}/actions/{action}Scope: integrations:execute

Tên action và tham số giống node workflow tương ứng (vd. node nhanh.lookupOrder ↔ action lookupOrder).

Tham số

integrationId
path · bắt buộc
string
max 200
action
path · bắt buộc
string
max 100

Body (JSON)

params
tuỳ chọn
object
default {}

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/integrations/{integrationId}/actions/{action}" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"params":{"orderId":"DH2291"}}'

Loại tích hợp hỗ trợ và các khoá credential / cài đặt cần nhập

GET/api/v1/integrations/typesScope: integrations:read

Lệnh mẫu

bash
curl "http://127.0.0.1:9900/api/v1/integrations/types" \
  -H "Authorization: Bearer dpk_xxx"

Gọi action theo loại tích hợp (dùng tích hợp đang bật của loại đó)

POST/api/v1/integrations/by-type/{type}/actions/{action}Scope: integrations:execute

Tiện khi chỉ có một tích hợp mỗi loại, như node workflow (vd. ghn + getTracking).

Tham số

type
path · bắt buộc
"kiotviet" | "haravan" | "sapo" | "nhanh" | "pancake" | "casso" | "sepay" | "ghn" | "ghtk" | "telegram_bot"
action
path · bắt buộc
string
max 100

Body (JSON)

params
tuỳ chọn
object
default {}

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/integrations/by-type/{type}/actions/{action}" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"params":{}}'

Kiểm tra kết nối của tích hợp

POST/api/v1/integrations/{integrationId}/testScope: integrations:execute

Tham số

integrationId
path · bắt buộc
string
max 200

Lệnh mẫu

bash
curl -X POST "http://127.0.0.1:9900/api/v1/integrations/{integrationId}/test" \
  -H "Authorization: Bearer dpk_xxx"