支付
列出酒店在线预订接受的支付方式,并根据所选方式启动支付步骤。各支付方式的处理方法见支付流程指南。
GET
/external/online/payment/type列出支付方式GET/external/payment/company虚拟 POS 信息POST/external/online/payment/type/{paymentType}启动支付步骤列出支付方式#
GET
/external/online/payment/type身份验证: Authorization: Bearer
返回酒店为在线销售启用的支付方式。固定的方式 ID:1 到店付款,3 银行转账,9 信用卡(卡信息随预订一并发送),10 在线支付(虚拟 POS)。
查询参数
hotelIDinteger必填酒店 ID。
响应
200 成功。
curl "https://test.hms.gen.tr/external/online/payment/type?hotelID=1000" \
-H "Authorization: Bearer $HMS_TOKEN"const res = await fetch("https://test.hms.gen.tr/external/online/payment/type?hotelID=1000", {
headers: {
"Authorization": `Bearer ${process.env.HMS_TOKEN}`
}
});
const data = await res.json();$ch = curl_init('https://test.hms.gen.tr/external/online/payment/type?hotelID=1000');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('HMS_TOKEN'),
],
]);
$data = json_decode(curl_exec($ch), true);{
"success": true,
"count": 3,
"items": [
{
"title": "到店付款",
"title_translate": "odeme.otelde_odeme",
"typeID": 1
},
{
"title": "银行转账",
"title_translate": "odeme.havale",
"typeID": 3
},
{
"title": "信用卡在线支付",
"title_translate": "odeme.online_odeme",
"typeID": 10
}
]
}虚拟 POS 信息#
GET
/external/payment/company身份验证: Authorization: Bearer
返回酒店的虚拟 POS 服务商和商户信息。仅在您自行直接对接服务商时才需要;标准流程使用 POST …/payment/type/10 即可。响应包含机密信息,请仅在服务端使用。
查询参数
hotelIDinteger必填酒店 ID。
响应
200 成功。
错误响应
- 200
hotel_company_info_could_not_found— 酒店未配置虚拟 POS。
curl "https://test.hms.gen.tr/external/payment/company?hotelID=1000" \
-H "Authorization: Bearer $HMS_TOKEN"const res = await fetch("https://test.hms.gen.tr/external/payment/company?hotelID=1000", {
headers: {
"Authorization": `Bearer ${process.env.HMS_TOKEN}`
}
});
const data = await res.json();$ch = curl_init('https://test.hms.gen.tr/external/payment/company?hotelID=1000');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('HMS_TOKEN'),
],
]);
$data = json_decode(curl_exec($ch), true);{
"success": true,
"paymentCompany": {
"merchant_id": "4000****",
"store_key": "********",
"terminal_no": "VP00****",
"user": "demo_api",
"password": "********",
"max_installment": 6,
"company_id": 3,
"company_code": "iyzico",
"company_name": "iyzico"
}
}启动支付步骤#
POST
/external/online/payment/type/{paymentType}身份验证: Authorization: Bearer · 请求体: application/json
返回所选支付方式需要执行的操作。方式 1 和 9 只需 hotelID;方式 3 返回银行账户列表;方式 10 需提供客人和购物车信息来发起支付,并将返回的 code(HTML)渲染到客人页面,由此跳转到服务商的支付页面。
路径参数
paymentTypeinteger必填支付方式 ID。
13910请求体
hotelIDinteger必填酒店 ID。
totalPricedecimal方式 10 必填。应收总金额。
orderIDstring方式 10 必填。您的订单/预订编号。
returnUrlstring方式 10 必填。客人支付完成后返回的 URL。
name / surname / email / phonestring方式 10 必填。付款人信息。
city / addressstring方式 10 必填。账单地址。
countryIDinteger方式 10 必填。国家列表中的
id。baskets[]object[]方式 10 必填,至少一项。每项包含:
id、name、piece、price。响应
200 方式 10:code 中包含一段跳转到支付服务商的 HTML 片段(视服务商而定,可能是自动提交的表单、window.location 脚本或内嵌支付表单)。请在客人浏览器中原样渲染。其他方式下,由 message 字段说明需执行的操作。
错误响应
- 200
required_input_info_not_submitted(+errors[])— 方式 10 缺少字段;country_info_sent_incorrectly—countryID无效;there_is_missing_info_in_the_shopping_cart— 购物车项缺少字段;bank_info_is_not_found— 方式 3 未配置银行账户。 - 404 未知的
paymentType。
curl -X POST "https://test.hms.gen.tr/external/online/payment/type/10" \
-H "Authorization: Bearer $HMS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"hotelID": 1000,
"totalPrice": 2330,
"orderID": "4811174883",
"returnUrl": "https://booking.example.com/payment/result",
"name": "Ayşe",
"surname": "Demir",
"email": "[email protected]",
"phone": "05551112233",
"city": "Denizli",
"address": "Kumsal Cad. No: 12",
"countryID": 1,
"baskets": [
{
"id": 2,
"name": "标准间 · 含早餐",
"piece": 1,
"price": 1930
},
{
"id": 12,
"name": "晚餐",
"piece": 1,
"price": 400
}
]
}'const res = await fetch("https://test.hms.gen.tr/external/online/payment/type/10", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.HMS_TOKEN}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"hotelID": 1000,
"totalPrice": 2330,
"orderID": "4811174883",
"returnUrl": "https://booking.example.com/payment/result",
"name": "Ayşe",
"surname": "Demir",
"email": "[email protected]",
"phone": "05551112233",
"city": "Denizli",
"address": "Kumsal Cad. No: 12",
"countryID": 1,
"baskets": [
{
"id": 2,
"name": "标准间 · 含早餐",
"piece": 1,
"price": 1930
},
{
"id": 12,
"name": "晚餐",
"piece": 1,
"price": 400
}
]
})
});
const data = await res.json();$ch = curl_init('https://test.hms.gen.tr/external/online/payment/type/10');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('HMS_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'hotelID' => 1000,
'totalPrice' => 2330,
'orderID' => '4811174883',
'returnUrl' => 'https://booking.example.com/payment/result',
'name' => 'Ayşe',
'surname' => 'Demir',
'email' => '[email protected]',
'phone' => '05551112233',
'city' => 'Denizli',
'address' => 'Kumsal Cad. No: 12',
'countryID' => 1,
'baskets' => [
[
'id' => 2,
'name' => '标准间 · 含早餐',
'piece' => 1,
'price' => 1930,
],
[
'id' => 12,
'name' => '晚餐',
'piece' => 1,
'price' => 400,
],
],
]),
]);
$data = json_decode(curl_exec($ch), true);{
"success": true,
"message": "payment_order_code",
"code": "<form method=\"post\" action=\"https://vpos.provider.example/3d\"><input type=\"hidden\" name=\"orderId\" value=\"4811174883\"> … </form><script>document.forms[0].submit()</script>"
}{
"success": true,
"message": "payment_by_bank_transfer",
"banks": [
{
"companyName": "Ziraat 银行",
"holder": "Demo Turizm A.Ş.",
"branchName": "Denizli",
"branchNumber": "0123",
"bankAccountNumber": "12345678-5001",
"iban": "TR00 0001 0001 2345 6789 5001 01"
}
]
}{
"success": true,
"message": "credit_card_info_should_be_requested"
}