C / GP-API Collection / TKA_2.8 Single to Multi Use Token
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": "CNP",
// "capture_mode": "AUTO",
// "type": "SALE",
// "amount": "100",
// "currency": "USD",
// "reference": "45467761",
// "country": "US",
// "payment_method": {
// "name": "Jane",
// "entry_mode": "ECOM",
// "id": "PMT_96959619-5ef6-41b1-bfeb-fc13c4b2b359",
// "storage_model": "ALWAYS"
// }
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"account_name","{{acc_name}}");
CkJsonObject_UpdateString(json,"channel","CNP");
CkJsonObject_UpdateString(json,"capture_mode","AUTO");
CkJsonObject_UpdateString(json,"type","SALE");
CkJsonObject_UpdateString(json,"amount","100");
CkJsonObject_UpdateString(json,"currency","USD");
CkJsonObject_UpdateString(json,"reference","45467761");
CkJsonObject_UpdateString(json,"country","US");
CkJsonObject_UpdateString(json,"payment_method.name","Jane");
CkJsonObject_UpdateString(json,"payment_method.entry_mode","ECOM");
CkJsonObject_UpdateString(json,"payment_method.id","PMT_96959619-5ef6-41b1-bfeb-fc13c4b2b359");
CkJsonObject_UpdateString(json,"payment_method.storage_model","ALWAYS");
CkHttp_SetRequestHeader(http,"Content-Type","application/json");
CkHttp_SetRequestHeader(http,"X-GP-Version","2020-12-22");
// Adds the "Authorization: Bearer {{token}}" header.
CkHttp_putAuthToken(http,"{{token}}");
CkHttp_SetRequestHeader(http,"Accept","application/json");
resp = CkHttp_PostJson3(http,"https://apis.sandbox.globalpay.com/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: 2020-12-22"
-d '{
"account_name": "{{acc_name}}",
"channel": "CNP",
"capture_mode":"AUTO",
"type": "SALE",
"amount": "100",
"currency": "USD",
"reference": "45467761",
"country": "US",
"payment_method": {
"name": "Jane",
"entry_mode": "ECOM",
"id": "PMT_96959619-5ef6-41b1-bfeb-fc13c4b2b359",
"storage_model": "ALWAYS"
}
}'
https://apis.sandbox.globalpay.com/ucp/transactions
Postman Collection Item JSON
{
"name": "TKA_2.8 Single to Multi Use Token",
"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": "2020-12-22"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"account_name\": \"{{acc_name}}\",\n \"channel\": \"CNP\",\n \"capture_mode\":\"AUTO\",\n \"type\": \"SALE\",\n \"amount\": \"100\",\n \"currency\": \"USD\",\n \"reference\": \"45467761\",\n \"country\": \"US\",\n \"payment_method\": {\n \"name\": \"Jane\",\n \"entry_mode\": \"ECOM\",\n \"id\": \"PMT_96959619-5ef6-41b1-bfeb-fc13c4b2b359\",\n \"storage_model\": \"ALWAYS\"\n }\n}"
},
"url": {
"raw": "https://apis.sandbox.globalpay.com/ucp/transactions",
"protocol": "https",
"host": [
"apis",
"sandbox",
"globalpay",
"com"
],
"path": [
"ucp",
"transactions"
]
}
},
"response": [
]
}