Skip to content

colinbm/sagepayadminapi-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

SagePay Admin API

Provides an easy way to access the Admin API. You can use any command specified in the Reporting and Admin API documentation as a method. Pass an array of elements to send, as detailed in the document.

Examples

Get a single transaction

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

Get Visa and MasterCard refunds from March 2014

$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 );

About

PHP Class for accessing the SagePay Admin API

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages