Branch #18 docs/api/18-commerce-license-hub.md

20. Commerce + License Hub

Branch #18 — Thanh toán gói và cấp entitlement tự động cho client plugin.

Endpoints

GET
https://bizgpt.vn/wp-json/bizcity-commerce/v1/packages

Danh sách gói thương mại

Auth: Bearer

POST
https://bizgpt.vn/wp-json/bizcity-commerce/v1/checkout

Tạo checkout

Auth: Bearer

GET
https://bizgpt.vn/wp-json/bizcity-commerce/v1/orders/{id}

Chi tiết đơn hàng

Auth: Bearer

PATCH
https://bizgpt.vn/wp-json/bizcity-license/v1/entitlement

Cập nhật quyền truy cập

Auth: Bearer

POST
https://bizgpt.vn/wp-json/bizcity-license/v1/webhook/woo-order-paid

Đồng bộ từ WooCommerce

Auth: Signed webhook

Method Path Auth Mô tả
GET https://bizgpt.vn/wp-json/bizcity-commerce/v1/packages Bearer Danh sách gói thương mại
POST https://bizgpt.vn/wp-json/bizcity-commerce/v1/checkout Bearer Tạo checkout
GET https://bizgpt.vn/wp-json/bizcity-commerce/v1/orders/{id} Bearer Chi tiết đơn hàng
PATCH https://bizgpt.vn/wp-json/bizcity-license/v1/entitlement Bearer Cập nhật quyền truy cập
POST https://bizgpt.vn/wp-json/bizcity-license/v1/webhook/woo-order-paid Signed webhook Đồng bộ từ WooCommerce

Query Examples

GET Danh sách gói thương mại
curl -X GET "https://bizgpt.vn/wp-json/bizcity-commerce/v1/packages" -H "Authorization: Bearer biz-YOUR_KEY"
const res = await fetch('https://bizgpt.vn/wp-json/bizcity-commerce/v1/packages', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
  },
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity-commerce/v1/packages"
headers = {'Authorization': 'Bearer biz-YOUR_KEY'}
res = requests.get(url, headers=headers)
print(res.json())
POST Tạo checkout
curl -X POST "https://bizgpt.vn/wp-json/bizcity-commerce/v1/checkout" -H "Authorization: Bearer biz-YOUR_KEY" -H "Content-Type: application/json" -d '{"package_id":"master_pro","site_url":"https://client-site.com"}'
const res = await fetch('https://bizgpt.vn/wp-json/bizcity-commerce/v1/checkout', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"package_id":"master_pro","site_url":"https://client-site.com"}),
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity-commerce/v1/checkout"
headers = {'Authorization': 'Bearer biz-YOUR_KEY', 'Content-Type': 'application/json'}
payload = '{"package_id":"master_pro","site_url":"https://client-site.com"}'
res = requests.request("POST", url, headers=headers, data=payload)
print(res.json())
GET Chi tiết đơn hàng
curl -X GET "https://bizgpt.vn/wp-json/bizcity-commerce/v1/orders/{id}" -H "Authorization: Bearer biz-YOUR_KEY"
const res = await fetch('https://bizgpt.vn/wp-json/bizcity-commerce/v1/orders/{id}', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
  },
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity-commerce/v1/orders/{id}"
headers = {'Authorization': 'Bearer biz-YOUR_KEY'}
res = requests.get(url, headers=headers)
print(res.json())
PATCH Cập nhật quyền truy cập
curl -X PATCH "https://bizgpt.vn/wp-json/bizcity-license/v1/entitlement" -H "Authorization: Bearer biz-YOUR_KEY" -H "Content-Type: application/json" -d '{"sample":true}'
const res = await fetch('https://bizgpt.vn/wp-json/bizcity-license/v1/entitlement', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"sample":true}),
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity-license/v1/entitlement"
headers = {'Authorization': 'Bearer biz-YOUR_KEY', 'Content-Type': 'application/json'}
payload = '{"sample":true}'
res = requests.request("PATCH", url, headers=headers, data=payload)
print(res.json())
POST Đồng bộ từ WooCommerce
curl -X POST "https://bizgpt.vn/wp-json/bizcity-license/v1/webhook/woo-order-paid" -H "Content-Type: application/json" -d '{"sample":true}'
const res = await fetch('https://bizgpt.vn/wp-json/bizcity-license/v1/webhook/woo-order-paid', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"sample":true}),
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity-license/v1/webhook/woo-order-paid"
headers = {'Content-Type': 'application/json'}
payload = '{"sample":true}'
res = requests.request("POST", url, headers=headers, data=payload)
print(res.json())

Use Cases

  • Bật/tắt tính năng theo trạng thái mua gói thực tế.
  • Đồng bộ license cho nhiều plugin/module liên quan.
  • Hợp nhất commerce + entitlement thành luồng tự động.

Implementation Steps

  1. Lấy package list để hiển thị trang giá.
  2. Tạo checkout và theo dõi trạng thái thanh toán.
  3. Nhận webhook và cập nhật entitlement về client.

Quick Start cURL

bash
curl -X GET https://bizgpt.vn/wp-json/bizcity-commerce/v1/packages -H "Authorization: Bearer biz-YOUR_KEY"
Canonical Spec

docs/api/18-commerce-license-hub.md

Notes for Public Deployment
  • Nên log đầy đủ webhook verification để audit license.