Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "criteria": {
// "overrideInsufficientCC": false,
// "applyCCSurcharge": false,
// "vATOffset": false,
// "reservationId": {
// "idContext": "OPERA",
// "id": 123,
// "type": "Reservation"
// },
// "paymentMethod": {
// "paymentMethod": "CA"
// },
// "postingReference": "CA Posting - Window 1",
// "postingAmount": {
// "amount": 175,
// "currencyCode": "USD"
// },
// "cashierId": 3,
// "hotelId": "{{HotelId}}",
// "folioWindowNo": "1",
// "overrideARCreditLimit": false
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateBool(json,L"criteria.overrideInsufficientCC",FALSE);
CkJsonObjectW_UpdateBool(json,L"criteria.applyCCSurcharge",FALSE);
CkJsonObjectW_UpdateBool(json,L"criteria.vATOffset",FALSE);
CkJsonObjectW_UpdateString(json,L"criteria.reservationId.idContext",L"OPERA");
CkJsonObjectW_UpdateInt(json,L"criteria.reservationId.id",123);
CkJsonObjectW_UpdateString(json,L"criteria.reservationId.type",L"Reservation");
CkJsonObjectW_UpdateString(json,L"criteria.paymentMethod.paymentMethod",L"CA");
CkJsonObjectW_UpdateString(json,L"criteria.postingReference",L"CA Posting - Window 1");
CkJsonObjectW_UpdateInt(json,L"criteria.postingAmount.amount",175);
CkJsonObjectW_UpdateString(json,L"criteria.postingAmount.currencyCode",L"USD");
CkJsonObjectW_UpdateInt(json,L"criteria.cashierId",3);
CkJsonObjectW_UpdateString(json,L"criteria.hotelId",L"{{HotelId}}");
CkJsonObjectW_UpdateString(json,L"criteria.folioWindowNo",L"1");
CkJsonObjectW_UpdateBool(json,L"criteria.overrideARCreditLimit",FALSE);
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
CkHttpW_SetRequestHeader(http,L"x-hotelid",L"{{HotelId}}");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
CkHttpW_SetRequestHeader(http,L"x-app-key",L"{{AppKey}}");
resp = CkHttpW_PostJson3(http,L"https://domain.com/csh/v0/hotels/{{HotelId}}/reservations/{{ReservationId}}/payments",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "x-hotelid: {{HotelId}}"
-H "x-app-key: {{AppKey}}"
-d '{
"criteria": {
"overrideInsufficientCC": false,
"applyCCSurcharge": false,
"vATOffset": false,
"reservationId": {
"idContext": "OPERA",
"id": {{ReservationId}},
"type": "Reservation"
},
"paymentMethod": {
"paymentMethod": "CA"
},
"postingReference": "CA Posting - Window 1",
"postingAmount": {
"amount": 175,
"currencyCode": "USD"
},
"cashierId": 3,
"hotelId": "{{HotelId}}",
"folioWindowNo": "1",
"overrideARCreditLimit": false
}
}'
https://domain.com/csh/v0/hotels/{{HotelId}}/reservations/{{ReservationId}}/payments
Postman Collection Item JSON
{
"name": "17. Check-Out - postBillingPayment",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "x-hotelid",
"type": "text",
"value": "{{HotelId}}"
},
{
"key": "x-app-key",
"value": "{{AppKey}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"criteria\": {\r\n \"overrideInsufficientCC\": false,\r\n \"applyCCSurcharge\": false,\r\n \"vATOffset\": false,\r\n \"reservationId\": {\r\n \"idContext\": \"OPERA\",\r\n \"id\": {{ReservationId}},\r\n \"type\": \"Reservation\"\r\n },\r\n \"paymentMethod\": {\r\n \"paymentMethod\": \"CA\"\r\n },\r\n \"postingReference\": \"CA Posting - Window 1\",\r\n \"postingAmount\": {\r\n \"amount\": 175,\r\n \"currencyCode\": \"USD\"\r\n },\r\n \"cashierId\": 3,\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"folioWindowNo\": \"1\",\r\n \"overrideARCreditLimit\": false\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HostName}}/csh/v0/hotels/{{HotelId}}/reservations/{{ReservationId}}/payments",
"host": [
"{{HostName}}"
],
"path": [
"csh",
"v0",
"hotels",
"{{HotelId}}",
"reservations",
"{{ReservationId}}",
"payments"
]
}
},
"response": [
]
}