DPSAUTH COM Object Sample Code
Cold Fusion
The Sample Code will not work without the following:
* DPSAUTH 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.
<!--- The "action" parameter is used for example only. In
order to use this you must have the DPS AUTH COM object installed and registered
on the same Server as the ColdFusion Application server.
---->
<cfparam name="action" default="display">
<html>
<head>
<title>DPS sample ColdFusion Payment page - status (<cfoutput>#action#</cfoutput>)</title>
</head>
<body>
<cfif action eq "display">
<!--- basic table to accept credit card information --->
<table border="0" cellpadding="2" cellspacing="0">
<form name="payment" method="Post" action="cfpayment.cfm?action=submit">
<tr>
<td>Card Number</td>
<td>: <input Name="CardNumber" value="4111111111111111" maxlength="16" Size="16"></td>
</tr>
<tr>
<td>CardHolder Name</td>
<td>: <input Name="CardHolderName" Size="64" value="A CARDHOLD"></td>
<tr>
<td>Date Expiry</td>
<td>: <input name="DateExpiry" size="4" value="0104" style="LEFT: 96px; TOP: 78px"></td>
</tr>
<tr>
<td>Amount</td>
<td>: <input value="1.23" Name="Amount" Size="10"></td>
</tr>
<tr>
<td>Merchant Reference</td>
<td>: <input Name="MerchantReference" Size="64" value="Free Text upto 64 characters"></td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="Submit" id="submit1" name="submit1">
<input type="Reset" value="Reset" name="reset">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<img src="http://www.paymentexpress.com/dpslogo.gif">
</td>
</tr>
</form>
</table>
<cfelseif action eq "submit">
<!--- lets create the object and get started --->
<cfobject class="DpsAuth.DpsAuthCtrl" action="CREATE" name="verify_cc" type="COM">
<!--- Merchant account. You will need to change this to your Account number supplied by DPS --->
<!--- use cfset verify_cc.Account="9997" if used instead of username/password --->
<cfset verify_cc.Username="#Insert your username here#">
<cfset verify_cc.Password="#Insert your password here#">
<!--- apply Swedish rounding and ensure that the Dollar amount is correctly formatted --->
<cfset verify_cc.Amount="#Numberformat(amount, '9999.99')#">
<cfset verify_cc.DateExpiry="#DateExpiry#">
<!--- optional attribute to specify the DPS server that is doing the processing. This is also already set in the DPS AUTH COM object --->
<cfset verify_cc.CardHolderName="#CardHolderName#">
<cfset verify_cc.CardNumber="#CardNumber#">
<cfset verify_cc.ClientType="W">
<cfset verify_cc.Cvc2="">
<cfset verify_cc.PreAuthNumber="">
<!--- <cfset verify_cc.ReceiptEmailAddress="#email#"> --->
<cfset verify_cc.TxnInfo="">
<cfset verify_cc.TxnType="P">
<cfset verify_cc.DoAuthorize()>
<!--- Check if we are 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 --->
<cfif verify_cc.StatusNeeded eq 1>
<cfset verify_cc.DoStatus()>
</cfif>
<!--- Just retried the transaction but it was unsuccessful OR Comms to Host interrupted with
transaction "in flight". Result is unknown, Webmaster must investigate and determine if funds
were transferred or not --->
<cfif verify_cc.StatusNeeded eq 1>
<cfoutput>
<p><font color="Red">Transaction Failure. Result unknown. Please contact webmaster: quote: Txnref:" #verify_cc.TxnRef# "ResponseCode=" #verify_cc.ResponseCode#.</font>
</cfoutput>
<cfelse>
<!--- check to see if we have a successful transaction. You can customise this message --->
<cfif verify_cc.success eq 1>
<cfoutput>
Your Transaction was #verify_cc.CardHolderResponseText# <br>
Your AuthCode is : #verify_cc.AuthCode# <br>
</cfoutput>
<cfelse>
<!--- the transaction was Declined or Failed customise this message --->
<cfoutput>
<p><font color="Red">Your Transaction was #verify_cc.CardHolderResponseText# <br>
The system will see #verify_cc.ResponseText# <br>
and the merchant will see #verify_cc.MerchantResponseText#.<br></font></p>
</cfoutput>
</cfif>
<!--- During development we might want to see all the codes that are being passed around --->
<cfoutput>
<!--- '#verify_cc.Account#', --->
'#verify_cc.Username#',
'#verify_cc.Password#',
'#verify_cc.DateExpiry#',
'#verify_cc.CardHolderName#',
'#verify_cc.CardNumber#',
'#verify_cc.ClientType#',
'#verify_cc.Cvc2#',
'#verify_cc.PreAuthNumber#',
'#verify_cc.ReceiptEmailAddress#',
'#verify_cc.TxnInfo#',
'#verify_cc.TxnType#',
'#verify_cc.AuthCode#',
'#verify_cc.CardName#',
'#verify_cc.ClientID#',
'#verify_cc.DateSettlement#',
'#verify_cc.HostDate#',
'#verify_cc.HostTime#',
'#verify_cc.PreAuthNumber#',
'#verify_cc.ResponseCode#',
'#verify_cc.ResponseText#',
'#verify_cc.Success#',
'#verify_cc.TxnRef#',
'#verify_cc.VersionMajor#',
'#verify_cc.VersionMinor#',
'#verify_cc.VersionRevision#'.
</cfoutput>
</cfif>
</cfif>
</body>
</html>