Hi - I've edited this post to reflect a solution. A little help from WHMCS support.
This will create the database has, and decode the fields.
I'm using this as an export prior to a change of payment gateways. This could also be the basis for an export of customers prior to changing the cc_encryption_hash (but dont forget service passwords too using the WHMCS decrypt() function)...
$stmt = $pdo->prepare("SELECT id, firstname, lastname, companyname, email, address1, address2, city,
state, postcode, phonenumber, cardtype, cardlastfour,
AES_DECRYPT(cardnum, MD5(CONCAT('$cc_encryption_hash',id)) ) as cardnum,
AES_DECRYPT(expdate, MD5(CONCAT('$cc_encryption_hash',id)) ) as expdate,
AES_DECRYPT(issuenumber, MD5(CONCAT('$cc_encryption_hash',id)) ) as issuenumber,
AES_DECRYPT(startdate, MD5(CONCAT('$cc_encryption_hash',id)) ) as startdate
FROM tblclients ");
$stmt->execute();
$lines = $stmt->rowCount();
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);