Transaction Information
WHASOLS added the ability to display additional transaction details in a modal in the WHASOLS Admin Area. Clicking on a transaction ID will open the modal to display this information for enabled supported gateways. By default, these details are available by clicking a transaction ID at
Billing > Transactions
.All Stripe gateways support this by default. You can display transaction information for other gateways using the TransactionInformation function.
Displaying Transaction Information
The following example code connects to the gateway and displays the transaction information:
<?php
function yourmodulename_TransactionInformation($arg = [])
{
// Gateway Parameters
$gateway_id= $arg['gateway']['id'];
$title= $arg['gateway']['title'];
//gateway parameter have gateway configuration parameters
/**
* Connect to gateway to retrieve transaction information.
*/
$postfields = [
"account"=>$arg['gateway']['apikey'],
"transactionId"=>$arg["invoice"]['transactionId'],
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/api/transaction');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
if(empty($response)) return ["status"=>"error","message"=>"Your Gateway error message here if exist"];
$transactionInformation = json_decode($response);
$information =
[
"TransactionId"=>$transactionData['id'],
"Amount"=>$transactionData['amount'],
"Currency"=>$transactionData['currency'],
"Type"=>$transactionData['type'],
"AvailableOn"=>$transactionData['available_on'],//Datetime as Y-m-d h:i:s
"Created"=>$transactionData['created'],//Datetime as Y-m-d h:i:s
"Description"=>$transactionData['description'],
"Fee"=>$transactionData['fee'],
"Status"=>$transactionData['status'],
"AdditionalDatum"=>
[
"customName1"=>$transactionData['customValue1'],
"customName2"=>$transactionData['customValue2'],
"customName3"=>$transactionData['customValue2'],
],
];
return ["status"=>"success","message"=>"Your Gateway message here if exist","response"=>$information];
}
Use the Information AdditionalDatum Array to add data. The passed value will display with the label for the key. For example:
<?php
$information =
[ "AdditionalDatum"=>
[
"customName1"=>$transactionData['customValue1'],
"customName2"=>$transactionData['customValue2'],
"customName3"=>$transactionData['customValue2'],
],
];
Required Permissions:By default, transaction information will display in the Admin Area for admins with the Full Administrator role. To allow other admin roles to see balance information, enable List Transactions for the desired role.