Tuesday, February 4, 2014

Secure pay xml api credit card payment


<?php 
#Test Merchant ID: abc0001
#Test Merchant Password: acb123
#Test URL (no SSL):     http://test.securepay.com.au/xmlapi/payment
#Test URL (SSL):        https://test.securepay.com.au/xmlapi/payment
#Live URL:              https://api.securepay.com.au/xmlapi/payment
$xml = '<?xml version="1.0" encoding="UTF-8"?>
    <SecurePayMessage>
        <MessageInfo>
            <messageID>8af793f9af34bea0cf40f5fb5c630c</messageID>
            <messageTimestamp>20041803161306527000+660</messageTimestamp>
            <timeoutValue>60</timeoutValue>
            <apiVersion>xml-4.2</apiVersion>
        </MessageInfo>
        <MerchantInfo>
            <merchantID>abc0001</merchantID>
            <password>abc123</password>
        </MerchantInfo>
        <RequestType>Payment</RequestType>
        <Payment>
            <TxnList count="1">
                <Txn ID="1">
                    <txnType>0</txnType>
                    <txnSource>0</txnSource>
                    <amount>1000</amount>
                    <currency>AUD</currency>
                    <purchaseOrderNo>test</purchaseOrderNo>
                    <CreditCardInfo>
                        <cardNumber>4444333322221111</cardNumber>
                        <expiryDate>09/15</expiryDate>
                    </CreditCardInfo>
                </Txn>
            </TxnList>
        </Payment>
    </SecurePayMessage>';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://test.securepay.com.au/xmlapi/payment");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE); // Follow redirects
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); // Return the HTTP response from the curl_exec function

$response = curl_exec($curl);
curl_close($curl);

header('Content-type: text/xml');
echo $response;

$responseIsLikeThis = '
<SecurePayMessage>
    <MessageInfo>
        <messageID>8af793f9af34bea0cf40f5fb5c630c</messageID>
        <messageTimestamp>20140402171039522000+660</messageTimestamp>
        <apiVersion>xml-4.2</apiVersion>
    </MessageInfo>
    <RequestType>Payment</RequestType>
    <MerchantInfo>
        <merchantID>ABC0001</merchantID>
    </MerchantInfo>
    <Status>
        <statusCode>000</statusCode>
        <statusDescription>Normal</statusDescription>
    </Status>
    <Payment>
        <TxnList count="1">
            <Txn ID="1">
                <txnType>0</txnType>
                <txnSource>0</txnSource>
                <amount>1000</amount>
                <currency>AUD</currency>
                <purchaseOrderNo>test</purchaseOrderNo>
                <approved>Yes</approved>
                <responseCode>00</responseCode>
                <responseText>Approved</responseText>
                <thinlinkResponseCode>100</thinlinkResponseCode>
                <thinlinkResponseText>000</thinlinkResponseText>
                <thinlinkEventStatusCode>000</thinlinkEventStatusCode>
                <thinlinkEventStatusText>Normal</thinlinkEventStatusText>
                <settlementDate>20140204</settlementDate>
                <txnID>576566</txnID>
                <CreditCardInfo>
                    <pan>444433...111</pan>
                    <expiryDate>09/15</expiryDate>
                    <cardType>6</cardType>
                    <cardDescription>Visa</cardDescription>
                </CreditCardInfo>
            </Txn>
        </TxnList>
    </Payment>
</SecurePayMessage>';
?>

No comments:

Post a Comment