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
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
// 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}}"
// }
$json = new CkJsonObject();
$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
$sbRequestBody = new CkStringBuilder();
$json->EmitSb($sbRequestBody);
ERROR: Entry not found: Http.PTextSb
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
phpEmitNewObject:
usingActiveX: False
phpType: CkHttp
--phpEmitNewObject
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
phpEmitNewObject:
usingActiveX: False
phpType: CkJsonObject
--phpEmitNewObject
--emitNewObject
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
phpEmitNewObject:
usingActiveX: False
phpType: CkStringBuilder
--phpEmitNewObject
--emitNewObject
failedToLoadClass: Http
failedToLoadClass: Http
getApiProperty:
Class not found
className: Http
--getApiProperty
--CodeGen
ERROR: Non-existent Chilkat method: Http.PTextSb
// resp is a CkHttpResponse
$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
phpEmitNewObject:
usingActiveX: False
phpType: CkHttp
--phpEmitNewObject
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
phpEmitNewObject:
usingActiveX: False
phpType: CkJsonObject
--phpEmitNewObject
--emitNewObject
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
phpEmitNewObject:
usingActiveX: False
phpType: CkStringBuilder
--phpEmitNewObject
--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->get_LastMethodSuccess() == false) {
ERROR: Entry not found: Http.LastErrorText
ERROR: CodeGen:
emitNewObject:
atgType: Http
varName: http
phpEmitNewObject:
usingActiveX: False
phpType: CkHttp
--phpEmitNewObject
--emitNewObject
emitNewObject:
atgType: JsonObject
varName: json
phpEmitNewObject:
usingActiveX: False
phpType: CkJsonObject
--phpEmitNewObject
--emitNewObject
emitNewObject:
atgType: StringBuilder
varName: sbRequestBody
phpEmitNewObject:
usingActiveX: False
phpType: CkStringBuilder
--phpEmitNewObject
--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
print $http->get_LastErrorText() . "\n";
exit;
}
print $resp->get_StatusCode() . "\n";
print $resp->bodyStr() . "\n";
?>
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": [
]
}