DPSAUTHSSL COM Object Sample Code
ASP/VBScript
The Sample Code will not work without the following:
* DPSAUTHSSL COM Object installed on you web sever
* Development Account setup with DPS
If you do not have access to a Development account please click here to request it.
<%@ Language=VBScript %>
<html>
<%
' This Example is provided to demonstrate integration
' of the Direct Payment Solutions DPSAUTHSSL with
' Microsoft Active Server Pages (ASP).
' Note: The DPSAUTHSSL COM Object must be installed on the WebServer running this
' ActiveServerPage for this code to work. Refer: http://www.paymentexpress.com/blue.asp?id=d_dpsauthssl
' for more information
Dim StatusNeeded
If Not IsEmpty(Request.Form("CardNumber")) Then
Set dpsobj = Server.CreateObject("DpsAuthSSL.DpsAuthSSLCtrl") ' Instantiate the DPSAuthSSL COM Object
dpsobj.CardNumber = Request.Form("CardNumber") ' CC Number - No spaces
dpsobj.CardHolderName = Request.Form("CardHolderName") ' Card holder name
dpsobj.DateExpiry = Request.Form("DateExpiry") ' Date Expiry in MMYY format
dpsobj.Amount = Request.Form("Amount") ' Amount "dddddddddd.cc" where d=dollars, c=cents
dpsobj.Currency = "AUD" ' Currency to be specified
dpsobj.MerchantReference = Request.Form("MerchantReference") ' Free Text upto 64 characters. Appears on Transaction Reports
dpsobj.ClientInfo = Request.ServerVariables ("REMOTE_ADDR") ' Browser Address
dpsobj.TxnType = "P" ' Set Transaction Type to "P" for Purchase
dpsobj.Username = "Test" ' (Insert your username here)
dpsobj.Password = "Test" ' (Insert your password here)
dpsobj.DoAuthorize() ' Authorise the payment
if dpsobj.StatusNeeded then
' Not successful result, but no response received from host within the
' allowed timeout (45sec). May have been a transient condition, so attempt a
' status on the transaction. If this fails,inform user and write an error for
' manual handling
dpsobj.DoStatus
End If
if dpsobj.StatusNeeded then
' Comms to Host interrupted with transaction "in flight". Result
' is unknown, Webmaster must investigate and determine if funds were
' transferred or not
Response.Write("<html> Transaction Failure. Result unknown. Please contact webmaster: quote: Txnref:" +dpsobj.TxnRef + "ResponseCode=" + dpsobj.ResponseCode)
else
if dpsobj.success then
' Successful Transaction
Response.Write("Transaction Approved AuthCode:" + dpsobj.AuthCode)
else
' Declined or Failed transaction
Response.Write("Transaction NOT Approved Response:" + dpsobj.CardHolderResponseText + " ResponseText="+dpsobj.ResponseText + " ResponseCode=" + dpsobj.ResponseCode)
end if
end if
Set dpsobj = Nothing ' destroy COM Object
End if
%>
<body>
<form action="dpsauthssl.asp" method="post">
<p>Credit Card Number: <input Name="CardNumber" value="4111111111111111" maxlength="16" Size="16"> </p>
<p>Date Expiry: <input name="DateExpiry" size="4" value="0102" style="LEFT: 96px; TOP: 78px"></p>
<p>Cardholder Name: <input Name="CardHolderName" Size="64" value="A CARDHOULD"></p>
<p>Amount: <input value="1.23" Name="Amount" Size="10"> </p>
<p>Merchant Reference: <input Name="MerchantReference" Size="64" value="Free Text upto 64 characters"></p>
<input type="submit" value="Submit" id="submit1" name="submit1">
</form>
</body>
</html>
Refunds using DpsTxnRef
<%@ Language=VBScript %>
<html>
<%
' This Example is provided to demonstrate integration
' of the Direct Payment Solutions DPSAUTHSSL with
' Microsoft Active Server Pages (ASP).
' Note: The DPSAUTHSSL COM Object must be installed on the WebServer running this
' ActiveServerPage for this code to work. Refer: http://www.paymentexpress.com/blue.asp?id=d_dpsauthssl
' for more information
Dim StatusNeeded
If Not IsEmpty(Request.Form("action")) Then
Set dpsobj = Server.CreateObject("DpsAuthSSL.DpsAuthSSLCtrl") ' Instantiate the DPSAuthSSL COM Object
If Request.Form("action") = "refund" Then
dpsobj.DpsTxnRef = Request.Form("DpsTxnRef") ' Date Expiry in MMYY format
dpsobj.Amount = Request.Form("Amount") ' Amount "dddddddddd.cc" where d=dollars, c=cents
dpsobj.MerchantReference = "Refund Txn using DpsTxnRef" ' Free Text upto 64 characters. Appears on Transaction Reports
dpsobj.TxnType = "R"
Else
dpsobj.CardNumber = Request.Form("CardNumber") ' CC Number - No spaces
dpsobj.CardHolderName = Request.Form("CardHolderName") ' Card holder name
dpsobj.DateExpiry = Request.Form("DateExpiry") ' Date Expiry in MMYY format
dpsobj.Amount = "1.00" ' Amount "dddddddddd.cc" where d=dollars, c=cents
dpsobj.MerchantReference = "Purchase Txn" ' Free Text upto 64 characters. Appears on Transaction Reports
dpsobj.TxnType = "P" ' Set Transaction Type to "P" for Purchase
End If
dpsobj.Username = "test" ' (Insert your username here)
dpsobj.Password = "test" ' (Insert your password here)
dpsobj.DoAuthorize() ' Authorize the payment
if dpsobj.StatusNeeded then
' Not successful result, but no response received from host within the
' allowed timeout (45sec). May have been a transient condition, so attempt a
' status on the transaction. If this fails,inform user and write an error for
' manual handling
dpsobj.DoStatus
End If
if dpsobj.StatusNeeded then
' Comms to Host interrupted with transaction "in flight". Result
' is unknown, Webmaster must investigate and determine if funds were
' transferred or not
Response.Write("<html> Transaction Failure. Result unknown. Please contact webmaster: quote: Txnref:" +dpsobj.TxnRef + " ResponseCode=" + dpsobj.ResponseCode)
else
if dpsobj.success then
' Successful Transaction
Response.Write("Transaction Approved AuthCode:" + dpsobj.AuthCode)
bSuccess = True
else
' Declined or Failed transaction
Response.Write("Transaction NOT Approved Response:" + dpsobj.CardHolderResponseText + " ---- ResponseText = <b>"+dpsobj.ResponseText + "</b> ---- ResponseCode = <b>" + dpsobj.ResponseCode)
bSuccess = True
end if
end if
' destroy COM Object
End if
%>
<body>
<form action="dpsauthsslrefund.asp" method="post" id=form1 name=form1>
<input type="hidden" value="1" name="action">
<p>Amount: <input Name="Amount" value="1.00" maxlength="16" Size="16"> </p>
<p>Card Number: <input Name="CardNumber" value="4111111111111111" maxlength="16" Size="16"> </p>
<p>Date Expiry: <input name="DateExpiry" size="4" value="0103" style="LEFT: 96px; TOP: 78px"></p>
<p>CardHolder Name: <input Name="CardHolderName" Size="64" value="A CARDHOULD"></p>
<input type="submit" value="Submit" id="submit1" name="submit1">
</form>
<%If bSuccess Then%>
<form action="dpsauthsslrefund.asp" method="post" id=form2 name=form2>
<input type="hidden" value="refund" name="action">
<p>Amount: <input Name="Amount" value="1.00" maxlength="16" Size="16"> </p>
<p>Dps Txn Ref: <input name="DpsTxnRef" size="22" value="<%=dpsobj.DpsTxnRef%>" style="LEFT: 96px; TOP: 78px"></p>
<input type="submit" value="Submit" id="submit1" name="submit1">
</form>
<%End If%>
</body>
</html>
<%Set dpsobj = Nothing%>