PHP code example of colinbm / sagepayadminapi-php

1. Go to this page and download the library: Download colinbm/sagepayadminapi-php 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/ */

    

colinbm / sagepayadminapi-php example snippets


$adminapi = new SagePayAdminApi('vendor', 'username', 'password');
$transaction = $adminapi->getTransactionDetail(array('vendortxcode' => '12345678'));
echo "Third Man Status: {$transaction->t3maction} ({$transaction->t3mscore})\n";

$adminapi = new SagePayAdminApi('vendor', 'username', 'password');

// SagePay will only return 50 rows at a time so loop until we have them all.
do {
	$list = $adminapi->getTransactionList(array(
		'startdate'      => '01/03/2014 00:00:00',
		'enddate'        => '01/04/2014 00:00:00',
		'startrow'       => $end_row + 1,
		'txtypes'        => array(
			'txtype' => 'REFUND',
		),
		'paymentsystems' => array(
			'paymentsystem' => array(
				'MC',
				'Visa',
			)
		),
	) );

	// Check response is OK
	if ( '0000' != $list->errorcode ) {
		die( $list->errorcode . ' : ' . $list->error );
	}
	$total_rows = (int) $list->transactions->totalrows;
	$end_row = (int) $list->transactions->endrow;

	foreach ( $list->transactions->transaction as $transaction ) {
		var_dump( $transaction );
	}
} while ( $end_row < $total_rows );