API thiết lập webhook

Dùng để thiết lập webhook như: thêm, sửa và xóa.

Trước khi bắt đầu

Một số lưu ý trước khi bắt đầu với các API liên quan tới webhook:

  • Một tài khoản Casso đã liên kết một tài khoản ngân hàng. Để test với API này có thể sử dụng tài khoản demo.

  • Bạn cần có một endpoint/API để nhận sự kiện từ Casso đây được gọi là Webhook.

  • Endpoint/API này phải public ra ngoài Internet. Nếu như bạn đang ở local bạn có thể xem hương dẫn này để biết cách public endpoint của bạn.

  • Bạn cần có API Key để thiết lập ở trường Authorization HTTP Header.

Tạo webhook

POST https://oauth.casso.vn/v2/webhooks

Thực hiện tạo webhook tới server của bạn

Headers

NameTypeDescription

Authorization

string

Bearer <"access token từ OAuth2"> hoặc Apikey <"API key của bạn">

Request Body

NameTypeDescription

income_only

boolean

Giá trị được thiết lập để gửi bắn sự kiện tới webhook đối với giao dịch tiền vào

secure_token

string

Mã bảo mật để mỗi lần gửi Event từ Casso sẽ được đính kèm trên header.

webhook

string

Đường dẫn(endpoint/API) nhận event(phát sinh giao dịch mới) từ Casso

{
    "error": 0,
    "message": "success",
    "data": {
        "id": 114,
        "channel": "webhook",
        "param1": "https://ten-mien-cua-ban.com/wc/handler-bank-transfer.php",
        "param2": "",
        "send_only_income": 1
    }
}

Ví dụ:

curl --location --request POST 'https://oauth.casso.vn/v2/webhooks' \
--header 'Authorization: Apikey <API Key của bạn> hoặc Bearer <access token từ OAuth2>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "webhook": "https://ten-mien-cua-ban.com/wc/handler-bank-transfer.php",
    "secure_token": "@123#abc",
    "income_only": true
}'

Xem chi tiết webhook

GET https://oauth.casso.vn/v2/webhooks/:id

Xem chi tiết các thông về webhook của bạn theo dựa theo webhook Id

Path Parameters

NameTypeDescription

id

string

id webhook bạn muốn xem chi tiết

Headers

NameTypeDescription

Authorization

string

Bearer <"access token từ Oauth2"> hoặc Apikey <"API key của bạn">

{
    "error": 0,
    "message": "success",
    "data": {
        "id": 111,
        "channel": "webhook",
        "param1": "https://ten-mien-cua-ban.com.vn/wc/handler-bank-transfer.php",
        "param2": "",
        "send_only_income": 1
    }
}

Ví dụ:

curl --location --request GET 'https://oauth.casso.vn/v2/webhooks/134' \
--header 'Authorization: Bearer <"Access token nhận được từ OAuth 2.0 của Casso">'

Cập nhật một webhook

PUT https://oauth.casso.vn/v2/webhooks/:id

Cập nhật các thông tin trong webhook đã được thiết lập trước đó

Path Parameters

NameTypeDescription

id

string

id webhook

Headers

NameTypeDescription

Authorization

string

Bearer <"access token từ OAuth2"> hoặc Apikey <"API key của bạn">

Request Body

NameTypeDescription

income_only

boolean

Xác nhận gửi webhook đối với tiền vào

secure_token

string

mã bảo mật

webhook

string

Đường dẫn(endpoint/API) nhận event(phát sinh giao dịch mới) từ Casso

{
    "error": 0,
    "message": "success",
    "data": {
        "id": 111,
        "channel": "webhook",
        "param1": "https://webhook-cua-ban.com.vn",
        "param2": "sdf",
        "send_only_income": 1
    }
}

Ví dụ:

curl --location --request PUT 'https://oauth.casso.vn/v2/webhooks/111' \
--header 'Authorization: Apikey <API Key của bạn> Hoặc Bearer <access token từ OAuth2>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "webhook": "https://ten-mien-cua-ban.com/api/bank",
    "secure_token": "@xyz@123",
    "income_only": "false"
}'

Xoá một webhook

DELETE https://oauth.casso.vn/v2/webhooks/:id

Thực hiện xóa một webhook bằng id webhook

Path Parameters

NameTypeDescription

id

string

id webhook

Headers

NameTypeDescription

Authorization

string

Bearer <"access token từ OAuth2"> hoặc Apikey <"API key của bạn">

{
    "error": 0,
    "message": "success",
    "data": {
        "id": 111,
        "channel": "webhook",
        "param1": "https://khanh-dep-trai.com.vn",
        "param2": "sdf",
        "send_only_income": 1
    }
}

Ví dụ:

curl --location --request DELETE 'https://oauth.casso.vn/v2/webhooks/85' \
--header 'Authorization: Bearer <"Access token nhận được từ OAuth 2.0 của Casso">'

Xoá tất cả webhook trong đường dẫn

DELETE https://oauth.casso.vn/v2/webhooks

Xóa tất cả các webhook đang tồn tại trong doanh nghiệp của bạn trên Casso tương ứng với giá trị webhook mà bạn yêu cầu.

Query Parameters

NameTypeDescription

webhook

string

Đường dẫn(endpoint/API) nhận event(phát sinh giao dịch mới) từ Casso

Headers

NameTypeDescription

Authorization

string

Bearer <"access token từ OAuth2"> hoặc Apikey <"API key của bạn">

{
    "error": 0,
    "message": "success",
    "data": [
        {
            "id": 108,
            "channel": "webhook",
            "param1": "https://ten-mien-cua-ban.com/wc/handler.php",
            "param2": "",
            "send_only_income": 1
        },
        {
            "id": 109,
            "channel": "webhook",
            "param1": "https://ten-mien-cua-ban.com/wc/handler.php",
            "param2": "",
            "send_only_income": 1
        },
        {
            "id": 110,
            "channel": "webhook",
            "param1": "https://ten-mien-cua-ban.com/wc/handler.php",
            "param2": "",
            "send_only_income": 1
        },
    ]
}

Ví dụ:

curl --location --request DELETE 'https://oauth.casso.vn/v2/webhooks?webhook=https://websitecuaban.com/api/webhook' \
--header 'Authorization: Bearer <"Access token nhận được từ OAuth 2.0 của Casso">'

Lưu ý: Khi bạn gọi API có thể sẽ xóa đi những webhook cũ mà bạn đã thiết lập trên hệ thống của Casso. Cân nhắc trước khi dùng tới API này.

Last updated