Download the pdf document for transaction codes and other information
testUrl = "https://transact.nab.com.au/test/xmlapi/payment";
liveUrl = "https://transact.nab.com.au/xmlapi/payment";
NAB Transact XML API – Public Test Account Details
Merchant ID: XYZ0010
Transaction Password: abcd1234
Xml sent to NAB for processing
$nabXml = "<NABTransactMessage>
<MerchantInfo>
<merchantID>XYZ0010</merchantID>
<password>abcd1234</password>
</MerchantInfo>
<RequestType>Payment</RequestType>
<Payment>
<TxnList count='1'>
<Txn ID='1'>
<txnType>0</txnType>
<txnSource>23</txnSource>
<amount>5000</amount>
<currency>AUD</currency>
<purchaseOrderNo>100000</purchaseOrderNo>
<CreditCardInfo>
<cardNumber>4444333322221111</cardNumber>
<cvv>123</cvv>
<expiryDate>01/15</expiryDate>
</CreditCardInfo>
</Txn>
</TxnList>
</Payment>
</NABTransactMessage>";
Php code to execute payment using xml api
$result = makeCurlCall(
$testNab, /* CURL URL */
"POST", /* CURL CALL METHOD */
array( /* CURL HEADERS */
"Content-Type: text/xml; charset=utf-8",
"Accept: text/xml",
"Pragma: no-cache",
"Content_length: ".strlen(trim($nabXml))
),
null, /* CURL GET PARAMETERS */
$nabXml /* CURL POST PARAMETERS AS XML */
);
makeCurlCall function
function makeCurlCall($url, $method = "GET", $headers = null, $gets = null, $posts = null) {
$ch = curl_init();
if($gets != null)
{
$url.="?".(http_build_query($gets));
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if($posts != null)
{
curl_setopt($ch, CURLOPT_POSTFIELDS, $posts);
}
if($method == "POST") {
curl_setopt($ch, CURLOPT_POST, true);
} else if($method == "PUT") {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
} else if($method == "HEAD") {
curl_setopt($ch, CURLOPT_NOBODY, true);
}
if($headers != null && is_array($headers))
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$response = curl_exec($ch);
$code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return array(
"code" => $code,
"response" => $response
);
}
And the response from NAB is like this, parse the xml received from nab
<? xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<NABTransactMessage>
<MessageInfo>
<messageID/>
<messageTimestamp>20130307120339466000+600</messageTimestamp>
<apiVersion/>
</MessageInfo>
<RequestType>Payment</RequestType>
<MerchantInfo>
<merchantID>XYZ0010</merchantID>
</MerchantInfo>
<Status>
<statusCode>000</statusCode>
<statusDescription>Normal</statusDescription>
</Status>
<Payment>
<TxnList count="1">
<Txn ID="1">
<txnType>0</txnType>
<txnSource>23</txnSource>
<amount>2500</amount>
<currency>AUD</currency>
<purchaseOrderNo>8547963513-1372817009</purchaseOrderNo>
<approved>Yes</approved>
<responseCode>00</responseCode>
<responseText>Approved</responseText>
<settlementDate>20130703</settlementDate>
<txnID>503578</txnID>
<authID/>
<CreditCardInfo>
<pan>444433...111</pan>
<expiryDate>01/15</expiryDate>
<cardType>6</cardType>
<cardDescription>Visa</cardDescription>
</CreditCardInfo>
</Txn>
</TxnList>
</Payment>
</NABTransactMessage>
https://docs.google.com/file/d/0B5nZNPW48dpFNmVpdi1PRHkyd2c/edit?usp=sharing