Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkHttpResponse resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_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.
// {
// "account_name": "{{acc_name}}",
// "channel": "CP",
// "capture_mode": "LATER",
// "type": "SALE",
// "amount": "12000",
// "currency": "USD",
// "reference": "My-Sale-EMV-CHIP-1234345345",
// "country": "US",
// "payment_method": {
// "entry_mode": "CONTACTLESS_CHIP",
// "card": {
// "track": ";4761739001010036=25122011184404889?",
// "tag": "9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001"
// }
// }
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"account_name","{{acc_name}}");
CkJsonObject_UpdateString(json,"channel","CP");
CkJsonObject_UpdateString(json,"capture_mode","LATER");
CkJsonObject_UpdateString(json,"type","SALE");
CkJsonObject_UpdateString(json,"amount","12000");
CkJsonObject_UpdateString(json,"currency","USD");
CkJsonObject_UpdateString(json,"reference","My-Sale-EMV-CHIP-1234345345");
CkJsonObject_UpdateString(json,"country","US");
CkJsonObject_UpdateString(json,"payment_method.entry_mode","CONTACTLESS_CHIP");
CkJsonObject_UpdateString(json,"payment_method.card.track",";4761739001010036=25122011184404889?");
CkJsonObject_UpdateString(json,"payment_method.card.tag","9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001");
CkHttp_SetRequestHeader(http,"Content-Type","application/json");
CkHttp_SetRequestHeader(http,"X-GP-Version","{{version}}");
// Adds the "Authorization: Bearer {{token}}" header.
CkHttp_putAuthToken(http,"{{token}}");
CkHttp_SetRequestHeader(http,"Accept","application/json");
resp = CkHttp_PostJson3(http,"https://{{url}}/ucp/transactions","application/json",json);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
}
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer {{token}}"
-H "Accept: application/json"
-H "X-GP-Version: {{version}}"
-d '{
"account_name":"{{acc_name}}",
"channel": "CP",
"capture_mode": "LATER",
"type": "SALE",
"amount": "12000",
"currency": "USD",
"reference": "My-Sale-EMV-CHIP-1234345345",
"country": "US",
"payment_method": {
"entry_mode": "CONTACTLESS_CHIP",
"card": {
"track": ";4761739001010036=25122011184404889?",
"tag": "9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001"
}
}
}'
https://{{url}}/ucp/transactions
Postman Collection Item JSON
{
"name": "TRA_2.6 CP CONTACTLESS CHIP",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{token}}"
},
{
"key": "Accept",
"value": "application/json"
},
{
"key": "X-GP-Version",
"value": "{{version}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"account_name\":\"{{acc_name}}\",\n \"channel\": \"CP\",\n \"capture_mode\": \"LATER\",\n \"type\": \"SALE\",\n \"amount\": \"12000\",\n \"currency\": \"USD\",\n \"reference\": \"My-Sale-EMV-CHIP-1234345345\",\n \"country\": \"US\",\n \"payment_method\": {\n \"entry_mode\": \"CONTACTLESS_CHIP\",\n \"card\": {\n \t\n \"track\": \";4761739001010036=25122011184404889?\",\n \"tag\": \"9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001\"\n \t}\n }\n}\n"
},
"url": {
"raw": "https://{{url}}/ucp/transactions",
"protocol": "https",
"host": [
"{{url}}"
],
"path": [
"ucp",
"transactions"
]
}
},
"response": [
]
}