• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 513
  • Last Modified:

php to coldfsion

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
Panos
Asked:
Panos
  • 17
  • 15
1 Solution
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
Okay, let me go through the proxypay3 guide quickly, I will get back to you in  a few..
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
0
 
PanosAuthor Commented:
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
 
PanosAuthor Commented:
sorry the last output is postdata (...output="#postdata#" addnewline="yes"...)
0
 
PanosAuthor Commented:
I did sent you the php validation and confirmation files from the dokumentation to your email
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
Validation.cfm

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

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

That's all
0
 
PanosAuthor Commented:
go on
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
Yeah, you need to work on the Validation page to get the information...
0
 
PanosAuthor Commented:
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
 
PanosAuthor Commented:
Thank you again
regards
panos
0
 
PanosAuthor Commented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
Read this post... it proves that CF 6 and CF 7 also supports SSLv3.

0
 
PanosAuthor Commented:
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
 
Brijesh ChauhanStaff IT EngineerCommented:
please email me the complete log file.. will try to check it out..
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
Yes. You can try it now. I opened the port.
0
 
PanosAuthor Commented:
The rsult is always the same. I get transaction failed with the same message Operation timed out: connect
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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
 
PanosAuthor Commented:
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
 
PanosAuthor Commented:
brijeshchauhan can you delete the 36508398  comment. There is my personal id.!
0
 
Brijesh ChauhanStaff IT EngineerCommented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 17
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now