Solved

php to coldfsion

Posted on 2011-09-07
33
484 Views
Last Modified: 2012-05-12
Hello experts.
I need help to convert the following php lines to coldfusion.
Any help?
<?php
      if (($_POST["Shop"]==$mid)&&($_POST["Amount"]==$am)&&($_POST["Currency"]==978)&&($_POST["Ref"]==$mr)){
      echo "[OK]";}
      else{
      echo "[NOTOK]";}
       ?>
0
Comment
Question by:Panos
  • 17
  • 15
33 Comments
 
LVL 11

Accepted Solution

by:
Brijesh Chauhan earned 500 total points
ID: 36494969
Are all these form variables that you are posting ? if yes then try something like below...

<cfif (form.Shop IS #mid#)  AND (form.Amount IS #am#) AND (form.Currency IS 978) AND (form.Ref IS #mr#)>
	<cfoutput> OK </cfoutput>
<cfelse>
	<cfoutput> NOT OK </cfoutput>
</cfif>

Open in new window

0
 
LVL 2

Author Comment

by:Panos
ID: 36495020
Hi brijeshchauhan

I thought it was like this.
The guys i have troubles with proxypay3 are going to make me crazy.

The validation page  needs only that OK variable or not?
And something else.
i'm trying to catch the posted form variables in a text file using the following code but i get nothing:

<cfset postData="">
<cfloop index="i" list="#Form.FieldNames#">
<cfset postData=#postData# & #Form[i]# & ",">
</cfloop>
<!--- Write Log ---> 
<cflock name="proxypay_lock" type="exclusive" timeout="30"> 
<cffile action="append" file="#GetDirectoryFromPath(GetTemplatePath())#logs/validation.txt" mode="777" output="#postData#" addnewline="yes" charset="utf-8">
</cflock>

Open in new window

0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495032
Okay, let me go through the proxypay3 guide quickly, I will get back to you in  a few..
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495181
Panos

You need the Validation URL defined somewhere, I am not sure where, but I think it can be defined in your proxypay merchant console.. here is what you need

1. A form which will collect information

2. A CFHTTP page which will post information

3. A VALIDATION page which will check if the transaction is valid,  in that page just dump

<cfset HTTPRequestData = GetHttpRequestData()>  

<cfdump var="#HTTPRequestData#">

4. if your validation is sucessfull, then do a cflocation to CONFIRMATION page else, display error...
0
 
LVL 2

Author Comment

by:Panos
ID: 36495289
Below is my form ,the cfhttp page with the cfhttp.FileContent that has the returning form for the credit card data.
In the next step i have now my temporary validation page that is working in the background.(proxypay3 sends 4 values to this page that must be compared with the db values. If the validation will pass the page must return OK - see page 12). I tried to save the data using the code below but i did not get anything .


I can't use cflocation. After the validation pass, Proxypay3 is going to get the money for the transaction and if all is OK than the DATA with all the transaction details are posted to the confirmation page.

form page:
<form name="PayformVisa" Method="POST" action="<cfoutput>#request.homeurl#proxypay3/</cfoutput>proxypay.cfm">
<input type="hidden" Name=" APACScommand " value="NewPayment">
<INPUT TYPE="hidden" Name="merchantID" VALUE="0000"><!-- personal id -->
<INPUT TYPE="hidden" Name="amount" VALUE="100">
<!--Currencies with mantisse 2 , amount is expressed in cents-->
<INPUT TYPE="hidden" Name="currency" VALUE="0978">
<!--This parameter must be unique for every transaction.-->
<INPUT TYPE="hidden" Name="merchantRef" VALUE="2300003" >
<!--the short description of the order, useful for etickets and order information.-->
<INPUT TYPE="hidden" Name="merchantDesc" VALUE="test">
<!-- the language of the payment templates used -->
<INPUT TYPE="hidden" Name="lang" value="EN"> <!-- EN , GR -->
<INPUT TYPE="hidden" Name="Var1" VALUE="Shopper1985">
<INPUT TYPE="hidden" Name="Var2" VALUE="Visa">
<INPUT TYPE="hidden" Name="Var3" VALUE="YES">
<INPUT TYPE="hidden" Name="Var4" VALUE="276595">
<INPUT TYPE="hidden" NAME="Var5" VALUE="Andy">
<INPUT TYPE="hidden" NAME="Var6" VALUE="test@gmail.com">
<INPUT TYPE="hidden" Name="Var7" >
<INPUT TYPE="hidden" Name="Var8" >
<INPUT TYPE="hidden" Name="Var9" >
<!-- The email address of the customer-->
<INPUT TYPE="hidden" Name="CustomerEmail" VALUE="test@gmail.com">
<!-- offset period for instalments -->
<INPUT TYPE="hidden" Name="Offset" VALUE="">
<!-- period for instalments -->
<INPUT TYPE="hidden" Name="Period" VALUE="">
<INPUT TYPE=Image SRC="visa.gif" BORDER=0 VALUE="Visa"
onClick="if (PayClicked()) document.PayformVisa.submit(); return false;"
Alt="Pay with Visa" ></form>
<SCRIPT language="javascript">
<!--
var PayButtonClicked = false;
function PayClicked()
{
// Check to see if Pay Button has been clicked before
if (PayButtonClicked)
{
// Message displayed
alert ("Transaction already sent.");
return false;
}
else
PayButtonClicked = true;
return true;
}
//-->
</SCRIPT>

cfhttp page :
<cfhttp url="https://eptest.eurocommerce.gr/proxypay/apacs" method="post">
      	<cfhttpparam type="formfield" name="APACScommand" value="NewPayment">
        <cfhttpparam type="formfield" name="merchantID" value="#form.merchantID#">
        <cfhttpparam type="formfield" name="amount" value="#form.amount#">
        <cfhttpparam type="formfield" name="merchantRef" value="#form.merchantRef#">
        <cfhttpparam type="formfield" name="merchantDesc" value="#form.merchantDesc#">
        <cfhttpparam type="formfield" name="currency" value="#form.currency#">
        <cfhttpparam type="formfield" name="lang" value="#form.lang#">
        <cfhttpparam type="formfield" name="var1" value="#form.var1#">
        <cfhttpparam type="formfield" name="var2" value="#form.var2#">
        <cfhttpparam type="formfield" name="var3" value="#form.var3#">
        <cfhttpparam type="formfield" name="var4" value="#form.var4#">
        <cfhttpparam type="formfield" name="var5" value="#form.var5#">
        <cfhttpparam type="formfield" name="var6" value="#form.var6#">
        <cfhttpparam type="formfield" name="var7" value="#form.var7#">
        <cfhttpparam type="formfield" name="var8" value="#form.var8#">
        <cfhttpparam type="formfield" name="var9" value="#form.var9#">
        <cfhttpparam type="formfield" name="CustomerEmail" value="#form.CustomerEmail#">
        <cfhttpparam type="formfield" name="Offset" value="#form.Offset#">
        <cfhttpparam type="formfield" name="Period" value="#form.Period#">
      </cfhttp>
      
     <cfoutput>#cfhttp.FileContent#</cfoutput>

validation:
<cfset HTTPRequestData = GetHttpRequestData()>  
<!--- Write Log ---> 
<cflock name="proxypay_lock" type="exclusive" timeout="30"> 
<cffile action="append" file="#GetDirectoryFromPath(GetTemplatePath())#logs/validation.txt" mode="777" output="#HTTPRequestData#" addnewline="yes" charset="utf-8">
</cflock>

Open in new window

0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495355
if you dump - <cfset HTTPRequestData = GetHttpRequestData()> <cfdump var=#HTTPRequestData#>.   then what do you get ? also this should be on your Validation.cfm page.. rt ?

The content of above would be in ->  #HTTPRequestData.content#
0
 
LVL 2

Author Comment

by:Panos
ID: 36495403
0
 
LVL 2

Author Comment

by:Panos
ID: 36495415
I'm trying to catch in different ways the data but i get nothing in my validation txt file:

<cfset HTTPRequestData = GetHttpRequestData()>  
<cflock name="proxypay_lock" type="exclusive" timeout="30"> 
<cffile action="append" file="#GetDirectoryFromPath(GetTemplatePath())#logs/validation.txt" mode="777" output=" #HTTPRequestData.content#" addnewline="yes" charset="utf-8">
</cflock>
<cfdump var=#HTTPRequestData#>

<cfset postData="">
<cfloop index="i" list="#Form.FieldNames#">
<cfset postData=#postData# & #Form[i]# & ",">
</cfloop>
<!--- Write Log ---> 
<cflock name="proxypay_lock" type="exclusive" timeout="30"> 
<cffile action="append" file="#GetDirectoryFromPath(GetTemplatePath())#logs/validation.txt" mode="777" output="#HTTPRequestData#" addnewline="yes" charset="utf-8">
</cflock>
OK

Open in new window

0
 
LVL 2

Author Comment

by:Panos
ID: 36495424
sorry the last output is postdata (...output="#postdata#" addnewline="yes"...)
0
 
LVL 2

Author Comment

by:Panos
ID: 36495438
I did sent you the php validation and confirmation files from the dokumentation to your email
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495457
I did a test and was redirected to NOT OK page, which is correct though... yeah the PHP code is below and should work with above.. let me try to read me and see if something is missing

<?php 
	if ($_POST["Shop"]!=$mid){
	echo "[WRONG MERCHANT ID IN VALIDATION]";
	echo $_POST["shop"];
	echo "$mid";
}
	 ?>

	<?php 
	if ($_POST["Amount"]!=$am){
	echo "[WRONG AMOUNT IN VALIDATION]";
	echo $_POST["Amount"];
	echo "$am";
}
	 ?>

	<?php 
	if ($crncy!=$cr){
	echo "[WRONG CURRENCY IN VALIDATION]";
	echo "$crncy";
	echo "$cr";
}
	 ?>
	
	<?php 
	if ($_POST["Ref"]!=$mr){
	echo "[WRONG MERCHANTREF IN VALIDATION]";
	echo $_POST["Ref"];
	echo "$mr";
}
	 ?>	

	<?php 
	if (($_POST["Shop"]==$mid)&&($_POST["Amount"]==$am)&&($_POST["Currency"]==978)&&($_POST["Ref"]==$mr)){
	echo "[OK]";}
	else{
	echo "[NOTOK]";}
	 ?>

Open in new window

0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495551
Panos, in your Validation test page can you abort the processing so that I can just see the DUMP of all the variables ??

can you also add in there

<cfdump var="#cgi.QUERY_STRING#">
0
 
LVL 2

Author Comment

by:Panos
ID: 36495602
Can you please write exactly the validation.cfm page?

If you willmake a new try i have to give a new transaction value in the form
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495626
Validation.cfm

<cfset HTTPRequestData = GetHttpRequestData()>  
<cfdump var="#HTTPRequestData#">

<cfdump var="#cgi.QUERY_STRING#">

That's all
0
 
LVL 2

Author Comment

by:Panos
ID: 36495643
go on
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495707
I am still redirected to NOTOK page http://carbay.selfip.com/proxypay3/notok.cfm?ref=275514, can you stop the processing at Validation.cfm so that the direction to NOTOK does not happen ?? with redirection, I can't see the variables which we are dumping above..
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 2

Author Comment

by:Panos
ID: 36495795
Yeahhhhh!!!

That's what i'm talking about. I don't get any values .
Proxypay did ask me for my validation page during the process making my testaccount.
I gave them the address above. You can see in the log file i sent you that it is the same page.

I can't change ,well i can't do anything. Proypay is working in the background as i say. If it  gets the OK value from the validation page is goes to the step 3 (in this case) .get the money and send data to the confirmation page.

So the problem is with proxypay and not with my page. The log file is saying the opposite. I had a discussion today with them and they  say that the problem was with my page.
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36495842
Yeah, you need to work on the Validation page to get the information...
0
 
LVL 2

Author Comment

by:Panos
ID: 36495965
As you have seen i can't do anything because i don't get any values. i have to solve that first with proxypay
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 36495967
Thank you again
regards
panos
0
 
LVL 2

Author Comment

by:Panos
ID: 36506324
I'm back here for a question.

Reading again the guide i find out that proxypay is working with SSL3 (please take a look).
On this solution:http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_23899273.html?sfQueryTermInfo=1+10+30+connect+java.net.connectexcept+oper+out+time

expert gdemaria is saying that coldfusion8 (that is the version i'm testing with) is NOT working with ssl3.

The following part of the log file sended to me from proxypay is describing the error:

[08 Sep 2011 13:25:35,600] [CO] (Thread-25) [TransactionValidationBean: sendMerchantValidationPOST] [30202] [sendMerchantValidationPOST failed] [com.clear2pay.sslproc.socket.SSLProcSocketException: open: creating Socket Failed.; nested exception is:
      java.net.ConnectException: Operation timed out: connect]

Is this the problem?Do i have to use cf9?
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36508205
Panos

Here is the understanding of difference between SSLv2 and SSLv3

the SSLv2 handshake does not require that the browser send its own certificate back to the server. In SSLv2 only the server has to prove its identity to the client.

However, in SSLv3 not only does the server have to prove its identity to the client, but the client (the browser in this case) also has to identify itself to to the server. The browser does that by sending its own certificate in return. So there are two certifcates involved in SSLv3, one on the server and one on the client.

According to me, CF 8 Does support SSLv3 ...
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36508217
Read this post... it proves that CF 6 and CF 7 also supports SSLv3.

0
 
LVL 2

Author Comment

by:Panos
ID: 36508267
Hi brijeshchauhan.
I fall on this trying to find something about this line:
 java.net.ConnectException: Operation timed out: connect

You believe it or not the experts in the proxypay cannot help me further. The only help is the log file!
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36508277
please email me the complete log file.. will try to check it out..
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36508318
The problem seems to be while the gateway is tying to send URL back to Validation file..

http://carbay.selfip.com/proxypay3/validation.cfm

this does not seem to work, ??? can you open that file in URL... ?
0
 
LVL 2

Author Comment

by:Panos
ID: 36508350
Yes. You can try it now. I opened the port.
0
 
LVL 2

Author Comment

by:Panos
ID: 36508423
The rsult is always the same. I get transaction failed with the same message Operation timed out: connect
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36508471
the problem is definitely sending back variables to validation.cfm file.. are there any requirements from payproxy end on this URL ? may be it needs to be https:// instead of http:// ???

sendTransactionValidationPOST failed -- this is your log file says..

0
 
LVL 2

Author Comment

by:Panos
ID: 36508513
brijeshchauhan i made this question too (http or https) but they said that's not the reason.
but i will try it and come back with news.
0
 
LVL 2

Author Comment

by:Panos
ID: 36508517
brijeshchauhan can you delete the 36508398  comment. There is my personal id.!
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 36508676
Panos, I can't delete a comment, can you ask an administrator to do it for you ? Sorry for posting it, I didn't realize it had your personal ID in there...
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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

11 Experts available now in Live!

Get 1:1 Help Now