Rust Requires Chilkat v11.0.0+
Rust
CardConnect Void
See more CardConnect Examples
Demonstrates how to send a CardConnect void request.The void service cancels a transaction that is in either "Authorized" or "Queued for Capture" status.. ...
See https://developer.cardconnect.com/cardconnect-api#void
Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
http.set_basic_auth(true);
http.set_login("API_USERNAME");
http.set_password("API_PASSWORD");
// Build and send the following JSON:
// The "retref" is the value returned in the JSON response for the Authorization request.
// {
// "retref":"112989260941",
// "merchid":"MERCHANT_ID"
// }
let json = chilkat::JsonObject::new();
let _ = json.update_string("retref", "112989260941");
let _ = json.update_string("merchid", "MERCHANT_ID");
let url = "https://<site>.cardconnect.com:<port>/cardconnect/rest/void".to_string();
let resp = chilkat::HttpResponse::new();
if http.http_str("PUT", &url, &json.emit().unwrap_or_default(), "utf-8", "application/json", &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
// A response status of 200 indicates potential success. The JSON response body
// must be examined to determine if it was truly successful or an error.
println!("response status code = {}", resp.status_code());
let json_resp = chilkat::JsonObject::new();
let _ = json_resp.load(&resp.body_str());
json_resp.set_emit_compact(false);
println!("response JSON:");
println!("{}", json_resp.emit().unwrap_or_default());
// A successful response looks like this:
// {
// "authcode": "REVERS",
// "respproc": "FNOR",
// "amount": "0.00",
// "resptext": "Approval",
// "currency": "USD",
// "retref": "112989260941",
// "respstat": "A",
// "respcode": "00",
// "merchid": "496160873888"
// }
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
let authcode = json_resp.string_of("authcode").unwrap_or_default();
let respproc = json_resp.string_of("respproc").unwrap_or_default();
let amount = json_resp.string_of("amount").unwrap_or_default();
let resptext = json_resp.string_of("resptext").unwrap_or_default();
let currency = json_resp.string_of("currency").unwrap_or_default();
let retref = json_resp.string_of("retref").unwrap_or_default();
let respstat = json_resp.string_of("respstat").unwrap_or_default();
let respcode = json_resp.string_of("respcode").unwrap_or_default();
let merchid = json_resp.string_of("merchid").unwrap_or_default();