delphiDll / GP-API Collection / DCC_1.1 Rate Lookup Not Available
Back to Collection Items
var
http: HCkHttp;
success: Boolean;
json: HCkJsonObject;
resp: HCkHttpResponse;
begin
// 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": "dcc",
// "model": "FROM_TRANSACTION_CURRENCY",
// "transaction_type": "SALE",
// "channel": "CNP",
// "amount": "10000",
// "currency": "EUR",
// "country": "GB",
// "reference": "TRANS-20180114123459878",
// "payment_method": {
// "name": "Jane Doe",
// "entry_mode": "ECOM",
// "card": {
// "number": "4263970000005262",
// "expiry_month": "12",
// "expiry_year": "20",
// "cvv": "233"
// }
// }
// }
json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'account_name','dcc');
CkJsonObject_UpdateString(json,'model','FROM_TRANSACTION_CURRENCY');
CkJsonObject_UpdateString(json,'transaction_type','SALE');
CkJsonObject_UpdateString(json,'channel','CNP');
CkJsonObject_UpdateString(json,'amount','10000');
CkJsonObject_UpdateString(json,'currency','EUR');
CkJsonObject_UpdateString(json,'country','GB');
CkJsonObject_UpdateString(json,'reference','TRANS-20180114123459878');
CkJsonObject_UpdateString(json,'payment_method.name','Jane Doe');
CkJsonObject_UpdateString(json,'payment_method.entry_mode','ECOM');
CkJsonObject_UpdateString(json,'payment_method.card.number','4263970000005262');
CkJsonObject_UpdateString(json,'payment_method.card.expiry_month','12');
CkJsonObject_UpdateString(json,'payment_method.card.expiry_year','20');
CkJsonObject_UpdateString(json,'payment_method.card.cvv','233');
CkHttp_SetRequestHeader(http,'Content-Type','application/json');
CkHttp_SetRequestHeader(http,'X-GP-Version','{{version}}');
// Adds the "Authorization: Bearer {{token}}" header.
CkHttp_putAuthToken(http,'{{token}}');
resp := CkHttp_PostJson3(http,'https://{{url}}/ucp/currency-conversions','application/json',json);
if (CkHttp_getLastMethodSuccess(http) = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
Memo1.Lines.Add(IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "X-GP-Version: {{version}}"
-H "Authorization: Bearer {{token}}"
-d '{
"account_name": "dcc",
"model": "FROM_TRANSACTION_CURRENCY",
"transaction_type": "SALE",
"channel": "CNP",
"amount": "10000",
"currency": "EUR",
"country": "GB",
"reference": "TRANS-20180114123459878",
"payment_method": {
"name": "Jane Doe",
"entry_mode": "ECOM",
"card": {
"number": "4263970000005262",
"expiry_month": "12",
"expiry_year": "20",
"cvv": "233"
}
}
}'
https://{{url}}/ucp/currency-conversions
Postman Collection Item JSON
{
"name": "DCC_1.1 Rate Lookup Not Available",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);\r",
"\r",
"postman.setEnvironmentVariable(\"ccs_id\", jsonData.id);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "X-GP-Version",
"value": "{{version}}",
"type": "text"
},
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"account_name\": \"dcc\",\r\n \"model\": \"FROM_TRANSACTION_CURRENCY\",\r\n \"transaction_type\": \"SALE\",\r\n \"channel\": \"CNP\",\r\n \"amount\": \"10000\",\r\n \"currency\": \"EUR\",\r\n \"country\": \"GB\",\r\n \"reference\": \"TRANS-20180114123459878\",\r\n \"payment_method\": {\r\n \"name\": \"Jane Doe\",\r\n \"entry_mode\": \"ECOM\",\r\n \"card\": {\r\n \"number\": \"4263970000005262\",\r\n \"expiry_month\": \"12\",\r\n \"expiry_year\": \"20\",\r\n \"cvv\": \"233\"\r\n }\r\n }\r\n}"
},
"url": {
"raw": "https://{{url}}/ucp/currency-conversions",
"protocol": "https",
"host": [
"{{url}}"
],
"path": [
"ucp",
"currency-conversions"
]
}
},
"response": [
]
}