SecurePayTech.com logo


<?php
/* Example code for using the NuSOAP library for PHP with the SecurePayTech SOAP webservices
Note: You will need to have the cURL extension installed in PHP in order to use access the
     webservice via https
*/

/* The NuSOAP library can be found at: http://sourceforge.net/projects/nusoap/ */
require_once('lib/nusoap.php');

/* Set up the SOAP Client, using the WSDL method */
$soapClient = new soapclient("https://tx.securepaytech.com:8443/web/SoapRefund?wsdl",true);
if ($soapClient->getError()) {
     echo $soapClient->getError() ."<br />";
     echo "Error creating SOAP Client, exiting";
     exit();
}

/* Use the following code to set up the SOAP Client in non-WSDL mode */
//$soapClient = new soapclient("https://tx.securepaytech.com:8443/web/SoapRefund",false);
//if ($soapClient->getError()) {
//     echo $soapClient->getError() ."<br />";
//     echo "Error creating SOAP Client, exiting";
//     exit();
//}

$merchantID = "YOUR_VPS_MERCHANT_ID_HERE";
$merchantKey = "YOUR_PASSKEY_HERE";
$originalTransactionNumber = "188"; //Just an example - you will have to supply a number
                                                       // from a prior, sucessful purchase transaction
$amount = 30.00;     //Must be less than or equal to the original
                              //purchase amount, less any already refunded amount

/* Create an array containing the arguments for the method call */
$args= array($merchantID,$merchantKey,$amount, $originalTransactionNumber);
//Perform the SOAP method call
$result = $soapClient->call("refund",$args);
if ($soapClient->getError()) {
     echo $soapClient->faultcode ." - ". $soapClient->faultstring ."<br />";
} else {
     echo "Soap method called succesfully<br />";
}

echo "resultCode: " . $result["resultCode"] . "<br />";
echo "merchTxnRef: " . $result["merchTxnRef"] . "<br />";
echo "transactionNo: " . $result["transactionNo"] . "<br />";
echo "receiptNo: " . $result["receiptNo"] . "<br />";
echo "authorizationID: " . $result["authorizationID"] . "<br />";
echo "batchNo: " . $result["batchNo"] . "<br />";
echo "failReason: " . $result["failReason"] . "<br />";
print_r ($result["failReason"]);
echo "<br />";

/* Uncomment to see debugging information */
//echo 'Request: <xmp>'.$soapClient->request.'</xmp>';
//echo 'Response: <xmp>'.$soapClient->response.'</xmp>';
//echo 'Debug log: <pre>'.$soapClient->debug_str.'</pre>';

?>