Dart
Dart
CardConnect Inquire
See more CardConnect Examples
Demonstrates how to get information for an individual transaction, including its settlement status (setlstat) and the response codes from the initial authorization.See https://developer.cardconnect.com/cardconnect-api?lang=json#inquire
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/inquire/<retref>/<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:
// {
// "amount": "0.00",
// "resptext": "Approval",
// "setlstat": "Voided",
// "capturedate": "20190422180044",
// "acctid": "1",
// "respcode": "00",
// "entrymode": "ECommerce",
// "merchid": "MERCHANT_ID",
// "token": "9418594164541111",
// "authcode": "PPS158",
// "respproc": "FNOR",
// "authdate": "20190422",
// "bintype": "",
// "profileid": "16618402968441604028",
// "lastfour": "1111",
// "name": "TOM JONES",
// "currency": "USD",
// "retref": "112989260941",
// "respstat": "A",
// "account": "9418594164541111"
// }
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
final amount = jsonResp.stringOf('amount');
final resptext = jsonResp.stringOf('resptext');
final setlstat = jsonResp.stringOf('setlstat');
final capturedate = jsonResp.stringOf('capturedate');
final acctid = jsonResp.stringOf('acctid');
final respcode = jsonResp.stringOf('respcode');
final entrymode = jsonResp.stringOf('entrymode');
final merchid = jsonResp.stringOf('merchid');
final token = jsonResp.stringOf('token');
final authcode = jsonResp.stringOf('authcode');
final respproc = jsonResp.stringOf('respproc');
final authdate = jsonResp.stringOf('authdate');
final bintype = jsonResp.stringOf('bintype');
final profileid = jsonResp.stringOf('profileid');
final lastfour = jsonResp.stringOf('lastfour');
final name = jsonResp.stringOf('name');
final currency = jsonResp.stringOf('currency');
final retref = jsonResp.stringOf('retref');
final respstat = jsonResp.stringOf('respstat');
final account = jsonResp.stringOf('account');
}