Sample code for 30+ languages & platforms
Rust

CardConnect Get Profile

See more CardConnect Examples

Demonstrates how to get a profile.
A GET request to the profile endpoint returns the stored data for the specified profile ID. ...

See https://developer.cardconnect.com/cardconnect-api?lang=json#get-profile-request

Chilkat Rust Downloads

Rust

// 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");

let url = "https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>".to_string();
let Ok(response_str) = http.quick_get_str(&url) else {
    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 = {}", http.last_status());

let json_resp = chilkat::JsonObject::new();
let _ = json_resp.load(&response_str);
json_resp.set_emit_compact(false);

println!("response JSON:");
println!("{}", json_resp.emit().unwrap_or_default());

// A successful response looks like this:

// {
//   "country": "US",
//   "gsacard": "N",
//   "address": "123 MAIN STREET",
//   "city": "ANYTOWN",
//   "acctid": "1",
//   "defaultacct": "Y",
//   "accttype": "VISA",
//   "token": "9441149619831111",
//   "license": "123451254",
//   "phone": "7778789999",
//   "profileid": "16392957457306633141",
//   "name": "TOM JONES",
//   "auoptout": "N",
//   "postal": "19090",
//   "expiry": "0214",
//   "region": "AK",
//   "ssnl4": "3655"
// }

// Use this online tool to generate parsing code from sample JSON: 
// Generate Parsing Code from JSON

let country = json_resp.string_of("country").unwrap_or_default();
let gsacard = json_resp.string_of("gsacard").unwrap_or_default();
let address = json_resp.string_of("address").unwrap_or_default();
let city = json_resp.string_of("city").unwrap_or_default();
let acctid = json_resp.string_of("acctid").unwrap_or_default();
let defaultacct = json_resp.string_of("defaultacct").unwrap_or_default();
let accttype = json_resp.string_of("accttype").unwrap_or_default();
let token = json_resp.string_of("token").unwrap_or_default();
let license = json_resp.string_of("license").unwrap_or_default();
let phone = json_resp.string_of("phone").unwrap_or_default();
let profileid = json_resp.string_of("profileid").unwrap_or_default();
let name = json_resp.string_of("name").unwrap_or_default();
let auoptout = json_resp.string_of("auoptout").unwrap_or_default();
let postal = json_resp.string_of("postal").unwrap_or_default();
let expiry = json_resp.string_of("expiry").unwrap_or_default();
let region = json_resp.string_of("region").unwrap_or_default();
let ssnl4 = json_resp.string_of("ssnl4").unwrap_or_default();