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/SoapPurchase?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/SoapPurchase",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";
$orderRef = "TestSoapOrder";
$amount = 120.00;
$currency = "NZD";
$cardType = 1; //Visa
$cardNumber = "4987-6543-2109-8769"
$cardExpiry = "0607"
$cardHolder = "Test CC Holder";

/* Create an array containing the arguments for the method call */
$args= array($merchantID,$merchantKey,$orderRef, $amount,$currency,
                              $cardType,$cardNumber,$cardExpiry,$cardHolder);
//Perform the SOAP method call
$result = $soapClient->call("purchase",$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>';

?>