EasyCFM.COM ColdFusion Forums / ASP to CFML / Need help - Nochex APC

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Need help - Nochex APC

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

fantasy
11-01-2006 @ 11:44 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 39
Joined: Jul 2006

Guys and girls,

I need some help converting a piece of ASP code to CFM. It is the APC for Nochex - an online payment provider in the UK - a bit like paypal.

Anyway, here is the code I need to convert:


<%@ Language=VBScript %>

<%

'requires Microsoft XML Parser http://msdn.microsoft.com/xml


Dim objHttp                              'object used for posting form data to nochex
Dim nochexformdata                              'variable used to store form data sent from NOCHEX
Dim NochexResponse                              'stores the response from the NOCHEX server

nochexformdata = Request.Form                         'copy the form data from NOCHEX into the variable

set objHttp = Server.CreateObject("MSXML2.XMLHTTP")               'create an instance of the XML object library
objHttp.open "POST", "https://www.nochex.com/nochex.dll/apc/apc", false          'set the page to post the form data to the NOCHEX server
objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHttp.Send nochexformdata                         'send the form data received from NOCHEX to the NOCHEX server

' Check notification validation
if (objHttp.status = 200 ) then
     if (objHttp.responseText = "AUTHORISED") then                                        
          NochexResponse = "AUTHORISED"
          'check the transaction_id to make sure it is not a duplicate
          'process transaction
     elseif (objHttp.responseText = "DECLINED") then
          NochexResponse = "DECLINED"
          'log and investigate incorrect data
     end if
else
     NochexResponse = "NO RESPONSE "          
end if

%>


I have the following so far (using a bit of Pablo's Paypal IPN guidance):


<CFSET str = "">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "&#LCase(TheField)#=#URLEncodedFormat(Form[TheField])#">
</CFLOOP>

<CFHTTP URL="https://www.nochex.com/nochex.dll/apc/apc?#str#" METHOD="GET" RESOLVEURL="false">
</CFHTTP>

<cfif CFHTTP.FileContent EQ "AUTHORISED">
Process payment info to db
<cfelse>
card not authorised
</cfif>


I need to get an 'authorised' response from the APC to show that I am posting back all the form variables exactly as I receive them, but I just get 'declined' so something is wrong. I am probably missing something obvious but I cant see it. If you need any more info let me know.

Cheers

www.funfantasies.co.uk

twista
11-01-2006 @ 12:32 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 232
Joined: Jun 2006

I'm not sure if the others can will help you, so I'll try.

First, dump that cfhttp scope and find out what it returns. As far as I'm aware, authorized is spelled with a z. Could be that simple, but I doubt it.

Next, if you could get that asp code in C# instead of that nasty VBscript, I could help you out alot more.

-------------
-Morgan
Lead Trainer of the Ninja Squirrels
quote:

every time you store comma delimited values in a relational database, God kills a kitty.
-CJ

SirRawlins
11-01-2006 @ 3:09 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 951
Joined: Mar 2006

Rather than doing a direct conversion of the ASP code over to CFML, i'd take a step back and re-assess the problems and goals, there is no gaurentee that the ASP method is the best way to achieve integration with the nochex API.

I would get some documentation on the NoChex API and build the solution to integrate with it from scratch.

I would imagine its not too different from PayPal as they offer a very similar service, so you can probably take a PayPal tutorial and re-use some of the methodology.

I'd recommend starting from scratch, we'll be more than happy to lend a hand if you can explain a little about what you're trying to achieve.

Rob

fantasy
11-02-2006 @ 7:03 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 39
Joined: Jul 2006

Thanks Guys.

The APC documentation doesnt contain any Coldfusion example code which is why I need some help. I have also used pablo's Paypal IPN tutorial to define the CFM code that I think should work but no luck.

The CFHTTP scope only returns either "DECLINED" or "AUTHORISED". I need to get "AUTHORISED" but keep getting "DECLINED". According to the APC documentation it means I am not returning the form variables back to them exactly as I receive them.

Is there any way to dump the form contents within the CFLOOP at the start of my code? That may help me.

www.funfantasies.co.uk

Webmaster
11-02-2006 @ 10:32 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

Can you post/email the documentation and an development access point to test some code? I think that would allow us to see the actual issue quicker

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

fantasy
11-06-2006 @ 10:01 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 39
Joined: Jul 2006

Ok chaps - here goes.

This is the link to the online documentation:

http://help.nochex.com/esupport/index.php?_a=knowledgebase&_j=questiondetails&_i=104&nav=+%26gt%3B+%3Ca+href%3D%27index.php%3F_a%3Dknowledgebase%26_j%3Dsubcat%26_i%3D37%27%3ESeller+tools%3C%2Fa%3E

Pretty much explains what I need to do but I cant achieve the result.

You can assume that I have set up everyting in my account settings correctly so that wont be causing any probs.

Cheers for your help.

Daz

www.funfantasies.co.uk

fantasy
11-06-2006 @ 11:53 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 39
Joined: Jul 2006

Guys - I have worked it out!

This is it:

<CFHTTP URL="https://www.nochex.com/nochex.dll/apc/apc" METHOD="POST">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
     <cfhttpparam type="FormField" name="#LCase(TheField)#" value="#Form[TheField]#" encoded="no">
</CFLOOP>
<CFIF IsDefined("FORM.transaction_date")>
     <cfhttpparam type="FormField" name="transaction_date" value="#Form.transaction_date#" encoded="no">
</CFIF>
</CFHTTP>

I needed to loop the form fields with CFHTTPPARAM to post them back to the APC server. I now get AUTHORISED. cool. Smile

www.funfantasies.co.uk

This message was edited by fantasy on 11-6-06 @ 12:09 PM

megan
11-06-2006 @ 12:08 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 2398
Joined: Jan 2003

Congratulations! Smile

& Thanks! for coming back and posting the solugion - I know some future person is going to be grateful ;P

~megan

We have art so that we shall not die of reality ~ Nietzsche

fantasy
11-06-2006 @ 12:10 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 39
Joined: Jul 2006

No probs Megan.

If anyone wants a working example let me know.

www.funfantasies.co.uk


Website Designed and Developed by Pablo Varando.