Skip to main content

Overview

The Query API enables merchants to retrieve transaction information from the payment gateway. Look up previously processed transactions and obtain detailed information about their status, amounts, and other transaction details.
Use the Query API to verify transactions, reconcile accounts, and retrieve transaction history.

API Endpoint

POST https://api.ionicfi.com/api/query.php

Authentication

All Query API requests require your API Security Key:
security_key=YOUR_API_KEY
Generate new security keys from the merchant control panel: Settings > Security Keys

Query Types

Look up a specific transaction by ID.Request:
security_key=YOUR_API_KEY
transaction_id=123456789
Response:
response=1
transaction_id=123456789
transaction_type=sale
condition=complete
amount=99.99
cc_number=4xxxxxxxxxxx1111
cc_exp=1225
first_name=John
last_name=Doe

Implementation Examples

<?php
$url = "https://api.ionicfi.com/api/query.php";

$data = array(
    "security_key" => "YOUR_API_KEY",
    "transaction_id" => "123456789"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

$response = curl_exec($ch);
curl_close($ch);

parse_str($response, $result);
print_r($result);
?>

Query Parameters

Transaction Query

ParameterDescriptionRequired
security_keyYour API security keyYes
transaction_idTransaction ID to queryYes

Batch Query

ParameterDescriptionRequired
security_keyYour API security keyYes
batch_idBatch ID to queryYes

Date Range Query

ParameterDescriptionRequiredFormat
security_keyYour API security keyYesString
start_dateBeginning dateYesYYYYMMDD
end_dateEnding dateYesYYYYMMDD
limitMax results to returnNoInteger
offsetPagination offsetNoInteger

Response Format

Transaction responses are returned in query string format:
response=1&transaction_id=123456789&amount=99.99&cc_number=4xxxxxxxxxxx1111
Parse the response by splitting on & and then on =:
parse_str($response, $result);
echo $result['amount']; // 99.99

Response Fields

Transaction Information

FieldDescription
transaction_idUnique transaction identifier
transaction_typeType: sale, auth, capture, void, refund, credit
conditionTransaction status: complete, pending, failed, unknown
amountTransaction amount
currencyCurrency code (USD, etc.)
processor_idProcessor that handled transaction

Payment Method

FieldDescription
cc_numberMasked card number (e.g., 4xxxxxxxxxxx1111)
cc_expCard expiration (MMYY)
card_typeCard brand: Visa, Mastercard, Amex, Discover
check_accountMasked account number (for ACH)
check_abaRouting number (for ACH)
account_typechecking or savings

Customer Information

FieldDescription
first_nameCustomer first name
last_nameCustomer last name
companyCompany name
address1Billing address line 1
address2Billing address line 2
cityCity
stateState
zipPostal code
countryCountry code
phonePhone number
emailEmail address

Response Details

FieldDescription
response1=success, 2=decline, 3=error
responsetextResponse description
authcodeAuthorization code from processor
avsresponseAVS response code
cvvresponseCVV response code
orderidMerchant order ID

Additional Fields

FieldDescription
createdTransaction timestamp
settledSettlement timestamp
batch_idSettlement batch ID
customer_vault_idCustomer vault ID (if used)
partial_payment_idPartial payment ID (if applicable)

Transaction Status

The condition field indicates transaction status:
Transaction processed successfully and is settled or pending settlement.Action: No action needed

Batch Queries

Query all transactions in a settlement batch:
security_key=YOUR_API_KEY
batch_id=20251030
Response Format:
total_count=150
total_amount=15000.00
transactions[0][transaction_id]=123456789
transactions[0][amount]=99.99
transactions[0][type]=sale
transactions[0][status]=complete
transactions[1][transaction_id]=123456790
transactions[1][amount]=50.00
transactions[1][type]=auth
transactions[1][status]=complete
Parse the response to access individual transactions:
parse_str($response, $result);
echo "Total transactions: " . $result['total_count'];
foreach ($result['transactions'] as $txn) {
    echo "Transaction ID: " . $txn['transaction_id'];
    echo "Amount: " . $txn['amount'];
}

Date Range Queries

Query transactions within a date range:
security_key=YOUR_API_KEY
start_date=20251001
end_date=20251031
limit=100
offset=0
Parameters:
  • start_date: Beginning date (YYYYMMDD)
  • end_date: Ending date (YYYYMMDD)
  • limit: Maximum results per request (default: 100, max: 1000)
  • offset: Pagination offset for large result sets
Pagination Example:
// Get first 100 transactions
$offset = 0;
$limit = 100;

do {
    $data = array(
        "security_key" => "YOUR_API_KEY",
        "start_date" => "20251001",
        "end_date" => "20251031",
        "limit" => $limit,
        "offset" => $offset
    );

    // Make query request
    $response = makeQuery($data);
    parse_str($response, $result);

    // Process transactions
    processTransactions($result['transactions']);

    $offset += $limit;

} while (count($result['transactions']) == $limit);

Error Handling

Common query errors:
ErrorDescriptionResolution
Invalid transaction IDTransaction not foundVerify transaction ID
Invalid security keyAuthentication failedCheck API key
Access deniedTransaction belongs to different merchantVerify merchant account
Invalid date formatDate format incorrectUse YYYYMMDD format

Rate Limiting

The Query API implements rate limiting:
  • 100 requests per minute per API key
  • 10,000 requests per day per merchant account
Exceeding rate limits results in temporary API access suspension. Implement exponential backoff for retries.

Use Cases

Verify transaction status after processing:
// After payment redirect
$transaction_id = $_GET['transaction_id'];
$result = queryTransaction($transaction_id);

if ($result['condition'] == 'complete' && $result['response'] == '1') {
    // Transaction successful
    completeOrder();
}
Reconcile transactions against your records:
// Daily reconciliation
$today = date('Ymd');
$result = queryDateRange($today, $today);
reconcileWithDatabase($result['transactions']);
Retrieve customer’s transaction history:
// Get all transactions for a customer
$customer_vault_id = '123456';
$transactions = queryCustomerTransactions($customer_vault_id);
displayToCustomer($transactions);
Generate transaction reports:
// Monthly report
$start = '20251001';
$end = '20251031';
$transactions = queryDateRange($start, $end);
generateReport($transactions);

Best Practices

Cache Results

Cache query results to reduce API calls and improve performance

Batch Processing

Use batch queries instead of individual transaction queries when possible

Error Handling

Implement robust error handling and retry logic

Rate Limiting

Respect rate limits and implement exponential backoff

Next Steps