ERROR!
------------------- GenerateCode ----------------------
ImpliedContentType: application/json
explicitContentType: application/json
---- begin chilkat script ----
// This example assumes the Chilkat API to have been previously unlocked.
// See {{-global_unlock:::Global Unlock Sample-}} for sample code.
new Http http;
ckbool success;
// Use this online tool to generate code from sample JSON: {{.https://tools.chilkat.io/jsonCreate|||Generate Code to Create JSON.}}
// The following JSON is sent in the request body.
// {
// "retref": "{{retref}}",
// "merchid": "{{merchid}}"
// }
new JsonObject json;
ignore = json.UpdateString("retref","{{retref}}");
ignore = json.UpdateString("merchid","{{merchid}}");
call http.SetRequestHeader("Authorization","Basic dGVzdGluZzp0ZXN0aW5nMTIz");
call http.SetRequestHeader("Content-Type","application/json");
new StringBuilder sbRequestBody;
call json.EmitSb(sbRequestBody);
HttpResponse resp = http.PTextSb("PUT","https://domain.com/refund",sbRequestBody,"utf-8","application/json",ckfalse,ckfalse);
if (http.LastMethodSuccess == ckfalse) {
println http.LastErrorText;
return;
}
println resp.StatusCode;
println resp.BodyStr;
delete resp;
---- end chilkat script ----
Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "retref": "{{retref}}",
// "merchid": "{{merchid}}"
// }
var json = new chilkat.JsonObject();
json.UpdateString("retref","{{retref}}");
json.UpdateString("merchid","{{merchid}}");
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
ERROR: Non-existent Chilkat method: Http.SetRequestHeader
var sbRequestBody = new chilkat.StringBuilder();
json.EmitSb(sbRequestBody);
ERROR: Entry not found: Http.PTextSb
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
--emitNewObject
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
ERROR: Non-existent Chilkat method: Http.PTextSb
// resp: HttpResponse
var resp = http.PTextSb("PUT","https://domain.com/refund",sbRequestBody,"utf-8","application/json",false,false);
ERROR: Entry not found: Http.LastMethodSuccess
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
--emitNewObject
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
if (http.LastMethodSuccess == false) {
ERROR: Entry not found: Http.LastErrorText
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
--emitNewObject
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
console.log(http.LastErrorText);
return;
}
console.log(resp.StatusCode);
console.log(resp.BodyStr);
}
chilkatExample();
Curl Command
curl -X PUT
-H "Authorization: Basic dGVzdGluZzp0ZXN0aW5nMTIz"
-H "Content-Type: application/json"
-d '{
"retref": "{{retref}}",
"merchid": "{{merchid}}"
}'
https://domain.com/refund
Postman Collection Item JSON
{
"name": "Refund with Reference (Retref)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"profileid\", jsonData.profileid);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"acctid\", jsonData.acctid);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"retref\", jsonData.retref);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"token\", jsonData.token);",
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"batchid\", jsonData.batchid);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Basic dGVzdGluZzp0ZXN0aW5nMTIz"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"retref\": \"{{retref}}\",\n \"merchid\": \"{{merchid}}\"\n}"
},
"url": {
"raw": "{{url}}/refund",
"host": [
"{{url}}"
],
"path": [
"refund"
]
},
"description": "[Refund Documentation](https://developer.cardconnect.com/cardconnect-api#refund)"
},
"response": [
]
}