Tài liệu API V1, phiên bản cũ. Bản đang dùng là V3.
API thiết lập webhook
Thay vì thiết lập webhook thủ công thì nay Casso cung cấp endpoint để có thể thiết lập webhook tự động.
Tạo webhook
POST https://oauth.casso.vn/v1/webhooks
Thực hiện tạo webhook tới server của bạn
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | string | chứa Access-Token |
Request Body
| Name | Type | Description |
|---|---|---|
| income_only | boolean | là giá trị được thiết lập để có gửi webhook đối với tiền vào hay không |
| secure_token | string | mã bảo mật |
| webhook | string | đường dẫn tới api đầu nhận webhook server của bạn |
200 Response thông tin webhook đã tạo thành công.
{
"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
}
}
401 Access-Token không đúng hoặc đã hết hạn.
{
"error": 401,
"message": "Unauthorized Access",
"data": null
}
curl --location --request POST 'https://oauth.casso.vn/v1/webhooks' \
--header 'Authorization: Access token' \
--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
}'
Chi tiết
GET https://oauth.casso.vn/v1/webhooks/:id
Xem chi tiết các thông về webhook của bạn theo webhook Id
Path Parameters
| Name | Type | Description |
|---|---|---|
| id | string | id webhook bạn muốn xem chi tiết |
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | string | Access-Token |
200
{
"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
}
}
401
{
"error": 401,
"message": "Unauthorized Access",
"data": null
}
curl --location --request GET 'https://oauth.casso.vn/v1/webhooks/134' \
--header 'Authorization: Access-Token'
Cập nhật
PUT https://oauth.casso.vn/v1/webhooks/:id
Cập nhật các thông tin trong webhook đã được thiết lập trước đó
Path Parameters
| Name | Type | Description |
|---|---|---|
| id | string | id webhook |
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | string | access token |
Request Body
| Name | Type | Description |
|---|---|---|
| income_only | boolean | xác nhận gửi webhook tiền vào |
| secure_token | string | mã bảo mật |
| webhook | string | đường dẫn tới đầu api nhận webhook server của bạn |
200
{
"error": 0,
"message": "success",
"data": {
"id": 111,
"channel": "webhook",
"param1": "https://webhook-cua-ban.com.vn",
"param2": "sdf",
"send_only_income": 1
}
}
401
{
"error": 401,
"message": "Unauthorized Access",
"data": null
}
curl --location --request PUT 'https://oauth.casso.vn/v1/webhooks/111' \
--header 'Authorization: Access-Token' \
--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/v1/webhooks/:id
Thực hiện xóa một webhook bằng id webhook
Path Parameters
| Name | Type | Description |
|---|---|---|
| id | string | id webhook |
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | string | Access-Token |
200
{
"error": 0,
"message": "success",
"data": {
"id": 111,
"channel": "webhook",
"param1": "https://khanh-dep-trai.com.vn",
"param2": "sdf",
"send_only_income": 1
}
}
401
{
"error": 401,
"message": "Unauthorized Access",
"data": null
}
curl --location --request DELETE 'https://oauth.casso.vn/v1/webhooks/85' \
--header 'Authorization: Access-Token'
Xoá tất cả webhook trong đường dẫn
DELETE https://oauth.casso.vn/v1/webhooks
Xóa tất cả các webhook đang tồn tại trong đường dẫn webhook trùng với đường dẫn của bạn ( Nếu đã tạo trước đó rồi thì phải xóa mà đúng không! )
Query Parameters
| Name | Type | Description |
|---|---|---|
| webhook | string | đường dẫn tới đầu api nhận webhook server của bạn |
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | string | Access-Token |
200
{
"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
},
]
}
401
{
"error": 401,
"message": "Unauthorized Access",
"data": null
}
404
{
"error": 12,
"message": "Webhook not exists",
"data": null
}
curl --location --request DELETE 'https://oauth.casso.vn/v1/webhooks?webhook=https://websitecuaban.com/api/webhook' \
--header 'Authorization: Access-Token'