เริ่มต้นใช้งาน
การใช้งาน API Token คือการส่งไปใน Header ของ HTTP Request รูปแบบดังนี้:
Authorization: Bearer <YOUR_PUBLIC_TOKEN>
ซึ่งตัวอย่างภายใน Documentation นี้ จะมีการส่ง API Token ไปด้วยทุกครั้ง ดังเช่นตัวอย่างด้านล่างนี้
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
https://api.acrosure.com/products/list;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_PUBLIC_TOKEN>' })
const response = await client.product.list()
import com.acrosure.Acrosure;
import com.acrosure.resource.Product;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
Product[] products = client.product().list();
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
products = acrosure_client.product.list()
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject products = await AcrosureClient.Product.List();
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.product.list() { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$products = $acrosureClient->getProductManager()->getList();
ตัวอย่างผลลัพธ์จากคำสั่งด้านบน
{
"status": "ok",
"data": [
{
"id": "prod_ta",
...
}, {
"id": "prod_motor",
...
}
]
}
ซึ่งผลลัพธ์ดังกล่าวก็คือรายการประกันภัยที่คุณสามารถทดลองใช้งานได้
ท่านสามารถเริ่มสมัครใช้งาน Acrosure เพื่อเริ่มทดลองเชื่อมต่อกับ Acrosure ได้อย่างง่ายๆ ดังนี้
ลงทะเบียนสร้าง Account Acrosure ได้ที่นี่
Login เข้าสู่ Dashboard ได้ที่นี่
Copy API Token มาใช้
สามารถเริ่มทดลองเชื่อมต่อกับระบบ Sandbox ได้ทันที
การเลือกใช้งาน Public/Secret Token
Token ทั้งสองประเภทใช้ในการยืนยันตัวตนเมื่อเรียกใช้ API ของ Acrosure แต่จะมีสิทธิ์ในการเข้าถึงบาง API ไม่เหมือนกัน
Public Token
สามารถเข้าถึง API ได้จำกัด โดยจะเป็น API ที่ไม่ส่งผลโดยตรงต่อการสร้างกรมธรรม์ (เช่น /applications/confirm)
Secret Token
สามารถเข้าถึง API ได้ทั้งหมด รวมถึงการเรียก API สำหรับสร้างกรมธรรม์ด้วย
เหตุผลที่ต้องมี Token สองประเภท
จุดประสงค์ของ Public Token นั้น มีไว้เพื่อให้คุณสามารถนำไปใช้ในระบบของคุณที่เปิดให้ผู้ใช้ทั่วไปเข้าถึงได้ เช่น Website หรือ Mobile Application โดยถึงแม้มีผู้ใช้เจอ Public Token นี้ ก็ไม่สามารถนำไปเรียกใช้ API เพื่อสร้างกรมธรรม์เองได้
ส่วน Secret Token นั้น มีไว้เพื่อให้คุณนำไปใช้ในระบบของคุณที่บุคคลภายนอกไม่สามารถเข้าถึงได้ เช่น Backend ที่ใช้งานภายใน เพื่อการสร้างกรมธรรม์
ภาพรวมการเชื่อมต่อ
ขั้นตอนการทำงาน
ในกระบวนการสั่งซื้อประกันภัยผ่าน Acrosure จะประกอบไปด้วยขั้นตอนหลักๆ 3 ขั้นตอนดังนี้
- ผู้พัฒนาเลือกใช้ฟอร์มสั่งซื้อสำเร็จรูป หรือเรียก API เพื่อสร้างฟอร์มสำหรับสั่งซื้อเอง จากนั้น redirect ผู้ใช้ไปยังฟอร์มเพื่อให้ผู้ใช้กรอกข้อมูล
- เมื่อผู้ใช้กรอกข้อมูลเรียบร้อยแล้ว ผู้ใช้จะถูก redirect กลับมายังเว็บไซต์ของผู้ขาย (ตาม URL ที่นักพัฒนาระบุ) เพื่อให้ดำเนินการชำระเงินต่อไป
- เมื่อชำระเงินเรียบร้อยแล้ว ให้เรียก API เพื่อยืนยันการสั่งซื้อจากเซิร์ฟเวอร์ของผู้พัฒนา
รูปแบบการเชื่อมต่อ
เนื่องจากข้อมูลที่ต้องใช้ในการซื้อกรมธรรม์ประกันภัยมีความซับซ้อน การ implement ระบบเพื่อเชื่อมต่อเข้ากับ Dhipaya Insurance Gateway จึงสามารถทำได้ 3 แบบด้วยกัน ดังนี้
1. เชื่อมต่อแบบ Form
การเชื่อมต่อระบบแบบ form นั้นเป็นการเชื่อมต่อที่ง่ายกว่า โดยจะเป็นการ redirect ลูกค้ามาที่หน้า form ในการซื้อประกันภัยของระบบ Dhipaya Insurance Gateway และเมื่อลูกค้ากรอกข้อมูลครบถ้วนแล้ว จะทำการ redirect กลับไปยังหน้าเว็บไซต์ของ partner เพื่อทำการดำเนินการขั้นตอนต่อไป
2. เชื่อมต่อแบบ Hybrid
การเชื่อมต่อแบบ Hybrid คือการเชื่อมต่อที่ผสมทั้งแบบ form และแบบ API โดยจะเหมาะสำหรับระบบที่มีข้อมูลลูกค้าอยู่แล้วบางส่วน และต้องการให้ลูกค้ากรอกเพิ่มเติมในส่วนที่ขาด
3. เชื่อมต่อแบบ API
การเชื่อมต่อระบบแบบ API นั้นเป็นการเชื่อมต่อที่ซับซ้อนกว่า เพราะการซื้อกรมธรรม์ประกันภัยนั้นมีข้อมูลที่ต้องใช้หลากหลาย และบาง field ข้อมูลก็มีเงื่อนไขแตกต่างกันไป ข้อดีของการเชื่อมต่อแบบนี้คือลูกค้าจะได้รับประสบการณ์ที่ดีกว่าในการซื้อสินค้าหรือบริการ
วิธีการดูโครงสร้างข้อมูลฟอร์ม
- เข้าไปยัง Acrosure Dashboard
- กดเมนู Products ที่อยู่ Panel ทางซ้าย
- เลือก Product ที่ต้องการดูข้อมูล
- กดที่ Form Parameter Items เพื่อดูโครงสร้างเบื้องต้น หรือดูที่ Raw Form Schema เพื่อดูโครงสร้างอย่างละเอียด
Software Development Kit
SDK คือชุดเครื่องมือสําหรับนักพัฒนา ที่จัดเตรียมไว้เพื่อให้นักพัฒนาได้ทําการเช่ือมต่อกับ ระบบ Acrosure Insurance Gateway ได้อย่างสะดวกมากขึ้น โดย SDK นั้นจะแบ่งเป็น แต่ละภาษา ขึ้นกับภาษาท่ีนักพัฒนาใช้ในระบบของบริษัท Partner โดยมีภาษาท่ีรองรับ ดังนี้
โดยนักพัฒนาสามารถดูวิธีการเริ่มต้นใช้งานได้ที่ลิ้งก์ของแต่ละภาษาด้านบน
เชื่อมต่อแบบ Form
ท่านสามารถใช้ฟอร์มสำเร็จรูปสำหรับเริ่มการสั่งซื้อประกันภัยได้ทันที โดยวิธีนี้จะสามารถทำได้ง่ายที่สุด แต่ผู้ซื้อจำเป็นต้องกรอกข้อมูลในการสั่งซื้อทั้งหมดด้วยตนเอง
การเชื่อมต่อในส่วนนี้จะประกอบด้วย 3 ขั้นตอน คือ
- ส่งผู้ใช้ไปยังฟอร์มสำเร็จรูป
- รับ callback หลังกรอกข้อมูลเสร็จสิ้น
- เรียก API
POST /applications/confirm
ยืนยันการสั่งซื้อจากเซิร์ฟเวอร์
1. ส่งผู้ใช้ไปยังหน้าเว็บฟอร์ม
ตัวอย่างโค้ด HTML ซึ่งเป็นลิงก์สำหรับการสั่งซื้อ
<a href="https://form.acrosure.com/?token=<YOUR_PUBLIC_TOKEN>&productId=prod_ta">สั่งซื้อประกันภัย</a>
สำหรับส่งผู้ใช้ไปสั่งซื้อประกันด้วยฟอร์มสำเร็จรูป สามารถทำได้ดังนี้
- เข้าไปที่หน้า Products ในแดชบอร์ด จากนั้นเลือก Product ที่ต้องการสั่งซื้อ
- คัดลอก URL สำหรับ redirect ผู้ใช้ไปยังแบบฟอร์มสั่งซื้อประกันภัย ไปใช้ได้ทันที โดยสร้างเป็นลิงก์หรือปุ่มด้วย HTML เพื่อส่งผู้ใช้ไปยังหน้าแบบฟอร์มดังกล่าว
2. รับ callback
การเรียก callback จะส่ง Application ID มาผ่าน URL ในส่วนคิวรีสตริง โดยมีรูปแบบดังนี้
https://example.com/dhipaya/callback?applicationId=appl_SAMPLE01
ให้นักพัฒนาเก็บ
applicationId
ไว้ จากนั้นนำผู้ใช้ไปดำเนินการชำระเงิน ก่อนจะยืนยันการสั่งซื้อในขั้นตอนสุดท้าย
เมื่อผู้ใช้กรอกข้อมูลการสั่งซื้อเสร็จสิ้น ผู้ใช้จะถูก redirect กลับมาที่เว็บไซต์ของนักพัฒนา เพื่อดำเนินการชำระเงินให้เสร็จสิ้น ก่อนจะยืนยันการสั่งซื้อประกันภัยเป็นขั้นตอนสุดท้าย
อย่างไรก็ตาม หากยังไม่ได้กำหนดหน้า callback ไว้ เบื้องต้นระบบจะ redirect ไปยังหน้าตัวอย่าง เพื่อให้ผู้พัฒนาพัฒนาหน้านี้ต่อไป
ท่านสามารถระบุ URL ของหน้าที่จะใช้เป็น callback ได้ โดยเข้าไปที่เมนู API Keys จากแดชบอร์ด
3. ยืนยันการสั่งซื้อ
curl -X POST \
--header "Authorization: Bearer <YOUR_SECRET_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/confirm;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_SECRET_TOKEN>" });
const response = await client.application.confirm("appl_SAMPLE01");
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Policy;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_SECRET_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Policy[] policies = client.application().confirm(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_SECRET_TOKEN>')
confirmed_application = acrosure_client.application.confirm(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_SECRET_TOKEN>")
JObject confirmedApplication = await AcrosureClient.Application.Confirm(
"appl_SAMPLE01"
);
// Not supported for Client-side
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_SECRET_TOKEN>" ]);
$confirmedApplication = $acrosureClient->getApplicationManager()->confirm(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "plcy_SAMPLE01",
"application_id": "appl_SAMPLE01",
...
},
{
"id": "plcy_SAMPLE02",
"application_id": "appl_SAMPLE01",
...
}
]
}
เมื่อผู้ใช้กรอกข้อมูลการสั่งซื้อประกันภัยเรียบร้อยแล้ว ผู้ใช้จะถูก redirect กลับมาที่เว็บไซต์ของผู้พัฒนา พร้อมกับ Application ID เพื่อให้ผู้พัฒนาได้ดำเนินการชำระเงินให้เรียบร้อย
เมื่อชำระเงินเสร็จสิ้นแล้ว ผู้พัฒนาจำเป็นต้องเรียก API POST /applications/confirm
เพื่อยืนยันการสั่งซื้อ API
เชื่อมต่อแบบ Hybrid
เพื่อให้ผู้ใช้ตัดสินใจสั่งซื้อประกันภัยได้อย่างรวดเร็วยิ่งขึ้น ท่านสามารถสร้างลิงก์สำหรับสั่งซื้อเฉพาะสำหรับผู้ซื้อรายนั้นๆ เพื่อให้ท่านสามารถกรอกข้อมูลบางส่วนที่ทราบอยู่แล้วให้ผู้ใช้ได้ทันที ก่อนที่จะ redirect ผู้ใช้ไปยังหน้าสั่งซื้อต่อไป
ขั้นตอนในการสร้างและกรอกฟอร์มล่วงหน้ามีดังนี้
- ดูรายละเอียดของฟอร์มที่ต้องกรอกจากแดชบอร์ด
- เรียก API
POST /applications/create
เพื่อสร้างฟอร์ม - สร้าง URL ของฟอร์มและ redirect ผู้ใช้ไปที่ฟอร์มตามปกติ
- เรียก API
POST /applications/confirm
ยืนยันการสั่งซื้อจากเซิร์ฟเวอร์
1. ดูรายละเอียดของฟอร์ม
ท่านสามารถดู product_id รายละเอียดฟอร์มที่ต้องกรอกได้จากหน้า Product ในแดชบอร์ด โดยสามารถดูโครงสร้างข้อมูลของฟอร์มได้จากหัวข้อ Form Schema และดูตัวอย่างข้อมูลทดสอบได้จากหัวข้อ Sample Form Data
2. สร้างฟอร์ม
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta","basic_data":{"countries":["GERMANY","JAPAN"],"policy_date":"2018-12-08","expiry_date":"2018-12-15","policy_unit":"D"}}' \
https://api.acrosure.com/applications/create;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_PUBLIC_TOKEN>' })
const response = await client.application.create({
product_id: 'prod_ta',
basic_data: {
countries: ['GERMANY', 'JAPAN'],
policy_date: '2018-12-08',
expiry_date: '2018-12-15',
policy_unit: 'D'
}
})
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.form.ApplicationCreateForm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
ObjectMapper mapper = new ObjectMapper();
ObjectNode basicData = mapper.createObjectNode();
ArrayNode countries = basicData.putArray("countries");
countries.add("GERMANY");
countries.add("JAPAN");
basicData.put("policy_date", "2018-12-08");
basicData.put("expiry_date", "2018-12-15");
basicData.put("policy_unit", "D");
ApplicationCreateForm createForm = new ApplicationCreateForm();
createForm.setBasicData(basicData);
try {
Application application = client.application().create(createForm);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
created_application = acrosure_client.application.create(
productId = 'prod_ta', # required
basic_data = {},
package_options = {},
additional_data = {},
package_code = 'PACKAGE_SAMPLE_01',
attachments = []
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject createdApplication = await AcrosureClient.Application.Create(@"{
productId: 'prod_ta', // required
basic_data: {},
package_options: {},
additional_data: {},
package_code: 'PACKAGE_SAMPLE_01',
attachments: []
}")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.create(productId: "prod_ta", basicData: [
"countries": ["GERMANY", "JAPAN"],
"policy_date": "2018-12-08",
"expiry_date": "2018-12-15",
"policy_unit": "D"
]) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$createdApplication = $acrosureClient->getApplicationManager()->create([
"product_id" => "prod_ta", // required
"basic_data" => json_decode('{}'),
"package_options" => json_decode('{}'),
"additional_data" => json_decode('{}'),
"package_code" => "PACKAGE_SAMPLE_01",
"attachments": => []
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
...
}
}
เรียก API POST /applications/create
โดยส่ง product_id ตามที่ปรากฎในแดชบอร์ด และระบุ form_data ที่ต้องการกรอกให้ผู้ใช้ล่วงหน้า
ทั้งนี้การเรียก API ในส่วนนี้สามารถเรียกจากเซิร์ฟเวอร์ หรือเรียกจากไคลเอนต์ด้วย JavaScript ก็ได้เช่นกัน
3. ส่งผู้ใช้ไปยังหน้าเว็บฟอร์ม
จากตัวอย่างนั้น URL ของฟอร์มจะเป็น
https://form.acrosure.com/?token=<YOUR_PUBLIC_TOKEN>&productId=prod_ta&applicationId=appl_SAMPLE01
URL ของฟอร์มที่กรอกแล้วนี้จะเหมือนกับ URL ของฟอร์มแบบสำเร็จรูป เพียงแต่เติมคิวรีสตริง applicationId=appl_SAMPLE01
เข้าไป โดยนำ application_id
จากผลในขั้นตอนที่แล้วมาใช้งาน
เมื่อ redirect ผู้ใช้ไปยัง URL ดังกล่าว ผู้ใช้จะพบกับฟอร์มที่กรอกข้อมูลไว้แล้ว และสามารถทำรายการที่เหลือต่อได้ตามปกติ เช่นเดียวกับการใช้ฟอร์มสำเร็จรูป
4. ยืนยันการสั่งซื้อ
curl -X POST \
--header "Authorization: Bearer <YOUR_SECRET_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/confirm;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_SECRET_TOKEN>' })
const response = await client.application.confirm('appl_SAMPLE01')
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Policy;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_SECRET_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Policy[] policies = client.application().confirm(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_SECRET_TOKEN>')
confirmed_application = acrosure_client.application.confirm(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_SECRET_TOKEN>")
JObject confirmedApplication = await AcrosureClient.Application.Confirm(
"appl_SAMPLE01"
);
// Not supported for Client-side
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_SECRET_TOKEN>" ]);
$confirmedApplication = $acrosureClient->getApplicationManager()->confirm(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "plcy_SAMPLE01",
"application_id": "appl_SAMPLE01",
...
},
{
"id": "plcy_SAMPLE02",
"application_id": "appl_SAMPLE01",
...
}
]
}
เมื่อผู้ใช้กรอกข้อมูลการสั่งซื้อประกันภัยเรียบร้อยแล้ว ผู้ใช้จะถูก redirect กลับมาที่เว็บไซต์ของผู้พัฒนา พร้อมกับ Application ID เพื่อให้ผู้พัฒนาได้ดำเนินการชำระเงินให้เรียบร้อย
เมื่อชำระเงินเสร็จสิ้นแล้ว ผู้พัฒนาจำเป็นต้องเรียก API POST /applications/confirm
เพื่อยืนยันการสั่งซื้อ API
เชื่อมต่อแบบ API แบบง่าย
ในบางกรณี นักพัฒนาอาจต้องการกรอกฟอร์มด้วย API ทั้งหมด เช่น กรณีที่นักพัฒนาต้องการสร้างระบบช่วยขายประกันสำหรับตัวแทนจำหน่าย โดยไม่ได้ให้ผู้ซื้อเป็นผู้กรอกข้อมูลเองโดยตรง เป็นต้น
ในกรณีดังกล่าว นักพัฒนาสามารถเรียก API เพื่อดำเนินการทั้งหมดได้ ดังนี้
- ดูรายละเอียดของฟอร์มที่ต้องกรอกจากแดชบอร์ด
- เรียกใช้ API
POST /applications/create
เพื่อกรอกข้อมูลภายในฟอร์ม - เรียกใช้ API
POST /applications/confirm
เพื่อยืนยันการสั่งซื้อ
1. ดูรายละเอียดของฟอร์ม
ท่านสามารถดู product_id
รายละเอียดฟอร์มที่ต้องกรอกได้จากหน้า Product ในแดชบอร์ด
โดยสามารถดูโครงสร้างข้อมูลของฟอร์มได้จากหัวข้อ Form Schema และดูตัวอย่างข้อมูลทดสอบได้จากหัวข้อ Sample Form Data
2. สร้างใบคำสั่งซื้อ
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta","basic_data":{"countries":["GERMANY","JAPAN"],"policy_date":"2018-12-08","expiry_date":"2018-12-15","policy_unit":"D"},"package_options":null,"additional_data":{"customer_title":"MR.","customer_first_name":"MANA","customer_last_name":"MUNGMARN","company_name":"-","card_type":"I","id_card":"1489900087857","email":"developer@example.com","phone":"","insurer_list":[{"title":"MR.","first_name":"MANA","last_name":"MUNGMARN","card_type":"I","id_card":"1489900087857","birthdate":"1988-10-14","email":"developer@example.com","phone":"0812345678","nominee":"","relationship":"","address":{"address_no":"1","moo":"2","village":"VILLAGE","alley":"","lane":"LAD PRAO 4","street":"LAD PRAO","minor_district":"","subdistrict":"Chomphon","district":"Chatuchak","province":"Bangkok","postal_code":"10900"}},{"title":"MR.","first_name":"MANEE","last_name":"MUNGMARN","card_type":"I","id_card":"1682086540364","birthdate":"1988-12-31","email":"developer@example.com","phone":"0812345678","nominee":"MR. MANOCH MUNGMARN","relationship":"Brother/Sister","address":{"address_no":"1","moo":"2","village":"VILLAGE","alley":"","lane":"LAD PRAO 4","street":"LAD PRAO","minor_district":"","subdistrict":"Chomphon","district":"Chatuchak","province":"Bangkok","postal_code":"10900"}}]}}' \
https://api.acrosure.com/applications/create;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.create({
product_id: "prod_ta",
basic_data: {
countries: ["GERMANY", "JAPAN"],
policy_date: "2018-12-08",
expiry_date: "2018-12-15",
policy_unit: "D"
},
package_options: null,
additional_data: {
...
}
});
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.form.ApplicationCreateForm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
ObjectMapper mapper = new ObjectMapper();
ObjectNode basicData = mapper.createObjectNode();
ArrayNode countries = basicData.putArray("countries");
countries.add("GERMANY");
countries.add("JAPAN");
basicData.put("policy_date", "2018-12-08");
basicData.put("expiry_date", "2018-12-15");
basicData.put("policy_unit", "D");
ApplicationCreateForm createForm = new ApplicationCreateForm();
createForm.setBasicData(basicData);
try {
Application application = client.application().create(createForm);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
created_application = acrosure_client.application.create(
productId = 'prod_ta', # required
basic_data = {},
package_options = {},
additional_data = {},
package_code = 'PACKAGE_SAMPLE_01',
attachments = []
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject createdApplication = await AcrosureClient.Application.Create(@"{
productId: 'prod_ta', // required
basic_data: {},
package_options: {},
additional_data: {},
package_code: 'PACKAGE_SAMPLE_01',
attachments: []
}")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.create(
productId: "prod_ta",
basicData: [
"countries": ["GERMANY", "JAPAN"],
"policy_date": "2018-12-08",
"expiry_date": "2018-12-15",
"policy_unit": "D",
],
additionalData, ...
) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$createdApplication = $acrosureClient->getApplicationManager()->create([
"product_id" => "prod_ta", // required
"basic_data" => json_decode('{}'),
"package_options" => json_decode('{}'),
"additional_data" => json_decode('{}'),
"package_code" => "PACKAGE_SAMPLE_01",
"attachments": => []
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
"status": "READY",
...
}
}
สร้างฟอร์มสั่งซื้อในลักษณะเดียวกันกับการสร้างฟอร์มแบบกรอกข้อมูลบางส่วน
3. ยืนยันการสั่งซื้อ
curl -X POST \
--header "Authorization: Bearer <YOUR_SECRET_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/confirm;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_SECRET_TOKEN>' })
const response = await client.application.confirm('appl_SAMPLE01')
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Policy;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_SECRET_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Policy[] policies = client.application().confirm(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_SECRET_TOKEN>')
confirmed_application = acrosure_client.application.confirm(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_SECRET_TOKEN>")
JObject confirmedApplication = await AcrosureClient.Application.Confirm(
"appl_SAMPLE01"
);
// Not supported for Client-side
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_SECRET_TOKEN>" ]);
$confirmedApplication = $acrosureClient->getApplicationManager()->confirm(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "plcy_SAMPLE01",
"application_id": "appl_SAMPLE01",
...
},
{
"id": "plcy_SAMPLE02",
"application_id": "appl_SAMPLE01",
...
}
]
}
ยืนยันการสั่งซื้อ เช่นเดียวกับการสั่งซื้อด้วยวิธีการอื่นๆ
เชื่อมต่อแบบ API แบบหลายขั้นตอน
บางครั้ง การเชื่อมต่อแบบ API อาจไม่ได้จบด้วยการใช้ POST /applications/create
เพียงครั้งเดียว แต่อาจผ่านการใส่ข้อมูลทีละส่วนจนกว่าจะสมบูรณ์
ในกรณีดังกล่าว มีตัวอย่างในการทำงานดังนี้ ดังนี้
- ดูรายละเอียดของฟอร์มที่ต้องกรอกจากแดชบอร์ด
- เรียกใช้ API
POST /applications/create
เพื่อสร้างใบคำสั่งซื้อและใส่ข้อมูลเบื้องต้น - เรียกใช้ API
POST /applications/get-packages
เพื่อดูแพคเกจที่สามารถเลือกได้ - เรียกใช้ API
POST /applications/select-package
เพื่อเลือกแพคเกจที่ต้องการ - เรียกใช้ API
POST /applications/update
เพื่อใส่ข้อมูลที่เหลือให้สมบูรณ์ - เรียกใช้ API
POST /applications/confirm
เพื่อยืนยันการสั่งซื้อ
1. ดูรายละเอียดของฟอร์ม
ท่านสามารถดู product_id
รายละเอียดฟอร์มที่ต้องกรอกได้จากหน้า Product ในแดชบอร์ด
โดยสามารถดูโครงสร้างข้อมูลของฟอร์มได้จากหัวข้อ Form Schema และดูตัวอย่างข้อมูลทดสอบได้จากหัวข้อ Sample Form Data
2. สร้างใบคำสั่งซื้อ
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta","basic_data":{"countries":["GERMANY","JAPAN"],"policy_date":"2018-12-08","expiry_date":"2018-12-15","policy_unit":"D"}}' \
https://api.acrosure.com/applications/create;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_PUBLIC_TOKEN>' })
const response = await client.application.create({
product_id: 'prod_ta',
basic_data: {
countries: ['GERMANY', 'JAPAN'],
policy_date: '2018-12-08',
expiry_date: '2018-12-15',
policy_unit: 'D'
}
})
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.form.ApplicationCreateForm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
ObjectMapper mapper = new ObjectMapper();
ObjectNode basicData = mapper.createObjectNode();
ArrayNode countries = basicData.putArray("countries");
countries.add("GERMANY");
countries.add("JAPAN");
basicData.put("policy_date", "2018-12-08");
basicData.put("expiry_date", "2018-12-15");
basicData.put("policy_unit", "D");
ApplicationCreateForm createForm = new ApplicationCreateForm();
createForm.setBasicData(basicData);
try {
Application application = client.application().create(createForm);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
created_application = acrosure_client.application.create(
productId = 'prod_ta', # required
basic_data = {},
package_options = {},
additional_data = {},
package_code = 'PACKAGE_SAMPLE_01',
attachments = []
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject createdApplication = await AcrosureClient.Application.Create(@"{
productId: 'prod_ta', // required
basic_data: {},
package_options: {},
additional_data: {},
package_code: 'PACKAGE_SAMPLE_01',
attachments: []
}")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.create(
productId: "prod_ta",
basicData: [
"countries": ["GERMANY", "JAPAN"],
"policy_date": "2018-12-08",
"expiry_date": "2018-12-15",
"policy_unit": "D",
]
) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$createdApplication = $acrosureClient->getApplicationManager()->create([
"product_id" => "prod_ta", // required
"basic_data" => json_decode('{}'),
"package_options" => json_decode('{}'),
"additional_data" => json_decode('{}'),
"package_code" => "PACKAGE_SAMPLE_01",
"attachments": => []
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
"status": "READY",
...
}
}
สร้างฟอร์มสั่งซื้อพร้อมกรอกข้อมูลบางส่วน POST /applications/create
3. ดูแพคเกจที่สามารถซื้อได้
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/get-packages;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_PUBLIC_TOKEN>' })
const response = await client.application.getPackages('appl_SAMPLE01')
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Package;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Package[] packages = client.application().getPackages(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
packages = acrosure_client.application.get_packages(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject packages = await AcrosureClient.Application.GetPackages(
"appl_SAMPLE01"
)
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.getPackages(id: "appl_SAMPLE01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$packages = $acrosureClient->getApplicationManager()->getPackages("appl_SAMPLE01");
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"package_code": "PACKAGE_SAMPLE_01",
...
}, {
"package_code": "PACKAGE_SAMPLE_02",
...
}
]
}
ดูรายการแพคเกจที่สามารถซื้อได้ POST /applications/get-packages
4. เลือกแพคเกจ
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01","package_code":"PACKAGE_SAMPLE_01"}' \
https://api.acrosure.com/applications/select-package;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_PUBLIC_TOKEN>' })
const response = await client.application.selectPackage({
application_id: 'appl_SAMPLE01',
package_code: 'PACKAGE_SAMPLE_01'
})
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Package;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Package[] packages = client.application().getPackages(application);
client.application().selectPackage(application, packages[0]);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
updated_application = acrosure_client.application.select_package(
application_id = 'appl_SAMPLE01',
package_code = 'PACKAGE_SAMPLE_01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject updatedApplication = await AcrosureClient.Application.selectPackage({
application_id: "appl_SAMPLE01",
package_code: "PACKAGE_SAMPLE_01"
});
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.selectPackage(id: "appl_SAMPLE01", packageCode: "PACKAGE_SAMPLE_01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$updatedApplication = $acrosureClient->getApplicationManager()->selectPackage([
"application_id" => "appl_SAMPLE01",
"package_code" => "PACKAGE_SAMPLE_01"
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
...
}
}
เลือกแพคเกจสำหรับใบคำสั่งซื้อผ่าน POST /applications/select-package
5. ใส่ข้อมูลในแบบฟอร์มให้สมบูรณ์
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01",,"basic_data":{"countries":["GERMANY","JAPAN"],"policy_date":"2018-12-08","expiry_date":"2018-12-15","policy_unit":"D"},"package_options":null,"additional_data":{"customer_title":"MR.","customer_first_name":"MANA","customer_last_name":"MUNGMARN","company_name":"-","card_type":"I","id_card":"1489900087857","email":"developer@example.com","phone":"","insurer_list":[{"title":"MR.","first_name":"MANA","last_name":"MUNGMARN","card_type":"I","id_card":"1489900087857","birthdate":"1988-10-14","email":"developer@example.com","phone":"0812345678","nominee":"","relationship":"","address":{"address_no":"1","moo":"2","village":"VILLAGE","alley":"","lane":"LAD PRAO 4","street":"LAD PRAO","minor_district":"","subdistrict":"Chomphon","district":"Chatuchak","province":"Bangkok","postal_code":"10900"}},{"title":"MR.","first_name":"MANEE","last_name":"MUNGMARN","card_type":"I","id_card":"1682086540364","birthdate":"1988-12-31","email":"developer@example.com","phone":"0812345678","nominee":"MR. MANOCH MUNGMARN","relationship":"Brother/Sister","address":{"address_no":"1","moo":"2","village":"VILLAGE","alley":"","lane":"LAD PRAO 4","street":"LAD PRAO","minor_district":"","subdistrict":"Chomphon","district":"Chatuchak","province":"Bangkok","postal_code":"10900"}}]}}' \
https://api.acrosure.com/applications/update;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.update({
application_id: "appl_SAMPLE01",
basic_data: {
countries: [
"GERMANY",
"JAPAN"
],
policy_date: "2018-12-08",
expiry_date: "2018-12-15",
policy_unit: "D"
},
package_options: null,
additional_data: {
...
}
});
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.form.ApplicationCreateForm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
ObjectMapper mapper = new ObjectMapper();
ObjectNode basicData = mapper.createObjectNode();
ArrayNode countries = basicData.putArray("countries");
countries.add("GERMANY");
countries.add("JAPAN");
basicData.put("policy_date", "2018-12-08");
basicData.put("expiry_date", "2018-12-15");
basicData.put("policy_unit", "D");
try {
Application application = client.application().get("appl_SAMPLE01");
application.setBasicData(basicData);
client.application().update(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
updatedApplication = acrosure_client.application.update(
application_id = 'appl_SAMPLE01', # required
basic_data = {},
package_options = {},
additional_data = {},
package_code = 'PACKAGE_SAMPLE_01',
attachments = []
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject updatedApplication = await AcrosureClient.Application.Update(@"{
application_id: 'appl_SAMPLE01', // required
basic_data: {},
package_options: {},
additional_data: {},
package_code: 'PACKAGE_SAMPLE_01',
attachments: []
}")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.update(
id: "appl_SAMPLE01",
basicData: [
"countries": ["GERMANY", "JAPAN"],
"policy_date": "2018-12-08",
"expiry_date": "2018-12-15",
"policy_unit": "D",
],
additionalData, ...
) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$updatedApplication = $acrosureClient->getApplicationManager()->update([
"application_id" => "appl_SAMPLE01", // required
"basic_data": json_decode('{}'),
"package_options": json_decode('{}'),
"additional_data": json_decode('{}'),
"package_code": "PACKAGE_SAMPLE_01",
"attachments": []
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
...
}
}
อัพเดทใบคำสั่งซื้อจนข้อมูลสมบูรณ์ POST /applications/update
6. ยืนยันการสั่งซื้อ
curl -X POST \
--header "Authorization: Bearer <YOUR_SECRET_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/confirm;
import AcrosureClient from '@acrosure/js-sdk'
const client = new AcrosureClient({ token: '<YOUR_SECRET_TOKEN>' })
const response = await client.application.confirm('appl_SAMPLE01')
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Policy;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_SECRET_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Policy[] policies = client.application().confirm(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_SECRET_TOKEN>')
confirmed_application = acrosure_client.application.confirm(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_SECRET_TOKEN>")
JObject confirmedApplication = await AcrosureClient.Application.Confirm(
"appl_SAMPLE01"
);
// Not supported for Client-side
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_SECRET_TOKEN>" ]);
$confirmedApplication = $acrosureClient->getApplicationManager()->confirm(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "plcy_SAMPLE01",
"application_id": "appl_SAMPLE01",
...
},
{
"id": "plcy_SAMPLE02",
"application_id": "appl_SAMPLE01",
...
}
]
}
ยืนยันการสั่งซื้อ เช่นเดียวกับการสั่งซื้อด้วยวิธีการอื่นๆ POST /applications/confirm
Applications API reference
Application คือใบคำสั่งซื้อกรมธรรม์ ซึ่งทางผู้ใช้งาน Acrosure สามารถจัดการกับข้อมูลภายในแบบฟอร์มการซื้อประกันได้อย่างอิสระ ก่อนที่จะขอออกกรมธรรม์กับทางบริษัทประกันภัย
ใบคำสั่งซื้อของประกันแต่ละประเภทจะมีโครงสร้างข้อมูลในแบบฟอร์มที่แตกต่างกัน คือฟิลด์ basic_data
, package_options
และ additional_data
ซึ่งสามารถดูโครงสร้างข้อมูลแบบฟอร์มเหล่านี้ได้โดยขั้นตอนดังนี้
โครงสร้างข้อมูล Application
ตัวอย่างข้อมูล
{
"id": "appl_SAMPLE01",
"form_data": {
"email": "developer@example.com",
"phone": "086161236",
"id_card": "1489900087857",
"card_type": "I",
"countries": [
"GERMANY",
"JAPAN"
],
"expiry_date": "2018-11-21T00:00:00Z",
"policy_date": "2018-11-14T00:00:00Z",
"policy_unit": "D",
"company_name": "-",
"insurer_list": [
{
"email": "developer@example.com",
"phone": "0812345678",
"title": "MR.",
"address": {
"moo": "2",
"lane": "LAD PRAO 4",
"alley": "",
"street": "LAD PRAO",
"village": "VILLAGE",
"district": "Chatuchak",
"province": "Bangkok",
"address_no": "1",
"postal_code": "10900",
"subdistrict": "Chomphon",
"minor_district": ""
},
"id_card": "1111111111119",
"nominee": "",
"birthdate": "1988-10-14T00:00:00Z",
"card_type": "I",
"last_name": "MUNGMARN",
"first_name": "MANA",
"relationship": ""
},
{
"email": "developer@example.com",
"phone": "0812345678",
"title": "MR.",
"address": {
"moo": "2",
"lane": "LAD PRAO 4",
"alley": "",
"street": "LAD PRAO",
"village": "VILLAGE",
"district": "Chatuchak",
"province": "Bangkok",
"address_no": "1",
"postal_code": "10900",
"subdistrict": "Chomphon",
"minor_district": ""
},
"id_card": "1111111111119",
"nominee": "MR. MANOCH MUNGMARN",
"birthdate": "1988-12-31T00:00:00Z",
"card_type": "I",
"last_name": "MUNGMARN",
"first_name": "MANEE",
"relationship": "Brother/Sister"
}
],
"customer_title": "MR.",
"start_province": "",
"customer_last_name": "MUNGMARN",
"customer_first_name": "MANA",
"destination_provinces": null
},
"status": "EXPIRED",
"paid": false,
"amount": 1351,
"amount_with_tax": 1452,
"source": "PARTNER",
"ref1": "",
"ref2": "",
"ref3": "",
"insurer_package_code": "ITA0402",
"insurer_package_name": "",
"insurer_application_no": "",
"package_data": null,
"language": "EN",
"application_no": "AP00010000001",
"step": 0,
"created_at": "2018-09-14T20:53:59.547879Z",
"updated_at": "2018-09-23T15:57:11.5342Z",
"expired_at": "2018-09-21T20:53:59.530746Z",
"product_id": "prod_ta",
"user_id": "user_SAMPLE",
"team_id": "team_SAMPLE",
"group_policy_id": "",
"product_code": "",
"product_name": "International Travel Insurance",
"policy_ids": null,
"created_by": "Sample Partner"
}
ข้อมูลภายในใบคำสั่งซื้อที่ได้คืนมาจากการเรียก API ต่างๆ โดยบางฟิลด์เป็นฟิลด์ที่ทาง Acrosure คำนวณมาให้ ไม่สามารถแก้ไขได้โดยตรง (เช่น ค่าเบี้ยประกัน หรือข้อความ error)
Name | Meaning |
---|---|
id |
รหัสของใบคำสั่งซื้อที่ใช้อ้างอิงในที่ต่างๆ |
application_no |
หมายเลขของใบคำสั่งซื้อ อยู่ในรูปแบบที่อ่านง่าย |
basic_data |
ข้อมูลเบื้องต้นที่ต้องใช้ในการค้นหาแพคเกจ (ดูเพิ่มที่ Acrosure Dashboard) |
package_options |
ข้อมูลเพิ่มเติมที่ใช้ในการค้นหาแพคเกจ (ดูเพิ่มที่ Acrosure Dashboard) |
additional_data |
ข้อมูลรายละเอียดสำหรับการออกกรมธรรม์ (ดูเพิ่มที่ Acrosure Dashboard) |
package_code |
รหัสแพคเกจที่เลือกซื้อ |
ref1 |
ข้อความสำหรับใช้ในการอ้างอิงอันที่ 1 |
ref2 |
ข้อความสำหรับใช้ในการอ้างอิงอันที่ 2 |
ref3 |
ข้อความสำหรับใช้ในการอ้างอิงอันที่ 3 |
status |
สถานะของใบคำสั่งซื้อ ดูเพิ่มเติมได้ที่ Application Status |
paid |
ค่าที่บ่งบอกสถานะการชำระเงินของใบคำสั่งซื้อ |
net_premium |
ค่าเบี้ยประกันเบื้องต้น |
gross_premium |
ค่าเบี้ยประกันสุทธิ |
vat |
ค่า VAT |
duty |
ค่าภาษีอากร |
step |
หมายเลข step ที่ใบคำสั่งซื้อนั้นกำลังดำเนินการอยู่ (ใช้ภายใน Acosure Form) |
product_id |
รหัสชนิดของ Product |
user_id |
รหัสของผู้ใช้ที่สร้างใบคำสั่งซื้อนี้ (ถ้าใช้ API Token ของ Team จะไม่มีฟิลด์นี้) |
team_id |
รหัสของทีมที่สร้างใบคำสั่งซื้อนี้ (ทีมของคุณนั่นเอง! 🎉) |
policy_ids |
รายการรหัสของกรมธรรม์ |
error_fields |
รายการที่บอกว่าฟิลด์ในแบบฟอร์มฟิลด์ไหนยังไม่ถูกต้อง |
error_message |
ข้อความที่แจ้งความไม่ถูกต้องต่างๆ เช่น มีฟิลด์ไม่ครบ ยังไม่เลือกแพคเกจ เป็นต้น |
created_at |
เวลาที่สร้างใบคำสั่งซื้อนี้ |
updated_at |
เวลาที่อัพเดทใบคำสั่งซื้อล่าสุด |
expired_at |
เวลาที่ใบคำสั่งซื้อนี้จะหมดอายุ |
Status ของ Application
Name | Meaning |
---|---|
INITIAL |
ข้อมูลเบื้องต้น (basic_data ) ยังไม่ครบ |
PACKAGE_REQUIRED |
ข้อมูลเบื้องต้นถูกต้องแล้ว แต่ยังไม่มี package_code หรือ มี package_code แล้ว แต่ข้อมูลใบคำสั่งซื้อที่มีไม่สามารถเลือกแพคเกจนั้นได้อีก |
DATA_REQUIRED |
ข้อมูลเบื้องต้นถูกต้องและเลือกแพคเกจแล้ว แต่ข้อมูลสำหรับการออกกรมธรรม์ยังไม่ถูกต้อง |
READY |
ข้อมูลครบถ้วน และเลือกแพคเกจแล้ว พร้อมสำหรับการร้องขอกรมธรรม์ |
CONFIRMING |
กำลังยืนยันใบคำสั่งซื้อ |
ONLINE_PAYMENT_PENDING |
รอการชำระเงินผ่านช่องทางออนไลน์ |
POLICY_PENDING |
กำลังรอกรมธรรม์ดาวน์โหลด |
CANCELLED |
ใบคำสั่งซื้อถูกยกเลิก |
COMPLETED |
ใบคำสั่งซื้อเสร็จสมบูรณ์ |
SUBMITTED |
กำลังรอทางบริษัทประกันภัยยืนยันและออกกรมธรรม์ให้ |
TENTATIVELY_ACCEPTED |
เกิดปัญหาจากทางบริษัทประกันภัย แต่ Acrosure ถือว่าใบคำสั่งซื้อสมบูรณ์แล้ว และจะดำเนินการต่อให้ |
EXPIRED |
ใบคำสั่งซื้อหมดอายุ |
/applications/get
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/get;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.get("appl_SAMPLE01");
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
application = acrosure_client.application.get('appl_SAMPLE01')
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject application = AcrosureClient.Application.Get("appl_SAMPLE01")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.get(id: "appl_SAMPLE01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$application = $acrosureClient->getApplicationManager()->get("appl_SAMPLE01");
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
...
}
}
เรียกดูข้อมูลใบคำขอสั่งซื้อ
HTTP Request
POST https://api.acrosure.com/applications/get
Request Body
Name | Required | Description |
---|---|---|
application_id |
Yes | รหัสของใบคำสั่งซื้อ |
/applications/list
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta"}' \
https://api.acrosure.com/applications/list;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.list({
product_id: "prod_ta"
});
import com.acrosure.Acrosure;
import com.acrosure.form.ApplicationQuery;
import com.acrosure.resource.Application;
import com.acrosure.resource.ApplicationList;
public class Main {
public static void main(String[] args) {
ApplicationQuery searchParams = new ApplicationQuery();
try {
ApplicationList applicationList = client.application().list(searchParams);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
applications = acrosure_client.application.list(searchParams)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject applications = await AcrosureClient.Application.List();
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.list() { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$applications = $acrosureClient->getApplicationManager()->getList(searchParams);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "appl_SAMPLE01",
"product_id": "prod_ta",
...
}, {
"id": "appl_SAMPLE02",
"product_id": "prod_ta",
...
}
]
}
เรียกดูรายการใบคำขอสั่งซื้อ โดยสามารถระบุเงื่อนไขเพิ่มเติมหรือไม่ก็ได้
HTTP Request
POST https://api.acrosure.com/applications/list
Request Body
Name | Required | Description | Possible Values |
---|---|---|---|
product_id |
No | ชนิดของ Product | |
offset |
No | ตำแหน่งในลำดับของใบคำสั่งซื้อที่ต้องการเริ่มดู | |
limit |
No | จำนวนสูงสุดของข้อมูลในรายการ | |
order_by |
No | วิธีการจัดเรียงรายการ | created_at , updated_at |
status |
No | สถานะของใบคำสั่งซื้อ | ดูเพิ่มเติมที่ Application Status |
query |
No | Keywords ต่างๆที่ต้องการค้นหา (โดยเป็น string อะไรก็ได้) | |
partial_match |
No | ค่าที่ระบุว่าจะค้นหา query โดย exact หรือไม่ |
true , false |
/applications/create
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta","basic_data":{"countries":["GERMANY","JAPAN"],"policy_date":"2018-12-08","expiry_date":"2018-12-15","policy_unit":"D"}}' \
https://api.acrosure.com/applications/create;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.create({
product_id: "prod_ta",
basic_data: {
countries: [
"GERMANY",
"JAPAN"
],
policy_date: "2018-12-08",
expiry_date: "2018-12-15",
policy_unit: "D"
},
});
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.form.ApplicationCreateForm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
ObjectMapper mapper = new ObjectMapper();
ObjectNode basicData = mapper.createObjectNode();
ArrayNode countries = basicData.putArray("countries");
countries.add("GERMANY");
countries.add("JAPAN");
basicData.put("policy_date", "2018-12-08");
basicData.put("expiry_date", "2018-12-15");
basicData.put("policy_unit", "D");
ApplicationCreateForm createForm = new ApplicationCreateForm();
createForm.setBasicData(basicData);
try {
Application application = client.application().create(createForm);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
created_application = acrosure_client.application.create(
productId = 'prod_ta', # required
basic_data = {},
package_options = {},
additional_data = {},
package_code = 'PACKAGE_SAMPLE_01',
attachments = []
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject createdApplication = await AcrosureClient.Application.Create(@"{
productId: 'prod_ta', // required
basic_data: {},
package_options: {},
additional_data: {},
package_code: 'PACKAGE_SAMPLE_01',
attachments: []
}")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.create(
productId: "prod_ta",
basicData: [
"countries": ["GERMANY", "JAPAN"],
"policy_date": "2018-12-08",
"expiry_date": "2018-12-15",
"policy_unit": "D",
]
) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$createdApplication = $acrosureClient->getApplicationManager()->create([
"product_id" => "prod_ta", // required
"basic_data" => json_decode('{}'),
"package_options" => json_decode('{}'),
"additional_data" => json_decode('{}'),
"package_code" => "PACKAGE_SAMPLE_01",
"attachments": => []
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
...
}
}
สร้างใบคำสั่งซื้อ โดยสามารถสร้างแบบข้อมูลไม่ครบไว้ก่อน แล้วนำไป update ในคราวหลังได้
โดยโครงสร้างข้อมูล basic_data
, package_options
, additional_data
สามารถดูรายละเอียดได้ที่ Dashboard ภายใน Product นั้นๆ
HTTP Request
POST https://api.acrosure.com/applications/create
Request Body
Name | Required | Description |
---|---|---|
product_id |
Yes | ชนิดของ Product |
basic_data |
No | ข้อมูลเบื้องต้นที่ต้องใช้ในการค้นหาแพคเกจ |
package_options |
No | ข้อมูลเพิ่มเติมที่ใช้ในการค้นหาแพคเกจ (ถ้ามี) |
additional_data |
No | ข้อมูลรายละเอียดสำหรับการออกกรมธรรม์ |
package_code |
No | รหัสแพคเกจที่ต้องการเลือกซื้อ |
ref1 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 1 |
ref2 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 2 |
ref3 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 3 |
/applications/update
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01",,"basic_data":{"countries":["GERMANY","JAPAN"],"policy_date":"2018-12-08","expiry_date":"2018-12-15","policy_unit":"D"},"package_options":null,"additional_data":{"customer_title":"MR.","customer_first_name":"MANA","customer_last_name":"MUNGMARN","company_name":"-","card_type":"I","id_card":"1489900087857","email":"developer@example.com","phone":"","insurer_list":[{"title":"MR.","first_name":"MANA","last_name":"MUNGMARN","card_type":"I","id_card":"1489900087857","birthdate":"1988-10-14","email":"developer@example.com","phone":"0812345678","nominee":"","relationship":"","address":{"address_no":"1","moo":"2","village":"VILLAGE","alley":"","lane":"LAD PRAO 4","street":"LAD PRAO","minor_district":"","subdistrict":"Chomphon","district":"Chatuchak","province":"Bangkok","postal_code":"10900"}},{"title":"MR.","first_name":"MANEE","last_name":"MUNGMARN","card_type":"I","id_card":"1682086540364","birthdate":"1988-12-31","email":"developer@example.com","phone":"0812345678","nominee":"MR. MANOCH MUNGMARN","relationship":"Brother/Sister","address":{"address_no":"1","moo":"2","village":"VILLAGE","alley":"","lane":"LAD PRAO 4","street":"LAD PRAO","minor_district":"","subdistrict":"Chomphon","district":"Chatuchak","province":"Bangkok","postal_code":"10900"}}]}}' \
https://api.acrosure.com/applications/update;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.update({
application_id: 'appl_SAMPLE01',
basic_data: {
countries: [
"GERMANY",
"JAPAN"
],
policy_date: "2018-12-08",
expiry_date: "2018-12-15",
policy_unit: "D"
},
package_options: null,
additional_data: {
...
}
});
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.form.ApplicationCreateForm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>")
ObjectMapper mapper = new ObjectMapper();
ObjectNode basicData = mapper.createObjectNode();
ArrayNode countries = basicData.putArray("countries");
countries.add("GERMANY");
countries.add("JAPAN");
basicData.put("policy_date", "2018-12-08");
basicData.put("expiry_date", "2018-12-15");
basicData.put("policy_unit", "D");
try {
Application application = client.application().get("appl_SAMPLE01");
application.setBasicData(basicData);
client.application().update(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
updatedApplication = acrosure_client.application.update(
application_id = 'appl_SAMPLE01', # required
basic_data = {},
package_options = {},
additional_data = {},
package_code = 'PACKAGE_SAMPLE_01',
attachments = []
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject updatedApplication = await AcrosureClient.Application.Update(@"{
application_id: 'appl_SAMPLE01', // required
basic_data: {},
package_options: {},
additional_data: {},
package_code: 'PACKAGE_SAMPLE_01',
attachments: []
}")
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.update(
id: "appl_SAMPLE01",
basicData: [
"countries": ["GERMANY", "JAPAN"],
"policy_date": "2018-12-08",
"expiry_date": "2018-12-15",
"policy_unit": "D",
],
additionalData, ...
) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$updatedApplication = $acrosureClient->getApplicationManager()->update([
"application_id" => "appl_SAMPLE01", // required
"basic_data": json_decode('{}'),
"package_options": json_decode('{}'),
"additional_data": json_decode('{}'),
"package_code": "PACKAGE_SAMPLE_01",
"attachments": []
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
...
}
}
อัพเดทใบคำสั่งซื้อ โดยสามารถอัพเดทแบบข้อมูลไม่ครบเพื่อเป็นการบันทึกไว้ก่อน แล้วนำไป update ในคราวหลังได้
โดยโครงสร้างข้อมูล basic_data
, package_options
, additional_data
สามารถดูรายละเอียดได้ที่ Dashboard ภายใน Product นั้นๆ
HTTP Request
POST https://api.acrosure.com/applications/update
Request Body
Name | Required | Description |
---|---|---|
basic_data |
No | ข้อมูลเบื้องต้นที่ต้องใช้ในการค้นหาแพคเกจ |
package_options |
No | ข้อมูลเพิ่มเติมที่ใช้ในการค้นหาแพคเกจ (ถ้ามี) |
additional_data |
No | ข้อมูลรายละเอียดสำหรับการออกกรมธรรม์ |
ref1 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 1 |
ref2 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 2 |
ref3 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 3 |
/applications/get-packages
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/get-packages;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.getPackages('appl_SAMPLE01');
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Package;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Package[] packages = client.application().getPackages(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
packages = acrosure_client.application.get_packages(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject packages = await AcrosureClient.Application.GetPackages(
"appl_SAMPLE01"
)
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.getPackages(id: "appl_SAMPLE01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$packages = $acrosureClient->getApplicationManager()->getPackages("appl_SAMPLE01");
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"package_code": "PACKAGE_SAMPLE_01",
...
}, {
"package_code": "PACKAGE_SAMPLE_02",
...
}
]
}
เรียกดูแพคเกจทั้งหมดที่ใบคำสั่งซื้อนั้นสามารถซื้อได้
HTTP Request
POST https://api.acrosure.com/applications/get-packages
Request Body
Name | Required | Description |
---|---|---|
application_id |
Yes | หมายเลขใบคำสั่งซื้อ |
/applications/get-package
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/get-package;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.getPackage('appl_SAMPLE01');
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Package;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Package aPackage = client.application().getPackage(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
current_package = acrosure_client.application.get_package(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject currentPackage = await AcrosureClient.Application.GetPackage(
"appl_SAMPLE01"
);
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.getPackage(id: "appl_SAMPLE01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$currentPackage = $acrosureClient->getApplicationManager()->getPackage(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"package_code": "PACKAGE_SAMPLE_01",
...
}
}
ดูแพคเกจที่ใบคำสั่งซื้อนั้นเลือกอยู่
HTTP Request
POST https://api.acrosure.com/applications/get-package
Request Body
Name | Required | Description |
---|---|---|
application_id |
Yes | หมายเลขใบคำสั่งซื้อ |
/applications/select-package
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01","package_code":"PACKAGE_SAMPLE_01"}' \
https://api.acrosure.com/applications/select-package;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.selectPackage({
application_id: 'appl_SAMPLE01',
package_code: 'PACKAGE_SAMPLE_01'
});
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Package;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Package[] packages = client.application().getPackages(application);
client.application().selectPackage(application, packages[0]);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
updated_application = acrosure_client.application.select_package(
application_id = 'appl_SAMPLE01',
package_code = 'PACKAGE_SAMPLE_01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject updatedApplication = await AcrosureClient.Application.selectPackage({
application_id: "appl_SAMPLE01",
package_code: "PACKAGE_SAMPLE_01"
});
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.selectPackage(id: "appl_SAMPLE01", packageCode: "PACKAGE_SAMPLE_01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$updatedApplication = $acrosureClient->getApplicationManager()->selectPackage([
"application_id" => "appl_SAMPLE01",
"package_code" => "PACKAGE_SAMPLE_01"
]);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
"package_code": "PACKAGE_SAMPLE_01"
...
}
}
เลือกแพคเกจสำหรับใบคำสั่งซื้อ
HTTP Request
POST https://api.acrosure.com/applications/select-package
Request Body
Name | Required | Description |
---|---|---|
application_id |
Yes | หมายเลขใบคำสั่งซื้อ |
package_code |
Yes | หมายเลขแพคเกจ |
/applications/submit
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/submit;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.application.submit('appl_SAMPLE01');
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
client.application().submit(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
submitted_application = acrosure_client.application.submit(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject submittedApplication = await AcrosureClient.Application.Submit(
"appl_SAMPLE01"
);
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.application.submit(id: "appl_SAMPLE01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$submittedApplication = $acrosureClient->getApplicationManager()->submit(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "appl_SAMPLE01",
"status": "SUBMITTED",
...
}
}
ส่งคำขอไปยังบริษัทประกันภัย เพื่อขอคำยืนยันการสั่งซื้อและให้ทางบริษัทออกกรมธรรม์
HTTP Request
POST https://api.acrosure.com/applications/submit
Request Body
Name | Required | Description |
---|---|---|
application_id |
Yes | หมายเลขใบคำสั่งซื้อ |
/applications/confirm
curl -X POST \
--header "Authorization: Bearer <YOUR_SECRET_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"application_id":"appl_SAMPLE01"}' \
https://api.acrosure.com/applications/confirm;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_SECRET_TOKEN>" });
const response = await client.application.confirm('appl_SAMPLE01');
import com.acrosure.Acrosure;
import com.acrosure.resource.Application;
import com.acrosure.resource.Policy;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_SECRET_TOKEN>");
try {
Application application = client.application().get("appl_SAMPLE01");
Policy[] policies = client.application().confirm(application);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_SECRET_TOKEN>')
confirmed_application = acrosure_client.application.confirm(
'appl_SAMPLE01'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_SECRET_TOKEN>")
JObject confirmedApplication = await AcrosureClient.Application.Confirm(
"appl_SAMPLE01"
);
// Not supported for Client-side
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_SECRET_TOKEN>" ]);
$confirmedApplication = $acrosureClient->getApplicationManager()->confirm(
"appl_SAMPLE01"
);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "plcy_SAMPLE01",
"application_id": "appl_SAMPLE01",
...
},
{
"id": "plcy_SAMPLE02",
"application_id": "appl_SAMPLE01",
...
}
]
}
ยืนยันการสั่งซื้อ โดยจะได้กรมธรรม์ออกมา
HTTP Request
POST https://api.acrosure.com/applications/confirm
Request Body
Name | Required | Description |
---|---|---|
application_id |
Yes | หมายเลขใบคำสั่งซื้อ |
Products API reference
Product คือประกันภัย โดยประกันภัยแต่ละประเภทจะต้องการข้อมูลสำหรับออกกรมธรรม์ที่แตกต่างกัน ดูเพิ่มเติมได้ที่ Acrosure Dashboard
โครงสร้างข้อมูล Product
ตัวอย่างข้อมูล
{
"id": "prod_ta",
"name": "International Travel Insurance",
"type": "ta_international",
"insurer_product_code": "ta_international",
"form_items": [
{
"key": "countries",
"type": "ARRAY",
"label": "ประเทศที่ต้องการไป",
"required": true
},
...
],
"sample_form_data": {
"countries": [
"GERMANY",
"JAPAN"
],
...
},
"language": "EN",
"complete_process": "CONFIRM",
"is_form_available": true,
}
ข้อมูลภายใน Product ที่ได้คืนมาจากการเรียก API ต่างๆ
Name | Meaning |
---|---|
id |
รหัสของ Product ที่ใช้อ้างอิงในที่ต่างๆ |
name |
ชื่อของประกันภัย |
type |
ประเภทของประกันภัย |
insurer_product_code |
รหัสอ้างอิงของประกันภัยนี้กับบริษัทประกันภัย |
form_items |
โครงสร้างข้อมูลของฟอร์มสำหรับ Application (ดูเพิ่มที่ Acrosure Dashboard) |
sample_form_data |
ตัวอย่างฟอร์มที่ถูกต้องของประกันภัยนั้นๆ |
language |
ภาษาของประกันภัยนั้น |
complete_process |
วิธีการยืนยันออกกรมธรรม์ของประกันภัยนั้นๆ SUBMIT : ต้องใช้ /applications/submit ในการยืนยันคำสั่งซื้อ และต้องรอทางบริษัทประกันภัยยืนยันอีกครั้ง CONFIRM : ต้องใช้ /applications/confirm ในการยืนยันคำสั่งซื้อ และจะได้รับกรมธรรม์ออนไลน์ทันที |
is_form_available |
ค่าที่บ่งบอกว่ามีฟอร์มสำเร็จรูปให้ใช้หรือไม่ |
โครงสร้างของ Form item
Form item คือข้อมูลที่อยู่ภายใน form_items
ของ Product ซึ่งจะมีรายละเอียดของฟิลด์แบบฟอร์มภายใน Application อยู่
Name | Meaning |
---|---|
key |
ชื่อฟิลด์ที่ต้องใช้ส่งไปใน Request Body |
type |
ประเภทข้อมูลภายในฟิลด์ |
label |
คำอธิบายของฟิลด์ |
required |
ค่าที่บอกว่าฟิลด์นี้จำเป็นต้องกรอกหรือไม่ |
handler |
ค่าที่สามารถนำไปอ้างอิงใช้ในการเรียก API /data/get เพื่อดูค่าที่เป็นไปได้ของฟิลด์นี้ |
values |
ค่าที่เป็นไปได้ของฟิลด์นี้ (ถ้ามีกำหนด) |
fields |
ฟิลด์ภายใน (ถ้ามี) |
/products/get
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta"}' \
https://api.acrosure.com/products/get;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.product.get('prod_ta');
import com.acrosure.Acrosure;
import com.acrosure.resource.Product;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Product product = client.product().get("prod_ta");
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
product = acrosure_client.product.get('prod_ta')
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject product = await AcrosureClient.Product.Get("prod_ta");
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.product.get(id: "prod_ta") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$product = $acrosureClient->getProductManager()->get("prod_ta");
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "prod_ta",
...
}
}
เรียกดูข้อมูลประกันภัย และแบบฟอร์มของประกันภัยนั้นๆ
HTTP Request
POST https://api.acrosure.com/products/get
Request Body
Name | Required | Description |
---|---|---|
product_id |
Yes | รหัสประกันภัย |
/products/list
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '' \
https://api.acrosure.com/products/list;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.product.list();
import com.acrosure.Acrosure;
import com.acrosure.resource.Product;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Product[] products = client.product().list();
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
products = acrosure_client.product.list()
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject products = await AcrosureClient.Product.List();
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.product.list() { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$products = $acrosureClient->getProductManager()->getList();
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "prod_ta",
...
}, {
"id": "prod_motor",
...
}
]
}
เรียกดูรายการประกันภัย ที่ทีมของคุณสามารถใช้งานได้
HTTP Request
POST https://api.acrosure.com/products/list
Request Body
None
Policies API reference
Policy คือกรมธรรม์ที่ได้ร้องขอไปทางบริษัทประกันภัย
โครงสร้างข้อมูล Policy
ตัวอย่างข้อมูล
{
"id": "plcy_SAMPLE01",
"effective_date": "2018-09-14T00:00:00Z",
"expiry_date": "2018-09-28T00:00:00Z",
"insurer_policy_code": "10001-101-100000001",
"insurer_policy_url": "SAMPLE_INSURER_POLICY_URL",
"policy_url": "SAMPLE_POLICY_URL",
"amount": 1120.23,
"amount_with_tax": 1204,
"status": "COMPLETED",
"insurer_id": "Q100000000000001",
"first_name": "MANA",
"last_name": "MUNGMUN",
"email": "user@domain.com",
"telephone": "0810000001",
"download_at": "2018-09-14T11:39:34.445916Z",
"created_at": "2018-09-14T11:38:33.600693Z",
"confirmed_at": null,
"application_id": "appl_SAMPLE01",
"team_id": "team_sample",
"user_id": "user_sample_partner",
"product_id": "prod_ta",
"form_data": {
...
},
"source": "PARTNER",
"team_name": "Sample Team",
"signed_policy_url": "https://storage.googleapis.com/acrosure-policy/sandbox/SAMPLE_SIGNED_URL",
"application_no": "AP00010000001"
}
ข้อมูลภายใน Policy ที่ได้คืนมาจากการเรียก API ต่างๆ
Name | Meaning |
---|---|
id |
รหัสของ Policy ที่ใช้อ้างอิงในที่ต่างๆ |
effective_date |
วันที่เอาประกัน |
expiry_date |
วันที่สิ้นสุดการเอาประกัน |
insurer_policy_code |
รหัสอ้างอิงกับทางบริษัทประกันภัย |
insurer_policy_url |
URL ไฟล์กรมธรรม์ของบริษัทประกันภัย |
policy_url |
URL ไฟล์กรมธรรม์ที่ Acrosure เก็บไว้ (ไม่สามารถเรียกดู URL นี้ตรงๆได้ ต้องผ่านการ Sign ก่อน ซึ่งจะอยู่ในฟิลด์ signed_policy_url ) |
signed_policy_url |
URL ไฟล์กรมธรรม์ที่สามารถดูได้ |
net_premium |
ค่าเบี้ยประกันเบื้องต้น |
gross_premium |
ค่าเบี้ยประกันสุทธิ |
vat |
ค่า VAT |
duty |
ค่าภาษีอากร |
status |
สถานะของไฟล์กรมธรรม์ ดูเพิ่มเติมได้ที่ Policy Status |
insurer_id |
รหัสอ้างอิงบริษัทประกันภัย |
first_name |
ชื่อจริงของผู้ซื้อ |
last_name |
นามสกุลของผู้ซื้อ |
email |
อีเมล์ของผู้ซื้อ |
telephone |
เบอร์โทรศัพท์ของผู้ซื้อ |
application_id |
รหัสใบคำสั่งซื้อ |
team_id |
รหัสทีม |
team_name |
ชื่อทีม |
user_id |
รหัสผู้ใช้ที่สร้าง |
product_id |
รหัสประกันภัย |
basic_data |
ข้อมูลเบื้องต้นที่ต้องใช้ในการค้นหาแพคเกจ |
package_options |
ข้อมูลเพิ่มเติมที่ใช้ในการค้นหาแพคเกจ |
additional_data |
ข้อมูลรายละเอียดสำหรับการออกกรมธรรม์ |
package_code |
รหัสแพคเกจที่เลือก |
downloaded_at |
เวลาที่ดาวน์โหลดไฟล์เสร็จสมบูรณ์ |
confirmed_at |
เวลาที่ยืนยันการซื้อกรมธรรม์ |
created_at |
เวลาที่สร้างกรมธรรม์นี้ |
updated_at |
เวลาที่อัพเดทกรมธรรม์ล่าสุด |
error_message |
ข้อความบอก Error (ถ้ามี) |
Status ของ Policy
Name | Meaning |
---|---|
COMPLETED |
ดาวน์โหลดไฟล์เรียบร้อยแล้ว |
INSURER_COMPLETED |
ส่งข้อมูลให้กับบริษัทประกันภัยเรียบร้อยแล้ว กำลังดาวน์โหลด |
CANCELED |
กรมธรรม์ถูกยกเลิก |
/policies/get
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta"}' \
https://api.acrosure.com/policies/get;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.policy.get('plcy_SAMPLE01');
import com.acrosure.Acrosure;
import com.acrosure.resource.Policy;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Policy policy = client.policy().get("plcy_SAMPLE01");
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
policy = acrosure_client.policy.get('plcy_SAMPLE01')
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject policy = await AcrosureClient.policy.Get("plcy_SAMPLE01");
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.policy.get(id: "plcy_SAMPLE01") { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$policy = $acrosureClient->getPolicyManager()->get("plcy_SAMPLE01");
ตัวอย่าง Response Body
{
"status": "ok",
"data": {
"id": "prod_ta",
...
}
}
เรียกดูข้อมูลกรมธรรม์
HTTP Request
POST https://api.acrosure.com/policies/get
Request Body
Name | Required | Description |
---|---|---|
policy_id |
Yes | รหัสกรมธรรม์ในระบบ |
/policies/list
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"product_id":"prod_ta"}' \
https://api.acrosure.com/policies/list;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.policy.list({
product_id: "prod_ta"
});
import com.acrosure.Acrosure;
import com.acrosure.resource.PolicyList;
import com.acrosure.form.PolicyQuery;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
PolicyQuery searchParams = new PolicyQuery();
PolicyList policyList = client.policy().list(searchParams);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
policies = acrosure_client.policy.list(searchParams)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject policies = await AcrosureClient.policy.List();
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.policy.list(query: ["product_id": "prod_ta"]) { response in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$policies = $acrosureClient->getPolicyManager()->getList(searchParams);
ตัวอย่าง Response Body
{
"status": "ok",
"data": [
{
"id": "plcy_SAMPLE01",
...
}, {
"id": "plcy_SAMPLE02",
...
}
]
}
เรียกดูรายการกรมธรรม์
HTTP Request
POST https://api.acrosure.com/policies/list
Request Body
Name | Required | Description | Possible Values |
---|---|---|---|
product_id |
No | ชนิดของ Product | |
first_name |
No | ชื่อจริงของผู้ซื้อ | |
last_name |
No | นามสกุลของผู้ซื้อ | |
email |
No | อีเมล์ของผู้ซื้อ | |
telephone |
No | เบอร์โทรศัพท์ของผู้ซื้อ | |
offset |
No | ตำแหน่งในลำดับของกรมธรรม์ที่ต้องการเริ่มดู | |
limit |
No | จำนวนสูงสุดของข้อมูลในรายการ | |
order_by |
No | วิธีการจัดเรียงรายการ | created_at , updated_at |
status |
No | สถานะของกรมธรรม์ | ดูเพิ่มเติมที่ Policy Status |
basic_data |
No | ข้อมูลเบื้องต้นของใบคำสั่งซื้อ | เป็น String |
package_options |
No | ข้อมูลเพิ่มเติมในการค้นหาแพคเกจของใบคำสั่งซื้อ | เป็น String |
additional_data |
No | ข้อมูลสำหรับการออกกรมธรรม์ของใบคำสั่งซื้อ | เป็น String |
ref1 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 1 | |
ref2 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 2 | |
ref3 |
No | ข้อความสำหรับใช้ในการอ้างอิงอันที่ 3 | |
insurer_policy_code |
No | รหัสอ้างอิงกับทางบริษัทประกันภัย | |
start_created_date |
No | วันเริ่มต้น ของช่วงวันที่สร้างกรมธรรม์ | |
end_created_date |
No | วันสิ้นสุด ของช่วงวันที่สร้างกรมธรรม์ | |
start_effective_date |
No | วันเริ่มต้น ของช่วงวันที่เริ่มคุ้มครอง | |
end_effective_date |
No | วันสิ้นสุด ของช่วงวันที่เริ่มคุ้มครอง | |
start_expiry_date |
No | วันเริ่มต้น ของช่วงวันที่สิ้นสุดความคุ้มครอง | |
end_expiry_date |
No | วันสิ้นสุด ของช่วงวันที่สิ้นสุดความคุ้มครอง | |
query |
No | คำสั่ง Query |
Data API reference
ใช้ในการจัดการข้อมูลอื่นๆ เช่น ดูค่าที่เป็นไปได้ของแต่ละฟิลด์ในฟอร์ม
/data/get
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
-d '{"handler":"subdistrict","dependencies":["กรุงเทพมหานคร","วังทองหลาง"]}' \
https://api.acrosure.com/data/get;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.data.get({
handler: "subdistrict",
dependencies: ["กรุงเทพมหานคร", "วังทองหลาง"]
});
import com.acrosure.Acrosure;
import com.acrosure.form.DataGetform;
import com.acrosure.resource.Data;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
DataGetForm<String> form = new DataGetForm<>();
form.setHandler("subdistrict");
String[] dependencies = {"กรุงเทพมหานคร", "วังทองหลาง"};
form.setDependencies(dependencies);
try {
Data[] data = client.data().get(form);
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
values = acrosure_client.data.get(
handler = '<some_handler>'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject values = await AcrosureClient.Data.Get(@"{
handler: '<some_handler>',
dependencies: ['<dependency_1>', '<dependency_2>']
}");
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.data.get(handler: "subdistrict", dependencies:["กรุงเทพมหานคร","วังทองหลาง"]) { resp in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$values = $acrosureClient->getDataManager()->get([
"handler" => "<some_handler>"
]);
ตัวอย่าง Response Body
{
"status":"ok",
"data":[
{
"value":"คลองเจ้าคุณสิงห์",
"label":"คลองเจ้าคุณสิงห์"
},
{
"value":"พลับพลา",
"label":"พลับพลา"
},
{
"value":"วังทองหลาง",
"label":"วังทองหลาง"
},
{
"value":"สะพานสอง",
"label":"สะพานสอง"
}
]
}
เรียกดูค่าที่เป็นไปได้ของฟิลด์ที่ใช้ Handler นั้นๆ
HTTP Request
POST https://api.acrosure.com/data/get
Request Body
Name | Required | Description |
---|---|---|
handler |
Yes | ชื่อ Handler |
dependencies |
No (แต่ Yes สำหรับ Handler ที่มี Dependencies) | ค่าที่ต้องการในการเป็นเงื่อนไขการดึงข้อมูล |
รายการ Handlers
รายชื่อ handlers ต่างๆ
Name | Dependencies | Description |
---|---|---|
province |
None | จังหวัด (ภาษาไทย) |
district |
เขต/อำเภอ (ภาษาไทย) | |
subdistrict |
แขวง/ตำบล (ภาษาไทย) | |
postal_code |
รหัสไปรษณีย์ (ภาษาไทย) | |
province_en |
None | จังหวัด (ภาษาอังกฤษ) |
district_en |
เขต/อำเภอ (ภาษาอังกฤษ) | |
subdistrict_en |
แขวง/ตำบล (ภาษาอังกฤษ) | |
postal_code_en |
รหัสไปรษณีย์ (ภาษาอังกฤษ) | |
country |
None | ประเทศ (ภาษาไทย) |
country_en |
None | ประเทศ (ภาษาอังกฤษ) |
id_card_type |
None | ประเภทของบัตร |
person_type |
None | ประเภทบุคคล |
organization_type |
None | ประเภทบริษัท |
customer_type |
None | ประเภทลูกค้า |
person_title |
None | คำนำหน้าชื่อ (ภาษาไทย) |
person_title_en |
None | คำนำหน้าชื่อ (ภาษาอังกฤษ) |
nominee_relationship |
None | ความสัมพันธ์ของผู้รับผลประโยชน์ (ภาษาไทย) |
nominee_relationship_en |
None | ความสัมพันธ์ของผู้รับผลประโยชน์ (ภาษาอังกฤษ) |
travel_policy_type |
None | ประเภทของประกันเดินทาง |
travel_policy_unit |
None | ประเภทการเดินทาง |
building_material |
None | วัสดุอาคาร |
building_type |
None | ประเภทอาคาร |
building_roof_structure |
None | โครงสร้างหลังคาของอาคาร |
building_roof_type |
None | ประเภทหลังคาของอาคาร |
building_second_floor_type |
None | ประเภทชั้นสองของอาคาร |
voluntary_motor_insurance_class |
None | ชั้นประกันรถยนต์ |
voluntary_motor_insurance_type |
None | ประเภทรถยนต์ |
motor_brand |
ยี่ห้อรถยนต์ | |
motor_model |
รุ่นรถยนต์ | |
model_spec |
รุ่นย่อยรถยนต์ | |
repair_provider_type |
None | ประเภทการซ่อมรถยนต์ |
motor_gear_type |
None | ประเภทเกียร์รถยนต์ |
Team API reference
ใช้ในการจัดการข้อมูลทีม
โครงสร้างข้อมูล Team
ตัวอย่างข้อมูล
{
"id": "team_sample",
"company_name": "Sample Team",
"callback_url": "https://www.example.com",
"logo_file": {
"title": "",
"url": "https://storage.googleapis.com/SAMPLE_URL",
"signed_url": "https://storage.googleapis.com/SAMPLE_SIGNED_URL"
},
"users": [
{
"id": "user_SAMPLE01",
"email": "user01@example.com",
"first_name_th": "Sample",
"last_name_th": "Partner",
"role": "partner.admin"
}
]
}
ข้อมูลภายใน Team ที่ได้คืนมาจากการเรียก API ต่างๆ
Name | Meaning |
---|---|
id |
รหัสของ Team ที่ใช้อ้างอิงในที่ต่างๆ |
company_name |
ชื่อทีม |
callback_url |
URL สำหรับการ Redirect กลับของฟอร์มสำเร็จรูป |
logo_file |
ไฟล์โลโก้ของทีม |
users |
รายชื่อสมาชิกทีม |
/teams/get-info
curl -X POST \
--header "Authorization: Bearer <YOUR_PUBLIC_TOKEN>" \
--header "Content-Type: application/json" \
https://api.acrosure.com/teams/get-info;
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_PUBLIC_TOKEN>" });
const response = await client.teams.getInfo();
import com.acrosure.Acrosure;
import com.acrosure.resource.Team;
public class Main {
public static void main(String[] args) {
Acrosure client = new Acrosure("<YOUR_PUBLIC_TOKEN>");
try {
Team team = client.team().getInfo();
} catch (IOException e) {
e.printStackTrace();
} catch (AcrosureException e) {
System.out.println(e.getMessage() + ", " + e.getStatusCode());
e.printStackTrace();
}
}
}
acrosure_client = AcrosureClient(token = '<YOUR_PUBLIC_TOKEN>')
team_info = acrosure_client.team.get_info()
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_PUBLIC_TOKEN>")
JObject teamInfo = await AcrosureClient.Team.getInfo();
let client = AcrosureClient(token: "<YOUR_PUBLIC_TOKEN>")
client.team.getInfo { resp in
// ...
}
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_PUBLIC_TOKEN>" ]);
$teamInfo = $acrosureClient->getTeamManager()->getInfo();
ตัวอย่าง Response Body
{
"data": {
"id": "team_sample",
"company_name": "Sample Team",
"callback_url": "https://www.example.com",
"enable_production": true,
"is_insurer": false,
"agent_code": "SAMPLE",
"policy_exposed": false,
"form_data_exposed": false,
"logo_file": {
"title": "",
"url": "https://storage.googleapis.com/SAMPLE_URL",
"signed_url": "https://storage.googleapis.com/SAMPLE_SIGNED_URL"
},
"users": [
{
"id": "user_SAMPLE01",
"email": "user01@example.com",
"first_name_th": "Sample",
"last_name_th": "Partner",
"role": "partner.admin"
}
]
},
"status": "ok"
}
เรียกดูข้อมูลของทีมของคุณ
HTTP Request
POST https://api.acrosure.com/teams/get-info
Request Body
None
ระบบแจ้งเตือนด้วย Webhook
ระบบแจ้งเตือนเป็นระบบที่ใช้สำหรับการแจ้งเตือนลูกค้าในกรณีที่เกิดเหตุการณ์ต่างๆ โดยระบบรองรับการแจ้งเตือนด้วย Webhook API เพื่อให้นักพัฒนาของบริษัท Partner ไปทำการพัฒนาระบบต่อ
นักพัฒนาจะต้องแจ้ง webhook URL ให้แก่ระบบ โดยเมื่อมีเหตุการณ์แจ้งเตือนเกิดขึ้น ระบบจะทำการส่ง POST Request ไปยัง webhook URL ที่นักพัฒนาได้แจ้งไว้
โครงสร้าง Request ของ Webhook
Request Header
Name | Meaning |
---|---|
Acrosure-Signature |
ข้อความที่ผ่านกระบวนการแฮชด้วยฟังก์ชัน HMAC โดยใช้ Secret Token เป็นกุญแจแฮช |
ตัวอย่าง Request Body
{
"event_type": "RENEW_AVAILABLE",
"policy_id": "plcy_SAMPLE01",
"expiry_date": "2018-09-28T00:00:00Z",
"premium": {
"net_premium": 1000,
"gross_premium": 4,
"vat": 70.28,
"duty": 1074.28
}
}
วิธีการตรวจสอบ Signature ว่ามาจาก Acrosure จริงหรือไม่ สามารถทำได้ดังนี้
echo -n '<raw_data>' | openssl dgst -sha256 -hmac "<YOUR_SECRET_TOKEN>"
import AcrosureClient from "@acrosure/js-sdk";
const client = new AcrosureClient({ token: "<YOUR_SECRET_TOKEN>" });
const isSignatureValid = client.verifySignature(
'<signature>',
'<raw_data>'
)
Acrosure client = new Acrosure("<YOUR_SECRET_TOKEN>");
Bool isSignatureValid = client.verifySignature("<signature>", "<raw_data>"));
acrosure_client = AcrosureClient(token = '<YOUR_SECRET_TOKEN>')
is_signature_valid = acrosure_client.verify_webhook(
signature = '<signature>',
data = '<raw_data>'
)
AcrosureClient AcrosureClient = new AcrosureClient("<YOUR_SECRET_TOKEN>")
bool isSignatureValid = AcrosureClient.verifySignature(
"<signature>",
@"{'data':'<raw_data>'}"
);
// Not supported for Client-side
$acrosureClient = new AcrosureClient([ "token" => "<YOUR_SECRET_TOKEN>" ]);
$isSignatureValid = $acrosureClient->verifySignature(
"<signature>",
"<raw_data>"
);
Request Body
Name | Meaning |
---|---|
event_type |
ประเภทของ Event |
policy_id |
รหัสกรมธรรม์ในระบบ |
expiry_date |
วันที่สิ้นสุดการรับประกัน |
premium |
ค่าเบี้ยประกัน(ปรากฎในกรณี Event ประเภท RENEW_AVAILABLE ) |
ประเภทของ Event
Event | Meaning |
---|---|
NEAR_EXPIRY_7 |
policy ที่ถูกกล่าวถึงใน event กำลังจะหมดอายุในอีก 7 วัน |
NEAR_EXPIRY_3 |
policy ที่ถูกกล่าวถึงใน event กำลังจะหมดอายุในอีก 3 วัน |
EXPIRY |
policy ที่ถูกกล่าวถึงใน event ได้หมดอายุแล้ว |
RENEW_AVAILABLE |
policy ที่ถูกกล่าวถึงใน event สามารถทำการต่ออายุได้ โดยมีรายละเอียเพิ่มเติมมากับ event |
โครงสร้างของ Premium
Name | Meaning |
---|---|
net_premium |
เบี้ยประกันสุทธิ |
gross_premium |
ค่าเบี้ยประกันรวมภาษีอากร |
vat |
ภาษีมูลค่าเพิ่ม |
duty |
ภาษีอากรสแตมป์ |