SecurePayTech.com logo


<?php
/* Example code for using the SOAP extensions in PHP 5.x, with the SecurePayTech SOAP webservices
Note: You will likely need to have the cURL extension installed in PHP in order to use access the
     webservice via https
     Note: Using WSDL mode with PHP 5.0.1 or previous will crash PHP. 5.0.2 or above is fine.
*/

$merchantID = "YOUR_VPS_MERCHANT_ID_HERE";
$merchantKey = "YOUR_PASSKEY_HERE";

/* Set up the SOAP Client, using the WSDL method */
$client = new SoapClient('https://tx.securepaytech.com:8443/web/SoapRefund?wsdl',array(
                                                             'uri' => 'http://tx.securepaytech.com',
                                                             'use' => SOAP_ENCODED,
                                                             'style' => 'SOAP_RPC'));

/* Use the following code to set up the SOAP Client in non-WSDL mode */
//$client = new SoapClient(null, array('location' => 'https://tx.securepaytech.com:8443/web/SoapRefund',
//                                                             'uri' => 'http://tx.securepaytech.com',
//                                                             'use' => SOAP_ENCODED,
//                                                             'style' => SOAP_RPC));


$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


try {
     //Perform the SOAP method call
     $result = $client->refund($merchantID,$merchantKey,$amount,$originalTransactionNumber);
} catch (SoapFault $f) {
     echo $f->getMessage();
     echo "<br />";
     echo $f->faultcode;
     echo "<br />";
     echo $f->faultstring;
     echo "<br />";
     print_r($f->getTrace());
}

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 />";
echo "<br />";

?>