Solved

Need form field validation for hidden form elements

Posted on 2008-06-10
12
1,473 Views
Last Modified: 2013-12-24
Hello,

I am customizing a ColdFusion shopping cart, whereby when someone is checking out and has either a Net 30 purchase order or credit card payment option (based on their established account), that the checkout form displays 2 radio buttons, for them to select one as their payment option. Javascript is working to show the hidden table of form elements, based on their selection. If someone does not have the Net 30 option, then the credit card payment info fill-in form displays (without any Javascript in use to hide/show form elements). When the placeorder button is clicked, a cfmodule runs to validate the form fields and returns highlighted fields that need to be completed/corrected. All works fine if the form is not utilizing the hide/show Javascript for Net 30 folks; however, nothing happens when I try to validate the fields of the hidden form elements. For example, someone clicks the Purchase Order option and a text field pops in, along with the Place Order button. This field is required, and the page should come back with the field highlighted for completion, when the Place Order button is clicked. Instead, the page just gets called again, with the fields hidden again, as if nothing had happened. I have tried many iterations of what I have, to no avail. Since the validation works just fine when not dealing with the hidden form elements, I know the issue must be with the fact that they are hidden. But, for the life of me, I don't know what the solution is. How I need things to work is that if someone has the Purchase Order or Credit Card option, they select one of the options (radio button) and the respective form appears on the page (this part works fine). Then if they leave a required field blank and submit the form, it should come back with the hidden form still shown (NOT go back as hidden), and the field name highlighted, to be completed. I hope I've explained this okay. I have attached the pertinent code. Any help would be so appreciated, as I really need to get this resolved. Thank you very much! Tam
This is in the showcart.cfm file, which displays the cart and payment fields for submission:
 

	<!--- If the "PLACE ORDER" button has been clicked... --->

	<!--- START [ PROCESS ORDER ] =================================================== --->

	<cfif FORM.action EQ "placeorder">

		<!--- Process order --->
 

		<cfmodule template="CWTags/CWTagProcessOrder.cfm" Cart="#Cart#">

	</cfif>

	<!--- END [ PROCESS ORDER ] =============================++====================== --->		 
 

<!--- If Checking out, show credit card input form or Processor information---> 

		 <form action="<cfoutput>#request.ThisPage#</cfoutput>" method="post" name="PlaceOrder"> 

			<cfif request.PaymentAuthType EQ "Gateway" OR request.PaymentAuthType EQ "None"> 

				 <!--- get Credit Cards for form field ---> 

				 <cfquery name="rsGetCCards" datasource="#request.dsn#" username="#request.dsnUsername#" password="#request.dsnPassword#">

 				SELECT ccard_Name, ccard_Code 

				FROM tbl_list_ccards 

				WHERE ccard_Archive	= 0 ORDER BY ccard_Name

				</cfquery> 

				 <p><strong>Enter your payment details to complete your order.</strong></p> 

				 <!--- Output any error messages from credit card input ---> 

				 <cfif request.FieldErrorText NEQ ""> 

					<span class="errorMessage"><cfoutput>#request.FieldErrorText#</cfoutput></span> 

				</cfif> 
 

<CFIF "<cfoutput>#rsGetCustData.cst_terms#</cfoutput>" CONTAINS "Net30">

<input type="hidden" name="cst_terms" value="<cfoutput>#rsGetCustData.cst_terms#</cfoutput>">

<input type="hidden" name="cstPONumer" value="<cfoutput>#FORM.cstPONumber#</cfoutput>">
 

<table>

<tr>

  <td valign="top">Select Payment Method: </td>

  <td valign="top"><input type='radio' id=ra1 name=ra1 value=1 onClick="checkClick(this.value)">

<label for=ra1>Purchase Order</label><br>

      <input type='radio' id=ra2 name=ra1 value=2 onClick="checkClick(this.value)">

<label for=ra2>Credit Card</label></td>

</tr>

</table>
 

				
 
 

			<table id=tbox1 style="display:none" cellpadding="0" cellspacing="0" border="0">

			  <tr>

			    <td>

				 <table class="tabularData"> 

					<tr> 

						 <th colspan="2">Purchase Order Data</th> 

					 </tr> 

					<tr class="altRowOdd" > 

						 <td align="right">  <cfif IsDefined ('request.FieldErrorPON')>

								 <span class="errorMessage">P.O. Number</span> 

								 <cfelse> 

								 P.O. Number

							 </cfif> </td> 

						 <td> <input name="cstPONumber" size="34" type="text" value="<cfoutput>#FORM.cstPONumber#</cfoutput>"> 

							* </td> 

					 </tr> 

			               

				</table> 

			    </td>

			  </tr>

			</table>

				<table id=placeorder1 style="display:none"> 

				  <tr>

				    <td><input name="placeorder" type="submit" class="formButton" value="Place Order">

				<input name="action" type="hidden" value="placeorder"></td>

				  </tr>

				</table>
 

			<table id=sel1 style="display:none" cellpadding="0" cellspacing="0" border="0"> 

			  <tr>

			    <td>

				 <table class="tabularData"> 

					<tr> 

						 <th colspan="2">Credit Card Data</th> 

					 </tr> 

					<tr class="altRowOdd" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCHN')> 

								 <span class="errorMessage">Card Holder Name</span> 

								 <cfelse> 

								 Card Holder Name

							 </cfif> </td> 

						 <td> <input name="cstCCardHolderName" type="text" value="<cfoutput>#FORM.cstCCardHolderName#</cfoutput>"> 

							* </td> 

					 </tr> 

					<tr class="altRowEven" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCT')> 

								 <span class="errorMessage">Card Type</span> 

								 <cfelse> 

								 Card Type

							 </cfif> </td> 

						 <td> <select name="cstCCardType"> 

								 <option value="forgot" selected="selected">Choose Credit Card</option> 

								 <cfoutput query="rsGetCCards"> 

									<option value="#rsGetCCards.ccard_Code#"<cfif FORM.cstCCardType EQ rsGetCCards.ccard_Code> 
 

selected</cfif>>#rsGetCCards.ccard_Name#</option> 

								</cfoutput> 

							 </select> 

							* </td> 

					 </tr> 

					<tr class="altRowOdd" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCN')> 

								 <span class="errorMessage">Card Number</span> 

								 <cfelse> 

								 Card Number

							 </cfif> 

							<br /> </td> 

						 <td> <input type="text" name="cstCCNumber" value="<cfoutput>#FORM.cstCCNumber#</cfoutput>"> 

							*</td> 

					 </tr> 

					<tr class="altRowEven" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCY') OR IsDefined ('request.FieldErrorCM')> 

								 <span class="errorMessage">Expiration Date</span> 

								 <cfelse> 

								 Expiration Date

							 </cfif> </td> 

						 <td> <select name="cstExprMonth" id="cst_ExprMonth"> 

								 <option value="forgot">--</option> 

								 <cfloop index="MonthValue" from="01" to="12"> 

									<option<cfif FORM.cstExprMonth EQ MonthValue> selected</cfif>><cfoutput>#NumberFormat(MonthValue,"09")#</cfoutput></option> 

								</cfloop> 

							 </select> 

							/

							<select name="cstExprYr" id="cst_ExprYr"> 

								 <option value="forgot">--</option> 

								 <cfloop index="YearValue" from="#DateFormat(Now(),'yyyy')#" to="#DateFormat(DateAdd('yyyy',6,Now()),'yyyy')#"> 

									<option<cfif FORM.cstExprYr EQ YearValue> selected="selected"</cfif> 
 

value="<cfoutput>#Right(YearValue,2)#</cfoutput>"><cfoutput>#YearValue#</cfoutput></option> 

								</cfloop> 

							 </select> 

							* </td> 

					 </tr> 

					<tr class="altRowEven" > 

						 <td align="right" valign="top"><cfif IsDefined ('request.FieldErrorCCV')> 

								 <span class="errorMessage">CCV Code</span> 

								 <cfelse> 

								 CCV Code

							 </cfif></td> 

						 <td><p> 

								 <input name="cstCCV" type="text" value="<cfoutput>#FORM.cstCCV#</cfoutput>" size="4" maxlength="4"> 

								 <br /> 

								<span class="smallprint">This is the 3 digit number<br /> 

								that appears on the reverse side of your <br /> 

								credit card (where your signature appears).<br /> 

								Amex cards only - the 4 digit number on <br /> 

								the front of your card.</span><br /> 

								 <br /> 

								 <img src="cw3/assets/cards/ccv.gif" width="135" height="86"></p></td> 

					 </tr> 
 

				</table> 

			      </td>

			    </tr>

			</table>

				<table id=placeorder2 style="display:none"> 

				  <tr>

				    <td><input name="placeorder" type="submit" class="formButton" value="Place Order">

				<input name="action" type="hidden" value="placeorder"></td>

				  </tr>

				</table>

	

<script type="text/JavaScript">				

function checkClick(val)

{

  if( val == 1 ) {

    document.all["tbox1"].style.display = 'block';

    document.all["sel1"].style.display = 'none';

    document.all["placeorder1"].style.display = 'block';

    document.all["placeorder2"].style.display = 'none';

    document.all["sel1"].style.display = 'none';

    document.all["asel1"].disabled = true;

    document.all["atext1"].disabled = false;

  } else {

    document.all["tbox1"].style.display = 'none';

    document.all["sel1"].style.display = 'block';

    document.all["placeorder1"].style.display = 'none';

    document.all["placeorder2"].style.display = 'block';

    document.all["asel1"].disabled = false;

    document.all["atext1"].disabled = true;

  }

}

</script>
 
 

<CFELSE>

		 <table class="tabularData"> 

					<tr> 

						 <th colspan="2">Credit Card Data</th> 

					 </tr> 

					<tr class="altRowOdd" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCHN')> 

								 <span class="errorMessage">Card Holder Name</span> 

								 <cfelse> 

								 Card Holder Name

							 </cfif> </td> 

						 <td> <input name="cstCCardHolderName" type="text" value="<cfoutput>#FORM.cstCCardHolderName#</cfoutput>"> 

							* </td> 

					 </tr> 

					<tr class="altRowEven" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCT')> 

								 <span class="errorMessage">Card Type</span> 

								 <cfelse> 

								 Card Type

							 </cfif> </td> 

						 <td> <select name="cstCCardType"> 

								 <option value="forgot" selected="selected">Choose Credit Card</option> 

								 <cfoutput query="rsGetCCards"> 

									<option value="#rsGetCCards.ccard_Code#"<cfif FORM.cstCCardType EQ rsGetCCards.ccard_Code> 
 

selected</cfif>>#rsGetCCards.ccard_Name#</option> 

								</cfoutput> 

							 </select> 

							* </td> 

					 </tr> 

					<tr class="altRowOdd" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCN')> 

								 <span class="errorMessage">Card Number</span> 

								 <cfelse> 

								 Card Number

							 </cfif> 

							<br /> </td> 

						 <td> <input type="text" name="cstCCNumber" value="<cfoutput>#FORM.cstCCNumber#</cfoutput>"> 

							*</td> 

					 </tr> 

					<tr class="altRowEven" > 

						 <td align="right"> <cfif IsDefined ('request.FieldErrorCY') OR IsDefined ('request.FieldErrorCM')> 

								 <span class="errorMessage">Expiration Date</span> 

								 <cfelse> 

								 Expiration Date

							 </cfif> </td> 

						 <td> <select name="cstExprMonth" id="cst_ExprMonth"> 

								 <option value="forgot">--</option> 

								 <cfloop index="MonthValue" from="01" to="12"> 

									<option<cfif FORM.cstExprMonth EQ MonthValue> selected</cfif>><cfoutput>#NumberFormat(MonthValue,"09")#</cfoutput></option> 

								</cfloop> 

							 </select> 

							/

							<select name="cstExprYr" id="cst_ExprYr"> 

								 <option value="forgot">--</option> 

								 <cfloop index="YearValue" from="#DateFormat(Now(),'yyyy')#" to="#DateFormat(DateAdd('yyyy',6,Now()),'yyyy')#"> 

									<option<cfif FORM.cstExprYr EQ YearValue> selected="selected"</cfif> 
 

value="<cfoutput>#Right(YearValue,2)#</cfoutput>"><cfoutput>#YearValue#</cfoutput></option> 

								</cfloop> 

							 </select> 

							* </td> 

					 </tr> 

					<tr class="altRowEven" > 

						 <td align="right" valign="top"><cfif IsDefined ('request.FieldErrorCCV')> 

								 <span class="errorMessage">CCV Code</span> 

								 <cfelse> 

								 CCV Code

							 </cfif></td> 

						 <td><p> 

								 <input name="cstCCV" type="text" value="<cfoutput>#FORM.cstCCV#</cfoutput>" size="4" maxlength="4"> 

								 <br /> 

								<span class="smallprint">This is the 3 digit number<br /> 

								that appears on the reverse side of your <br /> 

								credit card (where your signature appears).<br /> 

								Amex cards only - the 4 digit number on <br /> 

								the front of your card.</span><br /> 

								 <br /> 

								 <img src="cw3/assets/cards/ccv.gif" width="135" height="86"></p></td> 

					 </tr> 

				</table> 
 

				<input name="placeorder" type="submit" class="formButton" value="Place Order">

				<input name="action" type="hidden" value="placeorder">

</CFIF>
 

				 <cfelseif request.PaymentAuthType EQ "Processor"> 

				 <p>Once you click Place Order below you will receive an order number. On

				 	the next page you will need to process your payment through our third party

				 	payment processor before your order will be shipped. </p> 

			 </cfif> 

			<cfif Client.ShipPref EQ 0 AND application.enableshipping EQ 1>

				<p>You must choose a shipping method to complete your order</p>

				<cfelse>
 

			</cfif> 

			<input type="hidden" name="PickShipPref" value="<cfoutput>#Client.ShipPref#</cfoutput>">

		 </form> 
 

This is in the CWTagProcessOrder.cfm file, which is the cfmodule called when the Place Order button is clicked, in order to validate the form:
 

  <!--- Validate Credit Card Input --->

  <cfparam name="request.FieldInvalid" default="NO">

	<cfif request.PaymentAuthType EQ "Gateway" OR request.PaymentAuthType EQ "None">

	  <CFIF "<cfoutput>#FORM.cst_terms#</cfoutput>" CONTAINS "Net30">

		<cfscript>

		// Check that PO Number is not blank

		if  (FORM.cstPONumber eq "")

			{ request.FieldErrorPON = "<br />P.O. Number cannot be blank.";

			 request.FieldInvalid = "YES";

		}

		</cfscript>

	  <CFELSE>

		<cfscript>

		// Check Card holder name

		if (FORM.cstCCardHolderName eq "")

			{ request.FieldErrorCHN = "<br />Card Holder Name cannot be blank.";

			 request.FieldInvalid = "YES";

		}

		

		// Check C Card Type

		if (FORM.cstCCardType eq "forgot")

			{ request.FieldErrorCT = "<br />Please choose your credit card type.";

			 request.FieldInvalid = "YES";

		}
 

		// Check C Card Number

		thisCCNum = FORM.cstCCNumber;

		ccLength = 16;

		altccLength = 16;

		ccvLength = 3;

		if(FORM.cstCCardType EQ "amex"){

			ccLength = 15;

			altccLength = 15;

			ccvLength = 4;

		}

		

		if(Form.cstCCardType EQ "visa"){      

			altccLength = 13; // visa now accepts 13 and 16 character numbers, so allow both    

		}

		

		if (IsNumeric(thisCCNum) IS "FALSE" OR (Len(thisCCNum) NEQ ccLength And Len(thisCCNum) NEQ altccLength)){ 

			request.FieldErrorCN = "<br />You did not enter a valid credit card number.";

			request.FieldInvalid = "YES";

		}

		

		if (IsNumeric(FORM.cstCCV) IS "FALSE" OR Len(FORM.cstCCV) LT ccvLength)

			{ request.FieldErrorCCV = "<br />You did not enter a CCV code.";

			 request.FieldInvalid = "YES";

		}

		

		// Check C Card Expr Month

		if (FORM.cstExprMonth eq "forgot"){ 

			request.FieldErrorCM ="<br />Please choose the month your card expires.";

			request.FieldInvalid = "YES";

		}

		

		// Check C Card Expr Year

		if (FORM.cstExprYr eq "forgot"){ 

			request.FieldErrorCY = "<br />Please choose the year your card expires.";

			request.FieldInvalid = "YES";

		}

		</cfscript>

	  </cfif>

	</cfif>

Open in new window

0
Comment
Question by:tam423
  • 6
  • 6
12 Comments
 
LVL 4

Expert Comment

by:msfletch
ID: 21756754
Tam423,

Perhaps the easiest way I can think of is to pass the radio button value back and then run the javascript accordingly on page load like:

[LINE 34]
<input type='radio' id=ra1 name=ra1 value=1 onClick="checkClick(this.value)"<cfif IsDefined('ra1') AND (ra1) IS 1> checked</cfif>>
<label for=ra1>Purchase Order</label><br>
<input type='radio' id=ra2 name=ra1 value=2 onClick="checkClick(this.value)"<cfif IsDefined('ra1') AND (ra1) IS 2> checked</cfif>>
<label for=ra2>Credit Card</label>

[BODY TAG]
<body<cfif IsDefined ('request.FieldErrorPON') AND IsDefined('ra1')> onLoad="checkClick(#ra1#)"</cfif>

You could also try using the same criteria on the individual table elements directly with something like:

<table id=tbox1 style="display:<cfif IsDefined ('request.FieldErrorPON')>block<cfelse>none</cfif>" cellpadding="0" cellspacing="0" border="0">
0
 

Author Comment

by:tam423
ID: 21756988
Hello msfletch,

Thank you so much for your response. What you are describing does make sense, but when I try this, the page returns as before, with no validation or display of the hidden form, based on the radio button selected. I tried just the IsDefined part to see if it is even registering as being defined, and it is not:

<input type='radio' id=ra1 name=ra1 value=1 onClick="checkClick(this.value)"<cfif IsDefined('ra1')>checked<cfelse>unchecked</cfif>>

Submitting the form just brings it back without the radio button being checked and viewing the source code shows "unchecked" in the radio input field. So it seems that these elements are remaining undefined upon submission and is probably the root of my problem, and if I could resolve why and how to get them defined, based on radio button selection, I might at least be on the road to a solution. Do I have something wrong with how I have the radio buttons defined and/or the javascript code for hiding/displaying? Could the call to the cfmodule for validation of the form be the problem, whereby when it is processed and the showcart.cfm is redisplayed, those elements are once again undefined? Perhaps I cannot use the same validation script that is being used when the credit card form is always displayed (a non-Net 30 customer) and need to create a completely different one, that will work with this type of hide/show javascript. I just don't know. I'm comfortable with ColdFusion, but am pretty much a beginner with javascript things. If you might have any further insight on this, I would SO appreciate it! :-)
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21757244
So it sounds like the issue is with values being lost between form submission and return to the form page for error display? Hmmm...

So I can see where the custom tag returns "request.FieldInvalid" and the error for each field, but it doesn't seem to return any values from the form fields themselves. For instance, if "FORM.cstCCNumber" is incorrectly formatted does it return the variable "cstCCNumber"?

I am not so good at troubleshooting things I can't see in action, but you can try adding some variables to the custom tag to see if they get returned on error. For instance, after all the <CFSCRIPT> tags and between the two </cfif> tags at the bottom you could add:

<cfif IsDefined('FORM.ra1')>
    <cfset request.ra1 = #FORM.ra1#>
</cfif>

Then change the <cfif> tags described in previous post use "request.ra1" instead of "ra1". If that returns the value for the radio buttons, then you can do the same for anything else you need returned.
0
 

Author Comment

by:tam423
ID: 21757564
Thanks again. I tried what you suggested, but still nothing happens. I think that I will have to start from scratch with the validation. I am modifying an existing shopping cart system, with the addition of the hide/show form fields and radio buttons, and I just don't think that the existing validation method works for this. Unfortunately, I just don't know why or how to change it to make it work. Anyway, I will work on this further tomorrow. There must be some way using client-side rather than server-side scripting to validate form fields that are initially hidden, but then made visible based on a radio button selection, so that the page returns with the fields remaining visible and highlighted for completion. I am open to creating a completely different method for validation, so I will work on that. What you have suggested seems logical and should work, I would think, so perhaps when I come up with something else, I can incorporate your suggestions and I will have some success. Thank you again, msfletch, for your prevous suggestions.
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21762012
Sorry I couldn't be more helpful. I have included two pages where I am essentially doing what I think you are trying to do. You may be able to find something useful in this code. The first page is the form page for collecting payment information.
<!--- #################### GET CLIENT INFORMATION #################### --->
 

<!--- check for existance of client code --->

<cfinclude template="inc_client_code_check.cfm">
 

<cfquery name="getClientSpecs" datasource="#whichDataSource#">

	SELECT c.*,

		c.businessName AS clientCompanyName,

		c.useCustomDropDown,

		c.customDropDownPrompt,

		c.useUniqueId,

		c.uniqueIdPrompt,

		c.acctPrompt,

		c.clientID,

		c.flags,

		i.acceptVisa,

		i.acceptMasterCard,

		i.acceptAmex,

		i.acceptDiscover,

		d.active AS liveAccount

	FROM clients c WITH (NOLOCK)

		INNER JOIN doctor d WITH (NOLOCK) ON d.doctorId = c.clientId

		INNER JOIN intellipay i WITH (NOLOCK) ON i.intellipayId = d.intellipayId

	WHERE c.clientCode=<cfqueryparam value="#clientCode#" CFSQLType="CF_SQL_VARCHAR" MaxLength="30">

</cfquery>
 

<!--- translate query results into normal variables --->

<cfif (getClientSpecs.RecordCount) GT 0>

	<cfoutput>

		<cfset topImage = "#getClientSpecs.topImage#">

		<cfset clientCompanyName = "#getClientSpecs.clientCompanyName#">

		<cfset clientHomePage = "#getClientSpecs.clientHomePage#">

		<cfset titleBoxColor = "#getClientSpecs.titleBoxColor#">

		<cfset clientID = "#getClientSpecs.clientID#">

		<cfset acceptVisa = "#getClientSpecs.acceptVisa#">

		<cfset acceptMasterCard = "#getClientSpecs.acceptMasterCard#">

		<cfset acceptAmex = "#getClientSpecs.acceptAmex#">

		<cfset acceptDiscover = "#getClientSpecs.acceptDiscover#">

		<cfset liveAccount = "#getClientSpecs.liveAccount#">

		<cfset acctPrompt = "#getClientSpecs.acctPrompt#">

		<cfset flags = "#getClientSpecs.flags#">

		<!--- set whether client accepts ACH payments --->

		<cfif mid(flags, 2, 1) EQ "1">

			<cfset acceptACH = 1>

		<cfelse>

			<cfset acceptACH = 0>

		</cfif>

		<!--- set whether client accepts credit cards in general --->

		<cfif mid(flags, 3, 1) EQ "1">

			<cfset acceptCC = 1>

		<cfelse>

			<cfset acceptCC = 0>

		</cfif>

		<!--- set which payment method client wants as default --->

		<cfif mid(flags, 4, 1) EQ "1">

			<cfset defaultPaymentMethod = "1">

		<cfelseif mid(flags, 4, 1) EQ "2">

			<cfset defaultPaymentMethod = "3">

		<cfelseif mid(flags, 4, 1) EQ "3">

			<cfset defaultPaymentMethod = "2">

		</cfif>

		<!--- check if client allows customer lookup --->

		<cfif mid(flags, 5, 1) EQ "1">

			<cfset allowLookup = 0>

		<cfelse>

			<cfset allowLookup = 1>

		</cfif>

		<!--- check if customer wants the customer account required --->

		<cfif mid(flags, 8, 1) EQ "1">

			<cfset requireCustomerAccount = 1>

		<cfelse>

			<cfset requireCustomerAccount = 0>

		</cfif>

		<cfset acctPrompt = "#getClientSpecs.acctPrompt#">

		<cfset uniqueIdPrompt = "#getClientSpecs.uniqueIdPrompt#">

		<cfset useUniqueId = "#getClientSpecs.useUniqueId#">

		<cfset useCustomDropDown = "#getClientSpecs.useCustomDropDown#">

		<cfset customDropDownPrompt = "#getClientSpecs.customDropDownPrompt#">

	</cfoutput>

<cfelse>

	<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

    <!--

	    alert('A client record matching your code was not found or your account does not have the proper setup to use VTFusion. Please contact Modern Payments with any questions at 801.748.0333. Thank you.');

		self.close();

    //-->

    </SCRIPT>

	<!--- stop running coldfusion on this page --->

	<cfabort>

</cfif>
 

<!--- check if custom drop-down is being used --->

<cfif (useCustomDropDown) IS 1>

	<cfquery name="getCustomDropDowns" datasource="#whichDataSource#">

		SELECT *

		FROM collectorDepartments WITH (NOLOCK)

		WHERE doctorId = #clientID#

		ORDER BY deptName

	</cfquery>

</cfif>
 

<!--- get list of fees for this client --->

<cfquery name="getCustomFees" datasource="#whichDataSource#">

	SELECT *

	FROM clientFees WITH (NOLOCK)

	WHERE doctorId = #clientID#

	ORDER BY feeType

</cfquery>
 

<!--- get list of states and their fee restrictions --->

<cfquery name="getStates" datasource="#whichDataSource#">

	SELECT state AS stateAbbrev, 

		restricted, 

		maxFee

	FROM stateFees WITH (NOLOCK)

	ORDER BY state

</cfquery>
 

<!--- run query of queries to get states that do not allow fees --->

<cfquery name="noFeeStates" dbtype="query">

	SELECT stateAbbrev

	FROM getStates

	WHERE restricted = 1

	ORDER BY stateAbbrev

</cfquery>
 
 

<!--- #################### SECURE SECTION #################### --->
 

<!--- set login requirement value from client flags --->

<cfset loginReq = #LEFT(getClientSpecs.flags, 1)#>
 

<!--- reset duplicate payment value in session --->

<cfset session.dupPayment = 0>

            

<!--- check login requirement value --->

<cfif IsDefined('loginReq') AND (loginReq) IS 1>

	<!--- include security code --->

	<!-- INCLUDED SECURITY FUNCTIONS --->

	<cfset noError = 1><!--- keeps secure page from saying session expired --->

	<cfinclude template="secure.cfm">

</cfif>
 

<!--- #################### DEFAULT VALUES AND DISPLAY VARIABLES #################### --->
 

<!--- set content and element variables --->

<cfif (allowLookup) IS 1>

	<cfset focusField = "lookupForm.customerAccount">

<cfelse>

	<cfset focusField = "form.customerAccount">

</cfif>

<cfset headerContent = "Enter Billing and Payment Information">

<cfset buttonText = "Submit">

<!--- check for a return error which means totals should be calculated --->

<cfif IsDefined('errorMessage') AND (errorMessage) IS NOT "">

	<cfset onLoadScript = "displayPaymentMethod(); totalPaymentCalc()">

<cfelse>

	<cfset onLoadScript = "displayPaymentMethod()">

</cfif>

<cfif IsDefined('focusField') AND (focusField) IS NOT "">

	<cfset onLoadScript = "#onLoadScript#; document.#focusField#.focus();">

</cfif>
 

<!--- check if a customer account number was passed --->

<cfif (IsDefined('customerAccount') AND (customerAccount) IS NOT "") AND (IsDefined('errorMessage') IS "No" OR (errorMessage) IS "")>
 

	<!--- lookup data from the DB --->

	<cfquery name="getCustomerData" datasource="#whichDataSource#">

		SELECT TOP 1 *

		FROM patient

		WHERE doctorID = #clientID#

			AND patientAccount = '#customerAccount#'

		ORDER BY entryDate DESC

	</cfquery>

	

	<!--- check if there was a result from the database --->

	<cfif IsDefined('getCustomerData.RecordCount') AND (getCustomerData.RecordCount) GT 0>
 

		<!--- function for encrypting credit cards --->

		<cffunction name="modEncrypt" access="remote" returnType="string">

			<cfargument name="source" type="String" required="Yes">

			<cfregistry action="GET" branch="HKEY_LOCAL_MACHINE\SOFTWARE\Modpay\Security" entry="3DES_Key" variable="Key">

			<cfset key = Trim(Key)>

			<cfset e = Encrypt(source, Key, "DESEDE")>

			<cfreturn e>

		</cffunction>

		

		<!--- function for decrypting credit card --->

		<cffunction name="modDecrypt" access="remote" returnType="string">

			<cfargument name="source" type="String" required="Yes">

			<cfregistry action="GET" branch="HKEY_LOCAL_MACHINE\SOFTWARE\Modpay\Security" entry="3DES_Key" variable="Key">

			<cfset key = Trim(Key)>

			<cfset d = Decrypt(source, Key, "DESEDE")>

			<cfreturn d>

		</cffunction>
 

		<!--- set default values from query above --->

		<cfset patientID = "#getCustomerData.patientID#">

		<cfset customerAccount = "#getCustomerData.patientAccount#">

		<cfset businessName = "#getCustomerData.CompanyName#">

		<cfset department = "#getCustomerData.secondId#">

		<cfset firstName = "#getCustomerData.firstName#">

		<cfset lastName = "#getCustomerData.lastName#">

		<cfset address = "#getCustomerData.address#">

		<cfset city = "#getCustomerData.city#">

		<cfset state = "#getCustomerData.state#">

		<cfset zipCode = "#getCustomerData.zip#">

		<cfset phone1 = "#getCustomerData.phone#">

		<cfset phone2 = "#getCustomerData.fax#">

		<cfset email = "#getCustomerData.email#">

		<cfif IsDefined('getCustomerData.isSavingsAcct') AND (getCustomerData.isSavingsAcct) IS 1>

			<cfset savingsName = "#getCustomerData.accountName#">

			<cfset savingsRouting = "#getCustomerData.routingABA#">

			<cfset savingsAccount = "#getCustomerData.bankAccountNum#">

			<cfif (savingsAccount) IS NOT "">

				<!--- truncate account number for display --->

				<cfset savingsAccount = "#LEFT(getCustomerData.bankAccountNum, 1)#...#RIGHT(getCustomerData.bankAccountNum, 4)#">

				<!--- set value for preexisting savings account number --->

				<cfset existingSaveAcct = 1>

			</cfif>

		<cfelse>

			<cfset checkName = "#getCustomerData.accountName#">

			<cfset checkRouting = "#getCustomerData.routingABA#">

			<cfset checkAccount = "#getCustomerData.bankAccountNum#">

			<!--- check for account number --->

			<cfif (checkAccount) IS NOT "">

				<!--- truncate account number for display --->

				<cfset checkAccount = "#LEFT(getCustomerData.bankAccountNum, 1)#...#RIGHT(getCustomerData.bankAccountNum, 4)#">

				<!--- set value for preexisting checking account number --->

				<cfset existingCheckAcct = 1>

			</cfif>

		</cfif>

		<cfset cardName = "#getCustomerData.ccName#">

		<cfset cardAccount = "#getCustomerData.ccNum#">

		<!--- check if cc number exists --->

		<cfif (getCustomerData.ccNum) IS NOT "">

			<!--- decrypt card --->

			<cfset cardAccount = "#modDecrypt(getCustomerData.ccNum)#">

			<!--- truncate credit card info for display --->

			<cfset cardAccount = "#LEFT(cardAccount, 6)#...#RIGHT(cardAccount, 4)#">

			<!--- set value for preexisting credit card --->

			<cfset existingCCNum = 1>

		</cfif>

		<cfset cardExp = "#NumberFormat(getCustomerData.expMonth, "99")#/#NumberFormat(getCustomerData.expYear, "9999")#">

		

	</cfif>
 

</cfif>
 

<!--- set default values --->

<cfparam name="customerAccount" default="">

<cfparam name="uniqueID" default="">

<cfparam name="useCustomDropDown" default="0">

<cfparam name="customDropDownPrompt" default="">

<cfparam name="department" default="">

<cfparam name="customerType" default="1">

<cfparam name="businessName" default="">

<cfparam name="firstName" default="">

<cfparam name="lastName" default="">

<cfparam name="address" default="">

<cfparam name="city" default="">

<cfparam name="state" default="">

<cfparam name="noFeeState" default="">

<cfparam name="zipCode" default="">

<cfparam name="phone1" default="">

<cfparam name="phone2" default="">

<cfparam name="email" default="">

<cfparam name="amount" default="">

<cfparam name="transDate" default="">

<cfparam name="feeStructure" default="">

<cfparam name="feeTotal" default="$ 0.00">

<cfparam name="transFee" default="$ 0.00">

<cfparam name="percFee" default="$ 0.00">

<cfparam name="totalAmount" default="$ 0.00">

<cfparam name="paymentMethod" default="0">

<cfparam name="paymentAuth" default="">

<cfparam name="checkName" default="">

<cfparam name="checkNumber" default="">

<cfparam name="checkRouting" default="">

<cfparam name="checkAccount" default="">

<cfparam name="savingsName" default="">

<cfparam name="savingsRouting" default="">

<cfparam name="savingsAccount" default="">

<cfparam name="cardName" default="">

<cfparam name="cardAccount" default="">

<cfparam name="cardExp" default="">

<cfparam name="notes" default="">

<cfparam name="existingCCNum" default="0">

<cfparam name="existingCheckAcct" default="0">

<cfparam name="existingSaveAcct" default="0">

<cfparam name="query_str" default="">
 

<!--- #################### BEGIN MAIN CONTENT #################### --->
 

<!--- include vcollect header --->

<cfinclude template="header.cfm">
 

<!--- ##### INCLUDE ANY JAVASCRIPT HERE ##### --->
 

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

<!--

	function displayName(whichType) {

		// if individual was selected

		if (whichType.value == 1) {

			HideContent("business");

			ShowContent("individual");

		// if company was selected

		}

		// if company was selected

		if (whichType.value == 2) {

			HideContent("individual");

			ShowContent("business");

		}

	}

	

	function displayPaymentMethod() {

		// set variable with the selected payment method

		var whichPaymentMethod = document.form.paymentMethod.options[document.form.paymentMethod.selectedIndex].value;

		// if checking was selected

		if (whichPaymentMethod == 1) {

			<cfif (acceptACH) IS 1>

			HideContent("savingsDisplay");

			</cfif>

			<cfif (acceptCC) IS 1>

			HideContent("creditCardDisplay");

			</cfif>

			<cfif (acceptACH) IS 1>

			ShowContent("checkingDisplay");

			ShowContent("payAuthDisplay");

			</cfif>

		}

		// if savings was selected

		if (whichPaymentMethod == 2) {

			<cfif (acceptACH) IS 1>

			HideContent("checkingDisplay");

			</cfif>

			<cfif (acceptCC) IS 1>

			HideContent("creditCardDisplay");

			</cfif>

			<cfif (acceptACH) IS 1>

			ShowContent("savingsDisplay");

			ShowContent("payAuthDisplay");

			</cfif>

		}

		// if credit card was selected

		if (whichPaymentMethod == 3) {

			<cfif (acceptACH) IS 1>

			HideContent("checkingDisplay");

			</cfif>

			<cfif (acceptACH) IS 1>

			HideContent("savingsDisplay");

			</cfif>

			<cfif (acceptCC) IS 1>

			ShowContent("creditCardDisplay");

			HideContent("payAuthDisplay");

			</cfif>

		}

	}

	

	<!--- create function for calculating fees according to what was found --->

	function totalPaymentCalc() {

	

		// get amount from the amount field.

		var initAmount = document.form.amount.value;

		

		// clean amount value from all non-numeric characters except for decimal point

		var initAmountClean = initAmount.replace(/[^0-9|\.]/g, ''); 

		

		// alert('Clean Amount Is:' + initAmountClean);

		// set default fee amount

		var feeAmount = 0;

		

		// set default total amount

		var totalPayment = 0;

		

		// get current fee structure selected

		var feeChosen = document.form.feeStructure.options[document.form.feeStructure.selectedIndex].value;

		

		// get current payment type

		var payTypeChosen = document.form.paymentMethod.options[document.form.paymentMethod.selectedIndex].value;

		

		// get current state

		var stateChosen = document.form.state.options[document.form.state.selectedIndex].value;

		

		// check if amount is zero ... in which case no calculating necessary

		if (initAmountClean == 0 || initAmountClean == "") { // || isNaN(initAmount)

		

			// set fee total to zero

			document.form.feeTotal.value = "$ 0.00"

			// set hidden precentage fee field to zero

			document.form.percFee.value = "$ 0.00";

			// set hiddentrans fee field to zero

			document.form.transFee.value = "$ 0.00";

			// set total amount to zero

			document.form.totalAmount.value = "$ 0.00";

			// do not update fee structure selected

			

			// check for no fee state

			if (stateChosen == "ZZ"<cfoutput query="noFeeStates"> || stateChosen == "#stateAbbrev#"</cfoutput>) {

				// hide fee selection box

				HideContent("feeSelection");

				// show no fee message

				ShowContent("noFeesMessage");

				// set no state variable

				document.form.noFeeState.value = 1;	

			} else {

				// hide no fee message

				HideContent("noFeesMessage");

				// show fee selection box

				ShowContent("feeSelection");

				// set no state variable

				document.form.noFeeState.value = 0;	

			}

		

		// if amount is not zero

		} else {

		

			// check if the state selected is one that does not allow fees

			if (stateChosen == "ZZ"<cfoutput query="noFeeStates"> || stateChosen == "#stateAbbrev#"</cfoutput>) {

				

				// set fee total to zero

				document.form.feeTotal.value = "$ 0.00";

				// set hidden precentage fee field to zero

				document.form.percFee.value = "$ 0.00";

				// set hiddentrans fee field to zero

				document.form.transFee.value = "$ 0.00";

				// set totalAmount to value of amount

				document.form.totalAmount.value = "$ " + CurrencyFormatted(initAmountClean);		

				// set no state variable

				document.form.noFeeState.value = 1;	

				// hide fee selection box

				HideContent("feeSelection");

				// show no fee message

				ShowContent("noFeesMessage");

			

			} else {
 

				// default no fee option

				if (feeChosen == 0) {

					// set fee total to zero

					document.form.feeTotal.value = "$ 0.00";

					// set hidden precentage fee field to zero

					document.form.percFee.value = "$ 0.00";

					// set hiddentrans fee field to zero

					document.form.transFee.value = "$ 0.00";

					// set totalAmount to value of amount

					document.form.totalAmount.value = "$ " + CurrencyFormatted(initAmountClean);			

				}

			

			<!--- check if there were any results from the fee query --->

			<cfif IsDefined('getCustomFees.RecordCount') AND (getCustomFees.RecordCount) GT 0>

			

				<!--- loop through the fee structures and create an IF statement for each one --->

				<cfoutput query="getCustomFees">

					

					if (feeChosen == #feeID#) {

					

						// check for payment type

						if (payTypeChosen == 1 || payTypeChosen == 2) {

							// multiply amount by percentage

							feeAmount = parseFloat(initAmountClean) * parseFloat(#VAL(achPercFee/100)#);

							// set hidden field to value or percentage

							document.form.percFee.value = feeAmount;

							// set hidden field to value of the trans fee

							document.form.transFee.value = parseFloat(#VAL(achTransFee)#);

							// add per trans fee

							feeAmount = parseFloat(feeAmount) + parseFloat(#VAL(achTransFee)#);

						}

						

						if (payTypeChosen == 3) {

							// multiply amount by percentage

							feeAmount = parseFloat(initAmountClean) * parseFloat(#VAL(ccPercFee/100)#);

							// set hidden field to value or percentage

							document.form.percFee.value = feeAmount;

							// set hidden field to value of the trans fee

							document.form.transFee.value = parseFloat(#VAL(ccTransFee)#);

							// add per trans fee

							feeAmount = parseFloat(feeAmount) + parseFloat(#VAL(ccTransFee)#);

						}

						

					}

				

				</cfoutput>

			

			</cfif>

			

			// update fee total

			document.form.feeTotal.value = "$ " + CurrencyFormatted(feeAmount);

			// add fee to amount

			totalPayment = (Math.round((parseFloat(initAmountClean) + parseFloat(feeAmount)) * 100) / 100);

			// format total payment

			document.form.totalAmount.value = "$ " + CurrencyFormatted(totalPayment);

			// reformat the amount field to conform to currency display standards

			document.form.amount.value = "$ " + CurrencyFormatted(initAmountClean);

			// set no state variable

			document.form.noFeeState.value = 0;	

			// hide fee selection box

			HideContent("noFeesMessage");

			// show no fee message

			ShowContent("feeSelection");

			

			}

		}

	}

	

	// function for formatting numbers in currency format

	function CurrencyFormatted(amount)

	{

		var i = parseFloat(amount);

		if (isNaN(i)) {

			i = 0.00;

		}

		var minus = '';

		if (i < 0) { 

			minus = '-'; 

		}

		i = Math.abs(i);

		i = parseInt((i + .005) * 100);

		i = i / 100;

		s = new String(i);

		if (s.indexOf('.') < 0) { 

			s += '.00'; 

		}

		if (s.indexOf('.') == (s.length - 2)) { 

			s += '0'; 

		}

		s = minus + s;

		s = CommaFormatted(s)

		return s;

	}

	

	// function for formating numbers with embedded commas

	function CommaFormatted(amount)

	{

		var delimiter = ","; // replace comma if desired

		var a = amount.split('.',2)

		var d = a[1];

		var i = parseInt(a[0]);

		if (isNaN(i)) { 

			return ''; 

		}

		var minus = '';

		if (i < 0) { 

			minus = '-'; 

		}

		i = Math.abs(i);

		var n = new String(i);

		var a = [];

		while(n.length > 3)

		{

			var nn = n.substr(n.length-3);

			a.unshift(nn);

			n = n.substr(0,n.length-3);

		}

		if (n.length > 0) { 

			a.unshift(n); 

		}

		n = a.join(delimiter);

		if (d.length < 1) { 

			amount = n; 

		} else { 

			amount = n + '.' + d; 

		}

		amount = minus + amount;

		return amount;

	}

	

	// function for checking the routing number or credit card number in the background

	function validateAccountNumber() {

		// clear verification results when running a verification

		clearVerificationResults;

		// find out which account is being used

		var payTypeChosen = document.form.paymentMethod.options[document.form.paymentMethod.selectedIndex].value;

		// set default values

		var routingNumber = "";

		var ccNumber = "";

		// if checking account chosen ... send routing

		if (payTypeChosen == 1) {

			// get correct value

			routingNumber = document.form.checkRouting.value;

			// initiate check through iFrame

			document.frames['queryframe'].location.replace('check_account.cfm?routingABA='+routingNumber);

		}

		// if savings account chosen ... send routing

		if (payTypeChosen == 2) {

			// get correct value

			routingNumber = document.form.savingsRouting.value;

			// initiate check through iFrame

			document.frames['queryframe'].location.replace('check_account.cfm?routingABA='+routingNumber);

		}

		// if credit card chosen ... send cc number

		if (payTypeChosen == 3) {

			// get correct value

			ccNumber = document.form.cardAccount.value;

			// initiate check through iFrame

			document.frames['queryframe'].location.replace('check_account.cfm?ccNumber='+ccNumber);

		}

	}

	

	// function for processing the returned value from the background queries

	function routingReturn(type, returnedValue) {

		// show return display div

		ShowContent('showVerificationResults');

		// if returned a routing number verification

		if (type == "routing") {

			// if a bad routing number format

			if (returnedValue == "badFormat") {

				document.form.resultsField.className = "invisibleFieldERROR";

				document.form.resultsField.value = "INCORRECT ROUTING NUMBER FORMAT";

			}

			// if it did not match a known routing number

			if (returnedValue == "noMatch") {

				document.form.resultsField.className = "invisibleFieldERROR";

				document.form.resultsField.value = "INVAILD ROUTING NUMBER";

			}

			// if it returned an otherwise unexpected value ... it is likely a bank name

			if (returnedValue != "badFormat" && returnedValue != "noMatch" && returnedValue != "") {

				document.form.resultsField.className = "invisibleFieldOK";

				document.form.resultsField.value = "VALID: " + returnedValue + "";

			}

		}

		// if returning a credit card verification

		if (type =="creditcard") {

			// if returned valid credit card number

			if (returnedValue != "invalidCC") {

				document.form.resultsField.className = "invisibleFieldOK";

				document.form.resultsField.value = "VALID: " + returnedValue + "";

			}

			// if returned invalid credit card number

			if (returnedValue == "invalidCC") {

				document.form.resultsField.className = "invisibleFieldERROR";

				document.form.resultsField.value = "INVALID CREDIT CARD NUMBER";

			}

		}
 

	}

	

	// function for clearing verification results

	function clearVerificationResults() {

		// hide content area

		HideContent("showVerificationResults");

		// clear results in form field

		document.form.resultsField.value = "";

	}
 

//-->

</SCRIPT>
 

<cfoutput>
 

<!--- start form here if no lookup functionality --->

<cfif (allowLookup) IS NOT 1>

<form name="form" method="post" action="verify.cfm">

</cfif>
 
 

<tr bgcolor="efefef">

	<td width=100% valign=top colspan=3>

	<table cellpadding=0 cellspacing=0 border=0 width=100%>

	<tr>

		<!--- TABLE: right spacer --->

		<td width=10><img src="images/spacer.gif" width="10" height="1"></td>

		

		<td width="46%" valign=top>

		

		<!--- ##### BEGIN BILLING INFO FORM ##### --->

		<table cellpadding=0 cellspacing=0 border=0 width=100%>

		<tr>

			<cfif (allowLookup) IS 1>

				<!--- start lookup form --->

				<form name="lookupForm" method="post" action="payment.cfm">

				<td colspan=3>

				<table cellpadding=0 cellspacing=0 border=0 width=100%>

				<tr>

					<td width="*" class="<cfif (requireCustomerAccount) IS 1>requiredFieldName<cfelse>fieldName</cfif>">#acctPrompt#<br><input type=text name="customerAccount" value="#customerAccount#" class="textFieldStretch" onChange="document.form.customerAccountHidden.value=document.lookupForm.customerAccount.value;"></td>

					<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

					<td width="50" class="fieldName">&nbsp;<br><input type=submit value="look-up" class="buttonStretched"></td>

				</tr>

				</table>

				</td>

				<!--- include hidden field with clientCode --->

				<input type="hidden" name="clientCode" value="#clientCode#">

				<!--- end lookup form --->

				</form>

				<!--- starting full form here if lookup functionality is enabled --->

				<form name="form" method="post" action="verify.cfm">

				<!--- input case# into a hidden field for the full form --->

				<input type=hidden name="customerAccountHidden" value="#customerAccount#">

			<cfelse>

				<td colspan=3 class="<cfif (requireCustomerAccount) IS 1>requiredFieldName<cfelse>fieldName</cfif>">#acctPrompt#<br><input type=text name="customerAccount" value="#customerAccount#" class="textFieldStretch" onChange="document.form.customerAccountHidden.value=document.form.customerAccount.value;"><input type=hidden name="customerAccountHidden" value="#customerAccount#"></td>

			</cfif>

		</tr>

		<!--- check if client wants unique ID to be included --->

		<cfif (useUniqueId) IS 1>

			<tr>

				<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

			</tr>

			<tr>

				<td colspan=3 class="fieldName">#uniqueIdPrompt#<br><input type=text name="uniqueID" value="#uniqueID#" class="textFieldStretch"></td>

			</tr>

		</cfif>

		<!--- check if client wants to use the custom drop-down --->

		<cfif (useCustomDropDown) IS 1 AND IsDefined('getCustomDropDowns.RecordCount') AND (getCustomDropDowns.RecordCount) GT 0>

			<tr>

				<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

			</tr>

			<tr>

				<td colspan=3 class="fieldName">#customDropDownPrompt#<br><select name="department" class="textFieldStretch">

					<cfloop query="getCustomDropDowns">

						<option value="#deptID#"<cfif (department) IS NOT ""><cfif (department) IS #deptID#> selected</cfif><cfelse><cfif (defaultItem) IS 1> selected</cfif></cfif>>#deptName#<cfif (defaultItem) IS 1> (default)</cfif></option>

					</cfloop>

				</select></td>

			</tr>

		</cfif>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3 class="fieldName">Customer Type</td>

		</tr>

		<tr>

			<td colspan=3 class="fieldName" align=left>

			<table cellpadding=0 cellspacing=0 border=0 width=60%>

			<tr>

				<td valign="bottom" class="fieldName" width="10%"><input type="radio" name="customerType" value="1" checked onClick="displayName(this)"<cfif (customerType) IS 1> checked</cfif>></td>

				<td valign="bottom" width="40%" class="fieldName">Individual</td>

				<td valign="bottom" class="fieldName" width="10%"><input type="radio" name="customerType" value="2" onClick="displayName(this)"<cfif (customerType) IS 2> checked</cfif>></td>

				<td valign="bottom" width="40%" class="fieldName">Business</td>

			</tr>

			</table>

			</td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3>

			<div id="individual" style="display:<cfif (customerType) IS 1>block<cfelse>none</cfif>">

			<table cellpadding=0 cellspacing=0 border=0 width=100%>

			<tr>

				<td width=48% class="requiredFieldName">First Name<br><input type=text name="firstName" value="#firstName#" class="textFieldStretch"></td>

				<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

				<td width=48% class="requiredFieldName">Last Name<br><input type=text name="lastName" value="#lastName#" class="textFieldStretch"></td>

			</tr>

			</table>

			</div>

			<div id="business" style="display:<cfif (customerType) IS 2>block<cfelse>none</cfif>">

			<table cellpadding=0 cellspacing=0 border=0 width=100%>

			<tr>

				<td class="requiredFieldName">Business Name<br><input type=text name="businessName" value="#businessName#" class="textFieldStretch"></td>

			</tr>

			</table>

			</div>

			</td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3 class="fieldName">Address<br><input type=text name="address" value="#address#" class="textFieldStretch"></td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3>

			<table cellpadding=0 cellspacing=0 border=0 width=100%>

			<tr>

				<td class="fieldName" width=52%>City<br><input type=text name="city" value="#city#" class="textFieldStretch"></td>

				<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

				<td class="requiredFieldName" width=15%>State<br><select name="state" class="textFieldStretch" onChange="totalPaymentCalc()">

					<option value="">--</option>

					<cfloop query="getStates">

						<option value="#stateAbbrev#"<cfif (state) IS "#stateAbbrev#"> selected</cfif>>#stateAbbrev#</option>

					</cfloop>

				</select></td>

				<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

				<td class="requiredFieldName" width=25%>Zip Code<br><input type=text name="zipCode" value="#zipCode#" class="textFieldStretch"></td>

			</tr>

			</table>

			</td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td width=48% class="fieldName">Primary Phone<br><input type=text name="phone1" value="#phone1#" class="textFieldStretch"></td>

			<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

			<td width=48% class="fieldName">Secondary Phone<br><input type=text name="phone2" value="#phone2#" class="textFieldStretch"></td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3 class="fieldName">Email<br><input type=text name="email" value="#email#" class="textFieldStretch"></td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		</table>

		</td>
 

		<!--- TABLE: center divider --->

		<td width=10><img src="images/spacer.gif" width="10" height="1"></td>

		<td width=2 class="dividerBar"><img src="images/spacer.gif" width="2" height="1"></td>

		<td width=10><img src="images/spacer.gif" width="10" height="1"></td>

		

		<td width="*" valign=top>

		

		<!--- ##### BEGIN PAYMENT INFO FORM ##### --->

		

		<table cellpadding=0 cellspacing=0 border=0 width=100%>

			<tr>

				<td width=48% class="requiredFieldName">Amount<br><input type=text name="amount" value="#amount#" class="textFieldStretchRight" onChange="totalPaymentCalc()"></td>

				<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

				<td width=48%>

				<table cellpadding=0 cellspacing=0 border=0 width=100%>

				<tr>

					<td class="requiredFieldName">Payment Date<br><input type=text name="transDate" value="<cfif (transDate) IS NOT "">#DateFormat(transDate, "mm/dd/yyyy")#<cfelse>#DateFormat(now(), "mm/dd/yyyy")#</cfif>" class="textFieldStretch" onClick="displayDatePicker('transDate');"></td>

					<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

					<td class="requiredFieldName">&nbsp;<br><a href="Javascript:displayDatePicker('transDate');"><img src="/admin/images/ico_calendar_bl.gif" width="12" height="12" border="0"></a></td>

				</tr>

				</table>

			</td>

			</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3>

			<!--- include normal fee selection drop-down --->

			<div id="feeSelection" style="display:block">

			<table cellpadding=0 cellspacing=0 width=100% border=0>

			<tr>

				<td class="fieldName" width="70%">Fee Schedule<br><select name="feeStructure" class="textFieldStretch" onChange="totalPaymentCalc()">

				<option value="0">No Fees</option>

				<cfloop query="getCustomFees">

					<option value="#feeID#"<cfif (feeStructure) IS NOT ""><cfif (feeStructure) IS #feeID#> selected</cfif><cfelse><cfif (defaultItem) IS 1> selected</cfif></cfif>>#feeType#<cfif (defaultItem) IS 1> (default)</cfif></option>

				</cfloop>

			</select></td>

				<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

				<td class="fieldName" width="26%">Fee Amount<br><input type=text name="feeTotal" value="$ 0.00" class="textFieldStretchRightDisabled" onFocus="this.blur();" tabIndex="-10"<cfif (feeTotal) IS NOT ""> value="#feeTotal#"</cfif>><input type="hidden" name="transFee" value="0.00"<cfif (transFee) IS NOT ""> value="#transFee#"</cfif>><input type="hidden" name="percFee" value="0.00"<cfif (percFee) IS NOT ""> value="#percFee#"</cfif>></td>

			</tr>

			</table>

			</div>

			<!--- include message for states that don't allow fees --->

			<div id="noFeesMessage" style="display:none">

			<table cellpadding=0 cellspacing=0 width=100% border=0>

			<tr>

				<td class="fieldName" width="100%">Fee Schedule<br><input type=text name="noFeeMessage" class="redTextFieldStretchDisabled" onFocus="this.blur();" tabIndex="-10" value="The state selected does not allow fees."><input type="hidden" name="noFeeState" value="0"></td>

			</tr>

			</table>

			</div>	

			</td>

		</tr>

		<tr>

			<td colspan=3 height="10"><img src="images/spacer.gif" width="5" height="10"></td>

		</tr>

		<tr>

			<td colspan=3 height="2" class="dividerBar"><img src="images/spacer.gif" width="5" height="2"></td>

		</tr>

		<tr>

			<td width=48% class="requiredFieldName" align=right>Total Amount:&nbsp;&nbsp;</td>

			<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

			<td width=48% class="fieldName" align=left>&nbsp;&nbsp;<input type=text name="totalAmount" value="<cfif (totalAmount) IS NOT "">#totalAmount#<cfelse>$ 0.00</cfif>" class="textFieldTotal" onFocus="this.blur();" tabIndex="-10"></td>

		</tr>		

		<tr>

			<td colspan=3 height="2" class="dividerBar"><img src="images/spacer.gif" width="5" height="2"></td>

		</tr>

		<tr>

			<td colspan=3 height="10"><img src="images/spacer.gif" width="5" height="10"></td>

		</tr>

		<tr>

			<td colspan=3 class="requiredFieldName">Payment Method<br><select name="paymentMethod" onChange="displayPaymentMethod(); totalPaymentCalc(); clearVerificationResults();" class="textFieldStretch">

				<!--- make sure ach payments are allowed --->

				<cfif (acceptACH) IS 1>

					<option value="1"<cfif IsDefined('paymentMethod') AND (paymentMethod) IS NOT 0><cfif (paymentMethod) IS 1> selected</cfif><cfelse><cfif (defaultPaymentMethod) IS 1> selected</cfif></cfif>>Checking Account</option>

					<option value="2"<cfif IsDefined('paymentMethod') AND (paymentMethod) IS NOT 0><cfif (paymentMethod) IS 2> selected</cfif><cfelse><cfif (defaultPaymentMethod) IS 2> selected</cfif></cfif>>Savings Account</option>

				</cfif>

				<!--- make sure client accepts CCs --->

				<cfif (acceptCC) IS 1>

					<option value="3"<cfif IsDefined('paymentMethod') AND (paymentMethod) IS NOT 0><cfif (paymentMethod) IS 3> selected</cfif><cfelse><cfif (defaultPaymentMethod) IS 3> selected</cfif></cfif>>Credit Card</option>

				</cfif>

			</select></td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3 class="requiredFieldName">

			<!--- display this only for ACH payments --->

			<div id="payAuthDisplay" style="display:none">

			<table cellpadding=0 cellspacing=0 border=0 width=100%>

			<tr>

				<td colspan=3>

				<table cellpadding=0 cellspacing=0 border=0 width=100%>

				<tr>

					<td width=78% class="requiredFieldName">How Was Payment Authorized?<br><select name="paymentAuth" class="textFieldStretch">

			<option value="TEL"<cfif IsDefined('paymentAuth') AND (paymentAuth) IS "TEL"> selected</cfif>>Over the phone</option>

			<option value="PPD"<cfif IsDefined('paymentAuth') AND (paymentAuth) IS "PPD"> selected</cfif>>In-person</option>

			<option value="WEB"<cfif IsDefined('paymentAuth') AND (paymentAuth) IS "WEB"> selected</cfif>>Through the Internet</option>

			<option value="CCD"<cfif IsDefined('paymentAuth') AND (paymentAuth) IS "CCD"> selected</cfif>>Directly from a company</option>

			<option value="PPD"<cfif IsDefined('paymentAuth') AND (paymentAuth) IS "PPD"> selected</cfif>>Other</option>

		</select></td>

				</tr>

				</table>

				</td>

			</tr>

			<tr>

				<td height="4"><img src="images/spacer.gif" width="5" height="4"></td>

			</tr>

			</table>

			</div>

			</td>

		</tr>

		<tr>

			<td colspan=3>

			<!--- make sure ach payments are allowed --->

			<cfif (acceptACH) IS 1>

				<div id="checkingDisplay" style="display:none">

					<table cellpadding=0 cellspacing=0 border=0 width=100%>

					<tr>

						<td colspan=3>

						<table cellpadding=0 cellspacing=0 border=0 width=100%>

						<tr>

							<td width=78% class="requiredFieldName">Name on Account<br><input type=text name="checkName" value="#checkName#" class="textFieldStretch"></td>

							<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

							<td width=18% class="fieldName">Check ##<br><input type=text name="checkNumber" value="#checkNumber#" class="textFieldStretch"></td>

						</tr>

						</table>

						</td>

					</tr>

					<tr>

						<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

					</tr>

					<tr>

						<td width=48%>

						<table cellpadding=0 cellspacing=0 border=0 width=100%>

						<tr>

							<td class="requiredFieldName" width="*">Routing Number<br><input type=text name="checkRouting" value="#checkRouting#" class="textFieldStretch" onChange="HideContent('showVerificationResults')"></td>

							<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

							<td width=30% class="requiredFieldName">&nbsp;<br><input type=button value="verify" class="buttonStretched" onClick="validateAccountNumber();"></td>

						</tr>

						</table>

						</td>

						<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

						<td width=48% class="requiredFieldName">Account Number<br><input type=text name="checkAccount" value="#checkAccount#" class="textFieldStretch" onChange="document.form.existingCheckAcct.value=0;"><cfif (existingCheckAcct) IS 1><input type="hidden" name="existingCheckAcct" value="1"></cfif></td>

					</tr>

					</table>

				</div>

				<div id="savingsDisplay" style="display:none">

					<table cellpadding=0 cellspacing=0 border=0 width=100%>

					<tr>

						<td colspan=3 class="requiredFieldName">Name on Account<br><input type=text name="savingsName" value="#savingsName#" class="textFieldStretch"></td>

					</tr>

					<tr>

						<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

					</tr>

					<tr>

						<td width=48%>

						<table cellpadding=0 cellspacing=0 border=0 width=100%>

						<tr>

							<td class="requiredFieldName" width="*">Routing Number<br><input type=text name="savingsRouting" value="#savingsRouting#" class="textFieldStretch" onChange="HideContent('showVerificationResults')"></td>

							<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

							<td width=30% class="requiredFieldName">&nbsp;<br><input type=button value="verify" class="buttonStretched" onClick="validateAccountNumber();"></td>

						</tr>

						</table>

						</td>

						<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

						<td width=48% class="requiredFieldName">Account Number<br><input type=text name="savingsAccount" value="#savingsAccount#" class="textFieldStretch" onChange="document.form.existingSaveAcct.value=0;"><cfif (existingSaveAcct) IS 1><input type="hidden" name="existingSaveAcct" value="1"></cfif></td>

					</tr>

					</table>

				</div>

			</cfif>

			<!--- make sure client accepts CCs --->

			<cfif (acceptCC) IS 1>

				<div id="creditCardDisplay" style="display:none">

					<table cellpadding=0 cellspacing=0 border=0 width=100%>

					<tr>

						<td colspan=3 class="requiredFieldName">Name on Card<br><input type=text name="cardName" value="#cardName#" class="textFieldStretch"></td>

					</tr>

					<tr>

						<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

					</tr>

					<tr>

						<td colspan=3>

						<table cellpadding=0 cellspacing=0 border=0 width=100%>

						<tr>

							<td width="*" class="requiredFieldName">Card Number<br><input type=text name="cardAccount" value="#cardAccount#" class="textFieldStretch" onChange="HideContent('showVerificationResults'); document.form.ccVerifyButton.disabled=false; document.form.existingCCNum.value=0"><cfif (existingCCNum) IS 1><input type="hidden" name="existingCCNum" value="1"></cfif></td>

							<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

							<td width=15% class="requiredFieldName">&nbsp;<br><input type=button id="ccVerifyButton" name="ccVerifyButton" value="verify" class="buttonStretched" onClick="validateAccountNumber();"<cfif IsDefined('cardAccount') AND (cardAccount) IS NOT ""> disabled</cfif>></td>

							<td width=4%><img src="images/spacer.gif" width="5" height="10"></td>

							<td width=30% class="requiredFieldName">Exp (mm/yyyy)<br><input type=text name="cardExp" value="#cardExp#" class="textFieldStretch"></td>

						</tr>

						</table>

						</td>

					</tr>

					</table>

				</div>

			</cfif>

			</td>

		</tr>

		<tr>

			<td colspan=3 height="1">

			<div id="showVerificationResults" style="display:none">

			<table cellpadding=0 cellspacing=0 border=0 width=100%>

			<tr>

				<td height="4"><img src="images/spacer.gif" width="5" height="4"></td>

			</tr>

			<tr>

				<td><input type="text" id="resultsField" name="resultsField" class="invisibleFieldOK" value="" tabIndex="-101" onFocus="this.blur();"></td>

			</tr>

			</table>

			</div>			

			</td>

		</tr>		

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		<tr>

			<td colspan=3 class="fieldName">Notes<br><textarea name="notes" rows="3" class="textFieldStretch"><cfif (notes) IS NOT "">#notes#</cfif></textarea></td>

		</tr>

		<tr>

			<td colspan=3 height="4"><img src="images/spacer.gif" width="5" height="4"></td>

		</tr>

		</table>

		

		</td>

		

		<!--- TABLE: right spacer --->

		<td width=10><img src="images/spacer.gif" width="10" height="1"></td>

	</tr>

	</table>

	

	</td>

</tr>
 

<!--- check for patient ID to pass along --->

<cfif IsDefined('patientID') AND (patientID) IS NOT "">

	<input type="hidden" name="patientID" value="#patientID#">

</cfif>

<input type="hidden" name="query_str"<cfif (query_str) IS NOT ""> value="#query_str#"<cfelse> value="#TRIM(CGI.QUERY_STRING)#"</cfif>>
 

</cfoutput>
 

<!--- include footer --->

<cfinclude template="footer.cfm">
 

<!--- include hidden iframe --->

<iframe id="queryframe" name="queryframe" style="width:0px; height:opx; border: 0px" src="images/spacer.gif"></iframe> 

Open in new window

0
 
LVL 4

Expert Comment

by:msfletch
ID: 21762021
This next page is the page that verifies the data and returns any errors to the previous page, which then displays the related fields.
<!--- 

DESCRIPTION: This page verifies the information sent from the payment form and either returns the user to the previous page with any notes, or forwards the information onto the processing page. In the future, this page will list the information and give the user a "chicken switch" allowing them to confirm the payment at that point

--->
 

<!--- #################### GET CLIENT INFO FOR LATER CHECKING #################### --->
 

<!--- check for existance of client code --->

<cfinclude template="inc_client_code_check.cfm">
 

<cfquery name="getClientSpecs" datasource="#whichDataSource#">

	SELECT c.*,

		c.businessName AS clientCompanyName,

		c.useCustomDropDown,

		c.customDropDownPrompt,

		c.useUniqueId,

		c.uniqueIdPrompt,

		c.acctPrompt,

		c.clientID,

		c.flags,

		i.acceptVisa,

		i.acceptMasterCard,

		i.acceptAmex,

		i.acceptDiscover,

		d.active AS liveAccount

	FROM clients c WITH (NOLOCK)

		INNER JOIN doctor d WITH (NOLOCK) ON d.doctorId = c.clientId

		INNER JOIN intellipay i WITH (NOLOCK) ON i.intellipayId = d.intellipayId

	WHERE c.clientCode=<cfqueryparam value="#clientCode#" CFSQLType="CF_SQL_VARCHAR" MaxLength="30">

</cfquery>
 

<!--- check if a customer ID was passed ... meaning that a look-up occured --->

<cfif IsDefined('patientID') AND (patientID) IS NOT "">

	<!--- gather customer information --->

	<cfquery name="getPatientInfo" datasource="#whichDataSource#">

		SELECT *

		FROM patient WITH (NOLOCK)

		WHERE patientID = #patientID#

	</cfquery>

</cfif>
 

<!--- translate query results into normal variables --->

<cfif (getClientSpecs.RecordCount) GT 0>
 

	<!--- function for encrypting credit cards --->

	<cffunction name="modEncrypt" access="remote" returnType="string">

		<cfargument name="source" type="String" required="Yes">

		<cfregistry action="GET" branch="HKEY_LOCAL_MACHINE\SOFTWARE\Modpay\Security" entry="3DES_Key" variable="Key">

		<cfset key = Trim(Key)>

		<cfset e = Encrypt(source, Key, "DESEDE")>

		<cfreturn e>

	</cffunction>

	

	<!--- function for decrypting credit card --->

	<cffunction name="modDecrypt" access="remote" returnType="string">

		<cfargument name="source" type="String" required="Yes">

		<cfregistry action="GET" branch="HKEY_LOCAL_MACHINE\SOFTWARE\Modpay\Security" entry="3DES_Key" variable="Key">

		<cfset key = Trim(Key)>

		<cfset d = Decrypt(source, Key, "DESEDE")>

		<cfreturn d>

	</cffunction>
 

	<cfset topImage = "#getClientSpecs.topImage#">

	<cfset clientCompanyName = "#getClientSpecs.clientCompanyName#">

	<cfset clientHomePage = "#getClientSpecs.clientHomePage#">

	<cfset titleBoxColor = "#getClientSpecs.titleBoxColor#">

	<cfset clientID = "#getClientSpecs.clientID#">

	<cfset acceptVisa = "#getClientSpecs.acceptVisa#">

	<cfset acceptMasterCard = "#getClientSpecs.acceptMasterCard#">

	<cfset acceptAmex = "#getClientSpecs.acceptAmex#">

	<cfset acceptDiscover = "#getClientSpecs.acceptDiscover#">

	<cfset liveAccount = "#getClientSpecs.liveAccount#">

	<cfset acctPrompt = "#getClientSpecs.acctPrompt#">

	<cfset flags = "#getClientSpecs.flags#">

	<!--- set whether client accepts ACH payments --->

	<cfif mid(getClientSpecs.flags, 2, 1) EQ "1">

		<cfset acceptACH = 1>

	<cfelse>

		<cfset acceptACH = 0>

	</cfif>

	<!--- set whether client accepts credit cards in general --->

	<cfif mid(flags, 3, 1) EQ "1">

		<cfset acceptCC = 1>

	<cfelse>

		<cfset acceptCC = 0>

	</cfif>

	<!--- set which payment method client wants as default --->

	<cfif mid(getClientSpecs.flags, 4, 1) EQ "1">

		<cfset defaultPaymentMethod = "1">

	<cfelseif mid(getClientSpecs.flags, 4, 1) EQ "2">

		<cfset defaultPaymentMethod = "3">

	<cfelseif mid(getClientSpecs.flags, 4, 1) EQ "3">

		<cfset defaultPaymentMethod = "2">

	</cfif>

	<!--- check if client allows customer lookup --->

	<cfif mid(getClientSpecs.flags, 5, 1) EQ "1">

		<cfset allowLookup = 0>

	<cfelse>

		<cfset allowLookup = 1>

	</cfif>

	<!--- check if customer wants the customer account required --->

	<cfif mid(getClientSpecs.flags, 8, 1) IS "1">

		<cfset requireCustomerAccount = 1>

	<cfelse>

		<cfset requireCustomerAccount = 0>

	</cfif>

	<cfset acctPrompt = "#getClientSpecs.acctPrompt#">

	<cfset uniqueIdPrompt = "#getClientSpecs.uniqueIdPrompt#">

	<cfset useUniqueId = "#getClientSpecs.useUniqueId#">

	<cfset useCustomDropDown = "#getClientSpecs.useCustomDropDown#">

	<cfset customDropDownPrompt = "#getClientSpecs.customDropDownPrompt#">

<cfelse>

	NO RESULTS FOUND!!

</cfif>
 

<!--- #################### SECURE SECTION #################### --->
 

<!--- set login requirement value from client flags --->

<cfset loginReq = #LEFT(getClientSpecs.flags, 1)#>

            

<!--- check login requirement value --->

<cfif IsDefined('loginReq') AND (loginReq) IS 1>

	<!--- include security code --->

	<!-- INCLUDED SECURITY FUNCTIONS --->

	<cfset noError = 1><!--- keeps secure page from saying session expired --->

	<cfinclude template="secure.cfm">

</cfif>
 

<!--- #################### SET DEFAULT VALUES #################### --->
 

<!--- set default values --->

<cfparam name="customerAccount" default="">

<cfparam name="customerAccountHidden" default="">

<cfparam name="uniqueID" default="">

<cfparam name="useCustomDropDown" default="0">

<cfparam name="customDropDownPrompt" default="">

<cfparam name="department" default="">

<cfparam name="customerType" default="1">

<cfparam name="businessName" default="">

<cfparam name="firstName" default="">

<cfparam name="lastName" default="">

<cfparam name="address" default="">

<cfparam name="city" default="">

<cfparam name="state" default="">

<cfparam name="noFeeState" default="">

<cfparam name="zipCode" default="">

<cfparam name="phone1" default="">

<cfparam name="phone2" default="">

<cfparam name="email" default="">

<cfparam name="amount" default="">

<cfparam name="transDate" default="">

<cfparam name="feeStructure" default="">

<cfparam name="feeTotal" default="">

<cfparam name="transFee" default="">

<cfparam name="percFee" default="">

<cfparam name="totalAmount" default="">

<cfparam name="paymentAuth" default="">

<cfparam name="paymentMethod" default="0">

<cfparam name="checkName" default="">

<cfparam name="checkNumber" default="">

<cfparam name="checkRouting" default="">

<cfparam name="checkAccount" default="">

<cfparam name="savingsName" default="">

<cfparam name="savingsRouting" default="">

<cfparam name="savingsAccount" default="">

<cfparam name="bankName" default="">

<cfparam name="cardName" default="">

<cfparam name="cardAccount" default="">

<cfparam name="cardExp" default="">

<cfparam name="notes" default="">

<cfparam name="existingCCNum" default="0">

<cfparam name="existingCheckAcct" default="0">

<cfparam name="existingSaveAcct" default="0">

<cfparam name="query_str" default="">
 

<!--- #################### CONFIRM REQUIRED FIELDS #################### --->
 

<!--- set default form status --->

<cfset formOK = 1>

<!--- set default missingErrorMessage --->

<cfset missingErrorMessage = "">

<!--- set default formatErrorMessage --->

<cfset formatErrorMessage = "">

<!--- set defasult general error message --->

<cfset errorMessage = "">
 

<!--- check if customerAccount is required --->

<cfif (requireCustomerAccount) IS 1>

	<!--- check for existence of value --->

	<cfif (FORM.customerAccountHidden) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>#acctPrompt# is required</li>">

	</cfif>

</cfif>
 

<!--- check if individual user's name is required --->

<cfif (FORM.customerType) IS 1>

	<!--- check for first name --->

	<cfif (FORM.firstName) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>First Name is required</li>">

	</cfif>

	<!--- check for last name --->

	<cfif (FORM.lastName) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Last Name is required</li>">

	</cfif>

<!--- if business name is required --->

<cfelse>

	<!--- check for businessName --->

	<cfif (FORM.businessName) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Business Name is required</li>">

	</cfif>

</cfif>
 

<!--- check for presence of a state --->

<cfif (FORM.state) IS "">

	<!--- set form error --->

	<cfset formOK = 0>

	<cfset missingErrorMessage = "#missingErrorMessage#<li>State is required</li>">

</cfif>
 

<!--- check for presence of a zip --->

<cfif (FORM.zipCode) IS "">

	<!--- set form error --->

	<cfset formOK = 0>

	<cfset missingErrorMessage = "#missingErrorMessage#<li>Zip Code is required</li>">

</cfif>
 

<!--- check for presence of an amount --->

<cfif (FORM.amount) IS "">

	<!--- set form error --->

	<cfset formOK = 0>

	<cfset missingErrorMessage = "#missingErrorMessage#<li>Amount is required</li>">

</cfif>
 

<!--- check for presence of a payment date --->

<cfif (FORM.transDate) IS "">

	<!--- set form error --->

	<cfset formOK = 0>

	<cfset missingErrorMessage = "#missingErrorMessage#<li>Payment Date is required</li>">

</cfif>
 

<!--- identify if a checking account is being used --->

<cfif (FORM.paymentMethod) IS 1>

	<!--- check for name on account --->

	<cfif (FORM.checkName) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Name on Account is required</li>">

	</cfif>

	<!--- check for routing number --->

	<cfif (FORM.checkRouting) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Routing Number is required</li>">

	</cfif>

	<!--- check for account number --->

	<cfif (FORM.checkAccount) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Account Number is required</li>">

	</cfif>

</cfif>
 

<!--- identify if a savings account is being used --->

<cfif (FORM.paymentMethod) IS 2>

	<!--- check for name on account --->

	<cfif (FORM.savingsName) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Name on Account is required</li>">

	</cfif>

	<!--- check for routing number --->

	<cfif (FORM.savingsRouting) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Routing Number is required</li>">

	</cfif>

	<!--- check for account number --->

	<cfif (FORM.savingsAccount) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Account Number is required</li>">

	</cfif>

</cfif>
 

<!--- identify if a credit card is being used --->

<cfif (FORM.paymentMethod) IS 3>

	<!--- check for name on card --->

	<cfif (FORM.cardName) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Name on Card is required</li>">

	</cfif>

	<!--- check for card number --->

	<cfif (FORM.cardAccount) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Card Number is required</li>">

	</cfif>

	<!--- check for exp date --->

	<cfif (FORM.cardExp) IS "">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset missingErrorMessage = "#missingErrorMessage#<li>Credit Card Expiration Date is required</li>">

	</cfif>

</cfif>
 

<!--- #################### CONFIRM PROPERLY FORMATTED VALUES #################### --->
 

<!--- make sure account number not too big --->

<cfif LEN(customerAccountHidden) GT 50>

	<!--- set form error --->

	<cfset formOK = 0>

	<cfset formatErrorMessage = "#formatErrorMessage#<li>#getClientSpecs.acctPrompt# too long (50 char max)</li>">

</cfif>
 

<!--- if using unique ID --->

<cfif (useUniqueId) IS 1>

	<!--- make sure unique ID not too big --->

	<cfif LEN(uniqueID) GT 50>

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>#uniqueIdPrompt# too long (50 char max)</li>">

	</cfif>

</cfif>
 

<!--- check for presence of email to see if it requires validation --->

<cfif (FORM.email) IS NOT "">

	<!--- check for valid email --->

	<cfif isValid("email", FORM.email) IS "No">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>Email address is not valid</li>">

	<!--- email address is valid --->

	<cfelse>

		<!--- check that email is not too long --->

		<cfif LEN(FORM.email) GT 255>

			<!--- set form error --->

			<cfset formOK = 0>

			<cfset formatErrorMessage = "#formatErrorMessage#<li>Email address is too long (255 char max)</li>">

		</cfif>

	</cfif>

</cfif>
 

<!--- verify amount --->

<cfif (FORM.amount) IS NOT "">

	<!--- clear all but numbers and decimal point from amount amount --->

	<cfset amountVerify = #LTRIM(RTRIM(REReplaceNoCase(FORM.amount, "[^0-9|\.]", "", "ALL")))#>

	<!--- make sure amount is actually a number by verifying anything left after conversion above --->

	<cfif LEN(amountVerify) LT 1>

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>Amount is not a number</li>">

	</cfif>

	<!--- make sure amount is greater than zero --->

	<cfif (amountVerify) LTE 0>

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>Amount must be a positive number</li>">

	</cfif>

</cfif>
 

<!--- verify transaction date --->

<cfif (FORM.transDate) IS NOT "">

	<!--- make sure it is actually a date --->

	<cfif isValid("date", FORM.transDate) IS "No">

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>Payment Date is invalid</li>">

	</cfif> 

	<!--- make sure date is not in the past --->

	<cfif (FORM.transDate) LT #DateFormat(now(), "mm/dd/yyyy")#>

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>Payment Date cannot be in the past</li>">

	</cfif>

</cfif>
 

<!--- check for existence of fee amount --->

<cfif (FORM.feeTotal) IS NOT "">

	<!--- clear all non-numeric characters except for a decimal place --->

	<cfset feeAmountVerify = #LTRIM(RTRIM(REReplaceNoCase(FORM.feeTotal, "[^0-9|\.]", "", "ALL")))#>

	<!--- verify that fee amount is not negative --->

	<cfif LEN(feeAmountVerify) LT 0>

		<!--- set form error --->

		<cfset formOK = 0>

		<cfset formatErrorMessage = "#formatErrorMessage#<li>Fees cannot be negative</li>">

	</cfif>

</cfif>
 

<!--- check if payment type is check --->

<cfif (FORM.paymentMethod) IS 1>

	<!--- verify that routing number is present --->

	<cfif (FORM.checkRouting) IS NOT "">

		<!--- remove all non-numeric values from routing number --->

		<cfset checkRoutingCheck = #LTRIM(RTRIM(REReplaceNoCase(FORM.checkRouting, "[^0-9]", "", "ALL")))#>

		<!--- verify routing number is proper length --->

		<cfif LEN(checkRoutingCheck) IS NOT 9>

			<!--- set form error --->

			<cfset formOK = 0>

			<cfset formatErrorMessage = "#formatErrorMessage#<li>Routing Number is invalid (must be nine digits)</li>">

		<cfelse>

			<!--- verify routing number is valid --->

			<cfquery datasource="#whichDataSource#" name="checkRoutingNum">

				SELECT customerName

				FROM fedAchDir WITH (NOLOCK)

				WHERE routingABA = #TRIM(checkRoutingCheck)#

			</cfquery>

			<!--- see if results returned --->

			<cfif IsDefined('checkRoutingNum.RecordCount') IS "No" OR (checkRoutingNum.RecordCount) LTE 0>

				<!--- set form error --->

				<cfset formOK = 0>

				<cfset formatErrorMessage = "#formatErrorMessage#<li>Routing Number is invalid</li>">

			<cfelse>

				<!--- set bank name --->

				<cfset bankName = "#checkRoutingNum.customerName#">

			</cfif>

		</cfif>

	</cfif>

</cfif>
 

<!--- check if payment type is savings --->

<cfif (FORM.paymentMethod) IS 2>

	<!--- verify that routing number is present --->

	<cfif (FORM.savingsRouting) IS NOT "">

		<!--- remove all non-numeric values from routing number --->

		<cfset savingsRoutingCheck = #LTRIM(RTRIM(REReplaceNoCase(FORM.savingsRouting, "[^0-9]", "", "ALL")))#>

		<!--- verify routing number is proper length --->

		<cfif LEN(savingsRoutingCheck) IS NOT 9>

			<!--- set form error --->

			<cfset formOK = 0>

			<cfset formatErrorMessage = "#formatErrorMessage#<li>Routing Number is invalid (must be nine digits)</li>">

		<cfelse>

			<!--- verify routing number is valid --->

			<cfquery datasource="#whichDataSource#" name="checkRoutingNumSav">

				SELECT customerName

				FROM fedAchDir WITH (NOLOCK)

				WHERE routingABA = #TRIM(savingsRoutingCheck)#

			</cfquery>

			<!--- see if results returned --->

			<cfif IsDefined('checkRoutingNumSav.RecordCount') IS "No" OR (checkRoutingNumSav.RecordCount) LTE 0>

				<!--- set form error --->

				<cfset formOK = 0>

				<cfset formatErrorMessage = "#formatErrorMessage#<li>Routing Number is invalid</li>">

			<cfelse>

				<!--- set bank name --->

				<cfset bankName = "#checkRoutingNumSav.customerName#">

			</cfif>

		</cfif>

	</cfif>

</cfif>
 

<!--- check if payment type is credit card --->

<cfif (FORM.paymentMethod) IS 3>

	<!--- check for new credit card number value --->

	<cfif (FORM.cardAccount) IS NOT "" AND (existingCCNum) IS 0>

		<!--- clear all but credit card numbers --->

		<cfset verifyCCNum = #LTRIM(RTRIM(REReplaceNoCase(FORM.cardAccount, "[^0-9]", "", "ALL")))#>

		<!--- check that credit card number is valid --->

		<cfif isValid("creditcard", FORM.cardAccount) IS "No">

			<!--- set form error --->

			<cfset formOK = 0>

			<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Number is invalid</li>">

		</cfif>

	<!--- check for existing credit card value --->

	<cfelseif (FORM.cardAccount) IS NOT "" AND (existingCCNum) IS 1>

		<!--- get credit card from query above --->

		<cfset verifyCCNum = #getPatientInfo.ccNum#>

		<!--- decrypt existing cc --->

		<cfset verifyCCNum = #modDecrypt(verifyCCNum)#>

		<!--- remove all but numbers --->

		<cfset verifyCCNum = #LTRIM(RTRIM(REReplaceNoCase(verifyCCNum, "[^0-9]", "", "ALL")))#>

		<!--- check that credit card number is valid --->

		<cfif isValid("creditcard", verifyCCNum) IS "No">

			<!--- set form error --->

			<cfset formOK = 0>

			<cfset formatErrorMessage = "#formatErrorMessage#<li>Existing Credit Card Number is invalid</li>">

		</cfif>

	</cfif>

	<!--- check for expiration date value --->

	<cfif (FORM.cardExp) IS NOT "">

		<!--- set new trimmed expDate --->

		<cfset ccExpDateTrimmed = #TRIM(FORM.cardExp)#>

		<!--- verify that a slash is present --->

		<cfset slashPosition = #REFind("\/", ccExpDateTrimmed)#>

		<cfif (slashPosition) IS 0 OR (slashPosition) IS "">

			<!--- set form error --->

			<cfset formOK = 0>

			<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted (requires slash)</li>">

		<cfelse>

			<!--- ##### verify credit card exp date only contains numbers or a single slash ##### --->

			<!--- set original length --->

			<cfset testNumExpDateOrigLen = #LEN(ccExpDateTrimmed)#>

			<!--- remove slash --->

			<cfset testNumExpDate = #TRIM(REReplaceNoCase(ccExpDateTrimmed, "\/", "", "ALL"))#>

			<!--- subtract current length from original length --->

			<cfset lenCheck = #VAL(testNumExpDateOrigLen)# - #VAL(LEN(testNumExpDate))#>

			<!--- verify previous value is 1 indicating correct number of slashes --->

			<cfif (lenCheck) IS NOT 1>

				<!--- set form error --->

				<cfset formOK = 0>

				<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted</li>">

			<!--- correct number of slashes --->

			<cfelse>

				<!--- ##### verify cc exp date contains no letters ##### --->

				<!--- get current length without the slash --->

				<cfset testNumExpDateLen = #LEN(TRIM(testNumExpDate))#>

				<!--- remove all but numbers from expiration date --->

				<cfset testNumExpDate = #LTRIM(RTRIM(REReplaceNoCase(testNumExpDate, "[^0-9]", "", "ALL")))#>

				<!--- check current length against previous length without the slash --->

				<cfif LEN(testNumExpDate) NEQ testNumExpDateLen>

					<!--- set form error --->

					<cfset formOK = 0>

					<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted (contains letters)</li>">

				<cfelse>

					<!--- ##### separate month and year and verify not expired ##### --->

					<!--- verify that slash is not the first item --->

					<cfif (slashPosition) IS 1>

						<!--- set form error --->

						<cfset formOK = 0>

						<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted</li>">

					<cfelse>

						<!--- separate month and year from exp date --->

						<cfset verifyExpMonth = #LEFT(ccExpDateTrimmed,  (VAL(slashPosition)-1))#>

						<!--- make sure month is not greater than 12 --->

						<cfif (verifyExpMonth) GT 12>

							<!--- set form error --->

							<cfset formOK = 0>

							<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted (bad month)</li>">

						<cfelse>

							<!--- figure out how may spaces remain after removing the month and the slash --->

							<cfset yearSpaces = #LEN(ccExpDateTrimmed)# - #VAL(slashPosition)#>

							<!--- verify there is still something for the year --->

							<cfif (yearSpaces) LTE 0>

								<!--- set form error --->

								<cfset formOK = 0>

								<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted (no year)</li>">

							<cfelse>

								<cfset verifyExpYear = #RIGHT(ccExpDateTrimmed, VAL(yearSpaces))#>

								<!--- verify that month and year are not too long --->

								<cfif LEN(verifyExpMonth) GT 2 OR LEN(verifyExpYear) GT 4>

									<!--- set form error --->

									<cfset formOK = 0>

									<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card Expiration Date is incorrectly formatted (too long)</li>">

								<cfelse>

									<!--- combine month and year into a date for comparison --->

									<cfset compareExpDate = #CreateDate(VAL(verifyExpYear), VAL(verifyExpMonth), 1)#>

									<!--- add one to the date month so that we can check to the end of the expiration month --->

									<cfset compareExpDate = #DateAdd("m", 1, compareExpDate)#>

									<!--- check if expiration date is last month or before --->

									<cfif (compareExpDate) LTE #now()#>

										<!--- set form error --->

										<cfset formOK = 0>

										<cfset formatErrorMessage = "#formatErrorMessage#<li>Credit Card is expired</li>">

									</cfif>	

								</cfif>

							</cfif>

						</cfif>

					</cfif>

				</cfif>

			</cfif>

		</cfif>

	</cfif>

</cfif>
 

<!--- #################### FORMAT ERRORS AND RETURN FORM #################### --->
 

<!--- check if form had problems --->

<cfif (formOK) IS 0>
 

	<!--- check if form was missing some data --->

	<cfif (missingErrorMessage) IS NOT "">

		<!--- add precursor message for missing form data --->

		<cfset missingErrorMessage = "Missing required information:<ul>#missingErrorMessage#</ul>">	

	</cfif>

	<!--- check if form contained erroneous data --->

	<cfif (formatErrorMessage) IS NOT "">

		<!--- add precursor message for missing form data --->

		<cfset formatErrorMessage = "Invalid information submitted:<ul>#formatErrorMessage#</ul>">	

	</cfif>

	<!--- format entire error --->

	<cfif (missingErrorMessage) IS NOT "" AND (formatErrorMessage) IS NOT "">

		<cfset errorMessage = "#missingErrorMessage#<br>#formatErrorMessage#">

	<cfelse>

		<cfset errorMessage = "#missingErrorMessage##formatErrorMessage#">

	</cfif>
 

	<cfoutput>

	

	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

	

	<html>

	<head>

		<title>VTFusion - Verify Form Data</title>

	</head>

	

	<body onLoad="document.badForm.submit();">

	

	<form name="badForm" method="post" action="payment.cfm">

	

	<input type="hidden" name="clientCode" value="#FORM.clientCode#">

	<input type="hidden" name="customerAccount" value="#customerAccountHidden#">

	<input type="hidden" name="uniqueID" value="#uniqueID#">

	<input type="hidden" name="department" value="#department#">

	<input type="hidden" name="customerType" value="#customerType#">

	<input type="hidden" name="firstName" value="#firstName#">

	<input type="hidden" name="lastName" value="#lastName#">

	<input type="hidden" name="businessName" value="#businessName#">

	<input type="hidden" name="address" value="#address#">

	<input type="hidden" name="city" value="#city#">

	<input type="hidden" name="state" value="#state#">

	<input type="hidden" name="noFeeState" value="#noFeeState#">

	<input type="hidden" name="zipCode" value="#zipCode#">

	<input type="hidden" name="phone1" value="#phone1#">

	<input type="hidden" name="phone2" value="#phone2#">

	<input type="hidden" name="email" value="#email#">

	<input type="hidden" name="amount" value="#amount#">

	<input type="hidden" name="transDate" value="#transDate#">

	<input type="hidden" name="feeStructure" value="#feeStructure#">

	<input type="hidden" name="feeTotal" value="#feeTotal#">

	<input type="hidden" name="transFee" value="#transFee#">

	<input type="hidden" name="percFee" value="#percFee#">

	<input type="hidden" name="totalAmount" value="#totalAmount#">

	<input type="hidden" name="paymentAuth" value="#paymentAuth#">

	<input type="hidden" name="paymentMethod" value="#paymentMethod#">

	<input type="hidden" name="checkName" value="#checkName#">

	<input type="hidden" name="checkNumber" value="#checkNumber#">

	<input type="hidden" name="checkRouting" value="#checkRouting#">

	<input type="hidden" name="checkAccount" value="#checkAccount#">

	<input type="hidden" name="savingsName" value="#savingsName#">

	<input type="hidden" name="savingsRouting" value="#savingsRouting#">

	<input type="hidden" name="savingsAccount" value="#savingsAccount#">

	<input type="hidden" name="cardName" value="#cardName#">

	<input type="hidden" name="cardAccount" value="#cardAccount#">

	<input type="hidden" name="cardExp" value="#TRIM(cardExp)#">

	<input type="hidden" name="notes" value="#notes#">

	<input type="hidden" name="errorMessage" value="#errorMessage#">

	<input type="hidden" name="existingCCNum" value="#existingCCNum#">

	<input type="hidden" name="existingCheckAcct" value="#existingCheckAcct#">

	<input type="hidden" name="existingSaveAcct" value="#existingSaveAcct#">

	<!--- check for patient ID to pass along --->

	<cfif IsDefined('patientID') AND (patientID) IS NOT "">

		<input type="hidden" name="patientID" value="#patientID#">

	</cfif>

	<input type="hidden" name="query_str" value="#query_str#">

	

	</form>

	

	</body>

	</html>

	

	</cfoutput>

	

	<!--- stop running coldfusion --->

	<cfabort>

	

</cfif>
 

<!--- ####################FORMAT SUBMISSION FORM #################### --->
 

<!--- check if form was OK --->

<cfif (formOK) IS 1>
 

	<cfoutput>
 

	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

	

	<html>

	<head>

		<title>VTFusion - Verify Form Data</title>

		

	<SCRIPT language="JavaScript">

	<!--

	if (document.images)

	{

	  pic1= new Image(16,16); 

	  pic1.src="images/indicator.gif"; 

	}

	//-->

	</SCRIPT>

	

	<style type="text/css">

		.boldText {font-family: verdana, arial, helvetica; font-weight: bold; font-size: 12px; color: 000088;}

	</style>

	

	</head>

	

	<body onLoad="document.goodForm.submit();">
 

	<!--- show working indicator and message --->

	<table  ellpadding=0 cellspacing=0 border=0 width=100% height=100%>

	<tr valign=middle>

		<td align=center class="boldText">Processing<p><img src="images/indicator.gif" width="16" height="16" alt="" border="0"></td>

	</tr>

	</table>
 
 

	<form name="goodForm" method="post" action="process.cfm">
 

	<input type="hidden" name="paymentDate" value="#TRIM(transDate)#">

	<input type="hidden" name="useUniqueId" value="#TRIM(useUniqueId)#">

	<input type="hidden" name="acctNum" value="#TRIM(customerAccountHidden)#">

	<input type="hidden" name="uniqueId" value="#TRIM(uniqueID)#">

	<input type="hidden" name="department" value="#TRIM(department)#">

	<input type="hidden" name="notes" value="#TRIM(notes)#">

	<input type="hidden" name="clientId" value="#TRIM(clientID)#">

	<input type="hidden" name="clientCode" value="#TRIM(clientCode)#">

	<input type="hidden" name="customerType" value="#TRIM(customerType)#">

	<input type="hidden" name="lastName" value="#TRIM(lastName)#">

	<input type="hidden" name="firstName" value="#TRIM(firstName)#">

	<input type="hidden" name="middleInitial" value=""><!--- no equivelent in VTFusion --->

	<input type="hidden" name="companyName" value="#Trim(businessName)#">

	<input type="hidden" name="address" value="#TRIM(address)#">

	<input type="hidden" name="city" value="#TRIM(city)#">

	<input type="hidden" name="state" value="#TRIM(state)#">

	<input type="hidden" name="zipCode" value="#TRIM(zipCode)#">

	<input type="hidden" name="phone" value="#TRIM(phone1)#">

	<input type="hidden" name="workPhone" value="#TRIM(phone2)#">

	<input type="hidden" name="custEmail" value="#TRIM(email)#">

	<input type="hidden" name="paymentAmount" value="#TRIM(amountVerify)#"><!--- stripped to numeric and decimal in verification above --->

	<input type="hidden" name="fee" value="#TRIM(feeAmountVerify)#"><!--- stripped to numeric and decimal in verification above --->

	<input type="hidden" name="totalPayment" value="#LTRIM(RTRIM(REReplaceNoCase(totalAmount, "[^0-9|\.]", "", "ALL")))#">

	<input type="hidden" name="transFee" value="#LTRIM(RTRIM(REReplaceNoCase(transFee, "[^0-9|\.]", "", "ALL")))#">

	<input type="hidden" name="percFee" value="#LTRIM(RTRIM(REReplaceNoCase(percFee, "[^0-9|\.]", "", "ALL")))#">

	<input type="hidden" name="pmtMethod" value="#paymentMethod#">

	<!--- if a check payment --->

	<cfif (FORM.paymentMethod) IS 1>

		<input type="hidden" name="paymentAuth" value="#paymentAuth#">

		<input type="hidden" name="accountName" value="#TRIM(checkName)#">

		<input type="hidden" name="routingABA" value="#TRIM(checkRoutingCheck)#">

		<!--- check for existing checking account --->

		<cfif (existingCheckAcct) IS 1>

			<input type="hidden" name="accountNumber" value="#TRIM(getPatientInfo.bankAccountNum)#">

		<cfelse>

			<input type="hidden" name="accountNumber" value="#TRIM(checkAccount)#">

		</cfif>

		<input type="hidden" name="checkNumber" value="#TRIM(checkNumber)#">

		<input type="hidden" name="bankName" value="#TRIM(bankName)#">

		<input type="hidden" name="isSavingsAcct" value="0">

	</cfif>

	<!--- if a savings account payment --->

	<cfif (FORM.paymentMethod) IS 2>

		<input type="hidden" name="paymentAuth" value="#paymentAuth#">

		<input type="hidden" name="accountName" value="#TRIM(savingsName)#">

		<input type="hidden" name="routingABA" value="#TRIM(savingsRoutingCheck)#">

		<!--- check for existing savings account --->

		<cfif (existingSaveAcct) IS 1>

			<input type="hidden" name="accountNumber" value="#TRIM(getPatientInfo.bankAccountNum)#">	

		<cfelse>

			<input type="hidden" name="accountNumber" value="#TRIM(savingsAccount)#">		

		</cfif>

		<input type="hidden" name="bankName" value="#TRIM(bankName)#">

		<input type="hidden" name="isSavingsAcct" value="1">

	</cfif>

	<!--- if a credit card payment --->

	<cfif (FORM.paymentMethod) IS 3>

		<input type="hidden" name="creditCardNumber" value="#TRIM(verifyCCNum)#">

		<input type="hidden" name="cardHolder" value="#TRIM(cardName)#">

		<!--- make sure month has two digits --->

		<cfif LEN(verifyExpMonth) LT 2>

			<cfset expMonth = "0#verifyExpMonth#">

		<cfelse>

			<cfset expMonth = "#verifyExpMonth#">

		</cfif>

		<input type="hidden" name="expMonth" value="#VAL(expMonth)#"><!--- 2 digits --->

		<!--- verify expiration year is four digits --->

		<cfif LEN(verifyExpYear) LT 4>

			<cfif LEN(verifyExpYear) IS 2>

				<cfset expYear = "20#verifyExpYear#">

			<cfelseif LEN(verifyExpYear) EQ 1>

				<cfset expYear = "200#verifyExpYear#">

			</cfif>

		<cfelse>

			<cfset expYear = "#verifyExpYear#">

		</cfif>

		<input type="hidden" name="expYear" value="#VAL(expYear)#"><!--- 4 digits --->

		<input type="hidden" name="stateFeeLimit" value="0">

	</cfif>

	<input type="hidden" name="creditCardFee" value="0.00">

	<input type="hidden" name="confirmationId" value="#Left(CreateUUID(), 8)#">

	<cfif (noFeeState) IS 1>

		<input type="hidden" name="isRestrictedState" value="yes">

	<cfelse>

		<input type="hidden" name="isRestrictedState" value="no">

	</cfif>

	<input type="hidden" name="query_str" value="#TRIM(query_str)#">	

	<input type="hidden" name="postTo" value=""><!--- for forwarding the results to another app --->

	<!--- check for patient ID to pass along --->

	<cfif IsDefined('patientID') AND (patientID) IS NOT "">

		<input type="hidden" name="patientID" value="#patientID#">

	</cfif>

	

	<!--- not passing the following ... will retrieve them from the DB when reach receipt page --->

	<!---

	<input type="hidden" name="topImage" value="#Trim(topImage)#">

	<input type="hidden" name="Logo" value="#Logo#">

	<input type="hidden" name="bgColor" value="#Trim(getClientInfo.bgcolorLeft)#">

	<input type="hidden" name="returnPage" value="#Trim(getClientInfo.clientHomePage)#">

	<input type="hidden" name="businessName" value="#Trim(businessName)#"> <!--- clients business name --->

	<input type="hidden" name="ne" value="1"><!--- replacing this with new notificcation settings --->

	--->	

	

	<!--- #?#?#?#?#?#?#?#?#?#?#?# DATA NOT INCLUDED ABOVE #?#?#?#?#?#?#?#?#?#?#?# --->

	<!--- no custom drop-down value --->

	<!--- feeCategory ???? is contained on form but does not seem to be forwarded to the final page, just the result of it. --->

	<!--- how the payment was authorized --->

	<!--- business or individual --->
 

	<!--- EDIT BELOW --->

	

	</form>

	

	</body>

	</html>

	

	</cfoutput>

	

	<!--- stop running coldfusion --->

	<cfabort>
 

</cfif>

Open in new window

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:tam423
ID: 21766467
msfletch,

Thank you so much for providing me with your code. I haven't had a chance to delve into this thoroughly yet and test things out, but I have looked over what you provided and I do see very similar elements to what I am trying to do, and wanted to just let you know that I will definitely try working with this and see if I can come up with something that will work. I'm working on stripping it down to just the essential elements that I need (as I don't have the datasource, etc.), in order to see it in action, and will let you know how things go. Thank you again, and I will be in touch.
0
 

Author Comment

by:tam423
ID: 21777307
msfletch,

Well, I have been working on this for way too long, and no matter what I try, I cannot get my javascript-driven hide/show form fields to work at all with the form validation script that came with the shopping cart system. I've decided that it will be best to work with the existing validation script and only modify the payment choices on the showcart.cfm page to reflect the addition of a Purchase Order Number field. It is displayed regularly, without the javascript to hide/show it. It is simply put in as:

      <td align="right">  <cfif IsDefined ('request.FieldErrorPON')><span class="errorMessage">P.O. Number</span>  <cfelse> P.O. Number</cfif> </td>
      <td> <input name="cstPONumber" size="34" type="text" value="<cfoutput>#FORM.cstPONumber#</cfoutput>"> * </td>

So, now all I want to do is validate this additional field in the validation script, using the existing cfscript elements and making the necessary modifications. For some reason, though, I cannot get the validation to respond in the correct manner. With the addiiton of the Purchase Order field, a customer must either enter a PO number, OR enter the credit card info (not both). So,

1. I am trying to check first that both the PO number field AND credit card fields aren't blank, and if they are, come back with alert (that seems to be okay), but
2. If the PO number field is filled in and credit card number field is not, submit the order (because all is okay), OR
3. If the PO number field is blank and the credit card number field is filled in, check that the rest of the credit card info is filled in. If so, submit the order.

What happens in scenario 2 is that the form still gets returned stating that the credit card field must be filled in. What happens in scenario 3 is that it will verify all of the other credit card info fields correctly, but it still comes back as needing the credit card number filled in again. This doesn't seem like it should be that difficult to make work, but it is causing me much grief. I must not be getting the IF statements correct, or something, but for the life of me, I don't know what is wrong. At this point, if I could just get a solution to this part, I will be good to go, and can award the points and close this question. If you wouldn't mind looking at what I have and lettiing me know what I have wrong, I would so appreciate it. Attached is the code that I have for the cfscript validation part.
		<cfscript>

		// Check that Purchase Order Number and Credit Card Number are not both blank

		if ((FORM.cstPONumber eq "") && (FORM.cstCCNumber eq ""))
 

			{ request.FieldErrorPON = "<br />Purchase Order cannot be blank.";

			 request.FieldInvalid = "YES";

		}

			{ request.FieldErrorCN = "<br />Credit Card number cannot be blank.";

			 request.FieldInvalid = "YES";

		}

		// Check that rest of credit card info is filled in if credit card number entered

		if ((FORM.cstPONumber eq "") && (FORM.cstCCNumber neq "")) {
 

		// Check Card holder name

		if (FORM.cstCCardHolderName eq "")

			{ request.FieldErrorCHN = "<br />Card Holder Name cannot be blank.";

			 request.FieldInvalid = "YES";

		}

		

		// Check C Card Type

		if (FORM.cstCCardType eq "forgot")

			{ request.FieldErrorCT = "<br />Please choose your credit card type.";

			 request.FieldInvalid = "YES";

		}
 

		// Check C Card Number

		thisCCNum = FORM.cstCCNumber;

		ccLength = 16;

		altccLength = 16;

		ccvLength = 3;

		if(FORM.cstCCardType EQ "amex"){

			ccLength = 15;

			altccLength = 15;

			ccvLength = 4;

		}

		

		if(Form.cstCCardType EQ "visa"){      

			altccLength = 13; // visa now accepts 13 and 16 character numbers, so allow both    

		}

		

		if (IsNumeric(thisCCNum) IS "FALSE" OR (Len(thisCCNum) NEQ ccLength And Len(thisCCNum) NEQ altccLength)){ 

			request.FieldErrorCN = "<br />You did not enter a valid credit card number.";

			request.FieldInvalid = "YES";

		}

		

		if (IsNumeric(FORM.cstCCV) IS "FALSE" OR Len(FORM.cstCCV) LT ccvLength)

			{ request.FieldErrorCCV = "<br />You did not enter a CCV code.";

			 request.FieldInvalid = "YES";

		}

		

		// Check C Card Expr Month

		if (FORM.cstExprMonth eq "forgot"){ 

			request.FieldErrorCM ="<br />Please choose the month your card expires.";

			request.FieldInvalid = "YES";

		}

		

		// Check C Card Expr Year

		if (FORM.cstExprYr eq "forgot"){ 

			request.FieldErrorCY = "<br />Please choose the year your card expires.";

			request.FieldInvalid = "YES";

		}

	      }

		</cfscript>

Open in new window

0
 
LVL 4

Accepted Solution

by:
msfletch earned 500 total points
ID: 21787475
OK tam423,

See attached code. I don't really have a good way to test it, but I don't think I have any spelling errors =). My monitor at home is pretty blurry so sometimes "n" and "m" look a lot alike.

Anyway, a brief explanation:

There seemed to be an error in your first IF statement. You had a single IF followed by two sets of open and close "{}". These are used to define all actions from a single IF, ELSE, or ELSE IF, so having two sets is a good candidate for breaking something. I corrected that by combining the two sets of actions.

I also added a check for PO number at the top. Since this is the easiest to check and the quickest to verify, I made all other checks dependant on that one. So if there is a PO Number, no need to check the rest.

I then removed the condition for the PO number from the CC Number check (as it wouldn't get there unless the PO number was already missing), and made all of the other checks dependant on that IF by combining the check for a CC Number value with the check for a missing CC Value.

Hopefully I am not just making things more confusing. Anyway ... check out the code and let me know how it goes.

Good luck!
<cfscript>
 

// Check if PO number entered

if ((FORM.cstPONumber NEQ "") {

	request.FieldInvalid = "NO";

	

} else { // No PO number
 

	// Check that Credit Card Number not blank

	if (FORM.cstCCNumber eq "") { 

		request.FieldErrorPON = "<br />Purchase Order cannot be blank.";

		request.FieldErrorCN = "<br />Credit Card number cannot be blank.";

		request.FieldInvalid = "YES";
 

	} else { // CC number not blank

	

		// Check that rest of credit card info is filled in if credit card number entered

		if (FORM.cstCCNumber neq "") {

		

			// Check Card holder name

			if (FORM.cstCCardHolderName eq "") {

				request.FieldErrorCHN = "<br />Card Holder Name cannot be blank.";

				request.FieldInvalid = "YES";

			}

		

			// Check C Card Type

			if (FORM.cstCCardType eq "forgot") {

				request.FieldErrorCT = "<br />Please choose your credit card type.";

				request.FieldInvalid = "YES";

			}

		

			// Check C Card Number

			thisCCNum = FORM.cstCCNumber;

			ccLength = 16;

			altccLength = 16;

			ccvLength = 3;

		

			if (FORM.cstCCardType EQ "amex") {

				ccLength = 15;

				altccLength = 15;

				ccvLength = 4;

			}

		

			if (Form.cstCCardType EQ "visa") {      

				altccLength = 13; // visa now accepts 13 and 16 character numbers, so allow both    

			}

		

			if (IsNumeric(thisCCNum) IS "FALSE" OR (Len(thisCCNum) NEQ ccLength And Len(thisCCNum) NEQ altccLength)) { 

				request.FieldErrorCN = "<br />You did not enter a valid credit card number.";

				request.FieldInvalid = "YES";

			}

		

			if (IsNumeric(FORM.cstCCV) IS "FALSE" OR Len(FORM.cstCCV) LT ccvLength) {

				request.FieldErrorCCV = "<br />You did not enter a CCV code.";

				 request.FieldInvalid = "YES";

			}

		

			// Check C Card Expr Month

			if (FORM.cstExprMonth eq "forgot") { 

				request.FieldErrorCM ="<br />Please choose the month your card expires.";

				request.FieldInvalid = "YES";

			}

		

			// Check C Card Expr Year

			if (FORM.cstExprYr eq "forgot") { 

				request.FieldErrorCY = "<br />Please choose the year your card expires.";

				request.FieldInvalid = "YES";

			}

		

		} // End IF for CC info check		

		

	} // End IF for CC number check

	

} // End IF for PO number check
 

</cfscript>

Open in new window

0
 

Author Comment

by:tam423
ID: 21791235
msfletch,

Thank you, thank you, thank you! This worked perfectly and is just what I needed, to finally be able to move forward with this project. Again, many thanks for all the time you have spent helping me with this -- it is so appreciated.

Tam
0
 
LVL 4

Expert Comment

by:msfletch
ID: 21796382
Glad I could help Tam. By the way, just for the sake of efficient coding, I have included below another version of the same code that removes another IF statement.  The code that checks for a value in the credit card field is technically not necessary after the IF above that checked for the blank credit card value.

Happy coding!
<cfscript>

 

// Check if PO number entered

if ((FORM.cstPONumber NEQ "") {

	request.FieldInvalid = "NO";

	

} else { // No PO number

 

	// Check that Credit Card Number not blank

	if (FORM.cstCCNumber eq "") { 

		request.FieldErrorPON = "<br />Purchase Order cannot be blank.";

		request.FieldErrorCN = "<br />Credit Card number cannot be blank.";

		request.FieldInvalid = "YES";

 

	} else { // CC number not blank

	

		// Check Card holder name

		if (FORM.cstCCardHolderName eq "") {

			request.FieldErrorCHN = "<br />Card Holder Name cannot be blank.";

			request.FieldInvalid = "YES";

		}

	

		// Check C Card Type

		if (FORM.cstCCardType eq "forgot") {

			request.FieldErrorCT = "<br />Please choose your credit card type.";

			request.FieldInvalid = "YES";

		}

	

		// Check C Card Number

		thisCCNum = FORM.cstCCNumber;

		ccLength = 16;

		altccLength = 16;

		ccvLength = 3;

	

		if (FORM.cstCCardType EQ "amex") {

			ccLength = 15;

			altccLength = 15;

			ccvLength = 4;

		}

	

		if (Form.cstCCardType EQ "visa") {      

			altccLength = 13; // visa now accepts 13 and 16 character numbers, so allow both    

		}

	

		if (IsNumeric(thisCCNum) IS "FALSE" OR (Len(thisCCNum) NEQ ccLength And Len(thisCCNum) NEQ altccLength)) { 

			request.FieldErrorCN = "<br />You did not enter a valid credit card number.";

			request.FieldInvalid = "YES";

		}

	

		if (IsNumeric(FORM.cstCCV) IS "FALSE" OR Len(FORM.cstCCV) LT ccvLength) {

			request.FieldErrorCCV = "<br />You did not enter a CCV code.";

			 request.FieldInvalid = "YES";

		}

	

		// Check C Card Expr Month

		if (FORM.cstExprMonth eq "forgot") { 

			request.FieldErrorCM ="<br />Please choose the month your card expires.";

			request.FieldInvalid = "YES";

		}

	

		// Check C Card Expr Year

		if (FORM.cstExprYr eq "forgot") { 

			request.FieldErrorCY = "<br />Please choose the year your card expires.";

			request.FieldInvalid = "YES";

		}

		

	} // End IF for CC number check

	

} // End IF for PO number check

 

</cfscript>

Open in new window

0
 

Author Comment

by:tam423
ID: 21798743
Thank you again, msfletch! I appreciate you taking the time to send a more efficient coded version. I will plug this one in and be good to go. Many thanks, once again. Tam
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now