Dart
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final http = CkHttp();
http.basicAuth = true;
http.login = 'API_USERNAME';
http.password = 'API_PASSWORD';
final url = 'https://<site>.cardconnect.com:<port>/cardconnect/rest/profile/<profile ID>/<account ID>/<merchid>';
final String responseStr;
try {
responseStr = http.quickGetStr(url);
} on ChilkatException catch (e) {
print(e.lastErrorText);
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.
print('response status code = ${http.lastStatus}');
final jsonResp = CkJsonObject();
jsonResp.load(responseStr);
jsonResp.emitCompact = false;
print('response JSON:');
print(jsonResp.emit());
// 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
final country = jsonResp.stringOf('country');
final gsacard = jsonResp.stringOf('gsacard');
final address = jsonResp.stringOf('address');
final city = jsonResp.stringOf('city');
final acctid = jsonResp.stringOf('acctid');
final defaultacct = jsonResp.stringOf('defaultacct');
final accttype = jsonResp.stringOf('accttype');
final token = jsonResp.stringOf('token');
final license = jsonResp.stringOf('license');
final phone = jsonResp.stringOf('phone');
final profileid = jsonResp.stringOf('profileid');
final name = jsonResp.stringOf('name');
final auoptout = jsonResp.stringOf('auoptout');
final postal = jsonResp.stringOf('postal');
final expiry = jsonResp.stringOf('expiry');
final region = jsonResp.stringOf('region');
final ssnl4 = jsonResp.stringOf('ssnl4');
}