PHP code example of loganhenson / firstdata

1. Go to this page and download the library: Download loganhenson/firstdata library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

loganhenson / firstdata example snippets




$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$response = $Transaction->Purchase('Mastercard', 'Logan Henson', 5500000000000004, 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}




$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$response = $Transaction->PreAuth('Mastercard', 'Logan Henson', 5500000000000004, 123, 1216);
	// store the $response['transarmor_token']
}catch(FirstDataException $e){
	echo $e->getMessage();
}



// get the transarmor_token from data storage

$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$latePurchaseResponse = $Transaction->LatePurchase('Mastercard', 'Logan Henson', $response['transarmor_token'], 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}



$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
	$response = $Transaction->Refund('Mastercard', 'Logan Henson', $transarmor_token, 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}




$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
    $Transaction->setCurrency('CAD');
	$response = $Transaction->Purchase('Mastercard', 'Logan Henson', 5500000000000004, 1216, 123, 120);
}catch(FirstDataException $e){
	echo $e->getMessage();
}



$Search = new Search(getenv('fd_username'), getenv('fd_password'));
try{
	$transactions = $Search->getTransactions();
}catch(FirstDataException $e){
	echo $e->getMessage();
}