macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: CF and viaKLIX

Subject: Re: CF and viaKLIX
From: "wfinley"
Date: Tue, 7 Aug 2007 07:05:41 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
I pulled my hair out looking for this and finally just cranked it out with the 
help of some other old code bases floating around.  Here it is so other 
developers like me don't have to rewrite it.  I'm sure there's a more elegant 
way to write it... but it works.   I call this page when I submit a form that 
has all the variables listed. 



 <!--- Removes Spaces Dashes and | symbols from the CC Number --->
 <cfset #ccnumber#='#REReplace("#payment_CreditCardNumber#"," -|","","ALL")#'>

 <cfsetting enablecfoutputonly="yes">
 <!--- Convert the four digit year to the last two digts-merge the month and 
year expiration to one four digit number --->
 <CFLOCK SCOPE="SESSION" TYPE="READONLY" TIMEOUT="10">
   <!--- Convert the year to two digits 
   <CFSET VARIABLES.expYY = Right(SESSION.ecom.CreditCardExpirationYear, 2)>--->
   <!--- Send the form variables to the Authorizing Agent --->
   <CFHTTP URL="https://www.viaKLIX.com/process.asp"; method="post">
     <!--- Viaklix login features --->
     <CFHTTPPARAM type="FORMFIELD" name="ssl_show_form" value="FALSE">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_test_mode" value="TRUE">
     <!--- FALSE RUNS THE CC FOR REAL! --->
     <CFHTTPPARAM type="FORMFIELD" name="ssl_result_format" value="ASCII">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_merchant_ID" value="xxx">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_user_id" value="xxx">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_pin" value="xxx3">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_transaction_type" value="SALE">
     <!--- Transaction features --->
     <CFHTTPPARAM type="FORMFIELD" name="ssl_amount" value="#payment_amount#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_description" 
value="#setup_companyname# Online Payment" >
     <!--- Address etc. --->
     <CFHTTPPARAM type="FORMFIELD" name="ssl_company" value="#payment_company#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_first_name" 
value="#payment_fName#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_last_name" value="#payment_lName#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_avs_address" 
value="#payment_Addr1#, #payment_Addr2#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_city" value="#payment_city#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_state" value="#payment_state#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_avs_zip" value="#payment_zip#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_country" value="#payment_Country#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_email" value="#payment_email#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_phone" value="#payment_phone#">
     <!--- the CC stuff --->
     <CFHTTPPARAM type="FORMFIELD" name="ssl_card_number" value="#ccNumber#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_exp_date" 
value="#payment_ExpirationDate##payment_ExpDateYear#">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_cvv2" value="#ssl_cvv2#">
     <!--- Optional stuff; you must set default as 0 or an error throws --->
     <CFHTTPPARAM type="FORMFIELD" name="ssl_customer_code" value="0">
     <CFHTTPPARAM type="FORMFIELD" name="ssl_salestax" value="0">
   </CFHTTP>
 </CFLOCK>
 <!--- Retrieve the transaction results from the Credit Card Processor --->
 <CFSET VARIABLES.ccpVars = #CFHTTP.FILECONTENT#>
 <!--- Convert the string to a comma-delimited format, replacing spaces with 
commas --->
 <CFSET VARIABLES.ccpVars = REREPLACE(VARIABLES.ccpVars, "[[:space:]]", ",", 
"ALL")>
 <!--- Assign a New variable to each of the comma delimited items in the list 
--->
 <CFSET VARIABLES.ssl_result = ListFirst(VARIABLES.ccpVars)>
 <CFSET VARIABLES.ssl_result_message = ListGetAt(VARIABLES.ccpVars, 2)>
 <CFSET VARIABLES.ssl_txn_id = ListGetAt(VARIABLES.ccpVars, 3)>
 <CFSET VARIABLES.ssl_approval_code = ListGetAt(VARIABLES.ccpVars, 4)>
 <!--- Change the variable character length to keep only those characters to 
the right of the "=" sign --->
 <CFSET URL.approved = RemoveChars(VARIABLES.ssl_result, 1, 11)>
 <CFSET VARIABLES.resultsMessage = RemoveChars(VARIABLES.ssl_result_message, 1, 
19)>
 <CFSET VARIABLES.ccpTransactionID = RemoveChars(VARIABLES.ssl_txn_id, 1, 11)>
 <CFSET VARIABLES.ccpApprovalCode = RemoveChars(VARIABLES.ssl_approval_code, 1, 
18)>
 <!--- Test Output of Variables 
 #CFHTTP.FILECONTENT#
 --->

 <CFOUTPUT>
 <cfif URL.approved is "0"> 
   <cfset approved ="y">
     <!--- it's been approved; do your stuff! --->
   <cfelse>
    <!--- it was not approved; here's why --->
    <cfset message = "#ListLast(CFHTTP.FILECONTENT, "=")#">
 </cfif>  
 </CFOUTPUT>


<Prev in Thread] Current Thread [Next in Thread>
  • Re: CF and viaKLIX, wfinley <=