Difference between revisions of "คู่มือการเชื่อมระบบ EasyZone Radius Billing กับ Cloudbeds API"

From EasyZone wiki
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:
  
 
2. ให้ admin cloudbeds login เพื่อตามค่า code ที่ url  https://hotels.cloudbeds.com/api/v1.1/oauth?client_id=client_id&redirect_uri=https://www.cloud-hotspot.com/page/&response_type=code&scope=
 
2. ให้ admin cloudbeds login เพื่อตามค่า code ที่ url  https://hotels.cloudbeds.com/api/v1.1/oauth?client_id=client_id&redirect_uri=https://www.cloud-hotspot.com/page/&response_type=code&scope=
 +
 +
ค่า '''client_id''' คือ ค่าที่ท่าน admin cloudbeds ส่งให้
 +
 +
หลังจากนั้นจะได้ url https://www.cloud-hotspot.com/page/?code=xxxx&state=xxxx
 +
 +
3. admin easyzone ทำการดึงค่า access token จาก curl scripts ดังนี้
 +
 +
code=xxxx
 +
 +
client_id=xxxx
 +
 +
client_secret=xxxx
 +
 +
api_key=xxxx
 +
 +
curl -d "code=$code&client_id=$client_id&client_secret=$client_secret&redirect_uri=https://www.cloud-hotspot.com/page/&grant_type=authorization_code" -H "Content-Type: application/x-www-form-urlencoded" -X POST https://hotels.cloudbeds.com/api/v1.1/access_token
 +
 +
ระบบจะแสดงข้อมูล access token และ refresh token
 +
 +
access_token="xxxx"
 +
refresh_token="xxxx"
 +
 +
4. ให้นำ access token มาทำการ add webhook ตามสคริปท์ ดังนี้
 +
 +
user_id=xxxx
 +
 +
hotspot_id=xxxx
 +
 +
url="https://app.cloud-hotspot.com/mn/main/cloudbeds/$user_id/$hotspot_id"
 +
 +
object=reservation
 +
 +
'''เพิ่มการส่งค่า webhook เมื่อมีการ checked_in'''
 +
 +
action=status_changed
 +
curl --location --request POST 'https://hotels.cloudbeds.com/api/v1.1/postWebhook' --header "Authorization: Bearer $access_token" --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode "endpointUrl=$url" --data-urlencode "object=$object" --data-urlencode "action=$action"
 +
 +
'''เพิ่มการส่งค่า webhook เมื่อมีการย้ายห้อง'''
 +
 +
action=accommodation_changed
 +
 +
curl --location --request POST 'https://hotels.cloudbeds.com/api/v1.1/postWebhook' --header "Authorization: Bearer $access_token" --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode "endpointUrl=$url" --data-urlencode "object=$object" --data-urlencode "action=$action"
 +
 +
ตรวจสอบค่า webhook ที่ scripts
 +
 +
#get webhook
 +
curl --location --request GET "https://hotels.cloudbeds.com/api/v1.1/getWebhooks" --header "Authorization: Bearer $access_token" --header 'Content-Type: application/x-www-form-urlencoded'
 +
 +
 +
5. ทำการเพิ่มข้อมูล user_id hotspot_id ที่ระบบ endpoint webhook
 +
 +
6. ทำการเพิ่ม account admin เพื่อรับและบันทึกค่า webhook ที่เมนู staff url https://app.cloud-hotspot.com/mn
 +
 +
7. เพิ่ม billing plan cloudbeds ในระบบ billing plan ของ hotspot

Latest revision as of 10:51, 25 April 2024

มีวิธีการดังต่อไปนี้

1. ให้ admin cloudbeds ของโรงแรมสร้าง client_id client_secret api_key ส่วนค่า redirect_uri ตั้งเป็น https://www.cloud-hotspot.com/page/ โดยเลือก permission เป็น read ในระบบและส่งให้ทีมงาน easyzone

2. ให้ admin cloudbeds login เพื่อตามค่า code ที่ url https://hotels.cloudbeds.com/api/v1.1/oauth?client_id=client_id&redirect_uri=https://www.cloud-hotspot.com/page/&response_type=code&scope=

ค่า client_id คือ ค่าที่ท่าน admin cloudbeds ส่งให้

หลังจากนั้นจะได้ url https://www.cloud-hotspot.com/page/?code=xxxx&state=xxxx

3. admin easyzone ทำการดึงค่า access token จาก curl scripts ดังนี้

code=xxxx

client_id=xxxx

client_secret=xxxx

api_key=xxxx

curl -d "code=$code&client_id=$client_id&client_secret=$client_secret&redirect_uri=https://www.cloud-hotspot.com/page/&grant_type=authorization_code" -H "Content-Type: application/x-www-form-urlencoded" -X POST https://hotels.cloudbeds.com/api/v1.1/access_token

ระบบจะแสดงข้อมูล access token และ refresh token

access_token="xxxx" refresh_token="xxxx"

4. ให้นำ access token มาทำการ add webhook ตามสคริปท์ ดังนี้

user_id=xxxx

hotspot_id=xxxx

url="https://app.cloud-hotspot.com/mn/main/cloudbeds/$user_id/$hotspot_id"

object=reservation

เพิ่มการส่งค่า webhook เมื่อมีการ checked_in

action=status_changed curl --location --request POST 'https://hotels.cloudbeds.com/api/v1.1/postWebhook' --header "Authorization: Bearer $access_token" --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode "endpointUrl=$url" --data-urlencode "object=$object" --data-urlencode "action=$action"

เพิ่มการส่งค่า webhook เมื่อมีการย้ายห้อง

action=accommodation_changed

curl --location --request POST 'https://hotels.cloudbeds.com/api/v1.1/postWebhook' --header "Authorization: Bearer $access_token" --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode "endpointUrl=$url" --data-urlencode "object=$object" --data-urlencode "action=$action"

ตรวจสอบค่า webhook ที่ scripts

  1. get webhook

curl --location --request GET "https://hotels.cloudbeds.com/api/v1.1/getWebhooks" --header "Authorization: Bearer $access_token" --header 'Content-Type: application/x-www-form-urlencoded'


5. ทำการเพิ่มข้อมูล user_id hotspot_id ที่ระบบ endpoint webhook

6. ทำการเพิ่ม account admin เพื่อรับและบันทึกค่า webhook ที่เมนู staff url https://app.cloud-hotspot.com/mn

7. เพิ่ม billing plan cloudbeds ในระบบ billing plan ของ hotspot