Copy link to clipboard
Copied
I am slowly but surely getting to grips with PayPal integration. I am trying to connect to their SetExpressCheckout API
I have a CFHTTP set up as a GET (also tried post)
It manages to authenticate me, but as soon as I give the CFHTTP a NAME="test_paypal" for example along with DELIMITER="&", it gives me a problem.
It says that the first variable returned which is TOKEN is an invalid name, it looks like this is a reserved name in CF?
I see this and a few other variables that I need using CFHTTP.FILECONTENT
Is there another way to correctly read all the variables returned without running into this issue?
Btw Any developers out there interested in working on this for me please let me know, I'll be on this for a lifetime at this rate!
Thanks
Mark
Copy link to clipboard
Copied
What does the code look the that is throwing the error?
If it is, as I suspect, when you try to reference the variable and you are using 'dot' notation. This can almost always be resovled by using 'array' notation.
I.E. if you are using something like payPal.token and it is throwing an error, you can get to the same data with payPal["token"].
Copy link to clipboard
Copied
Hi Ian,
Here is the code, and the server response that I get. If I try to use NAME= , it just goes into invalid variable for TOKEN
<CFHTTP URL="#serverURL#" METHOD="post" THROWONERROR="YES" delimiter="&" >
<CFHTTPPARAM NAME="METHOD" VALUE="SetExpressCheckout" TYPE="FormField"
ENCODED="YES">
<CFHTTPPARAM NAME="USER" VALUE="#APIUserName#" TYPE="FormField" ENCODED="YES">
<CFHTTPPARAM NAME="PWD" VALUE="#APIPassword#" TYPE="FormField" ENCODED="YES">
<CFHTTPPARAM NAME="SIGNATURE" VALUE="#APISignature#" TYPE="FormField"
ENCODED="YES">
<CFHTTPPARAM NAME="VERSION" VALUE="#version#" TYPE="FormField" ENCODED="YES">
<CFHTTPPARAM NAME="AMT" VALUE="1.00" TYPE="FormField" ENCODED="YES">
<CFHTTPPARAM NAME="RETURNURL" VALUE="http://www.xxxxxxxxxxx.com/buy.cfm"
TYPE="FormField" ENCODED="YES">
<CFHTTPPARAM NAME="CANCELURL" VALUE="http://www.xxxxxxxxxxxxxx.com"
TYPE="FormField" ENCODED="YES">
</CFHTTP>
<CFOUTPUT>
#cfhttp.fileContent#
</CFOUTPUT>
server gives
TOKEN=EC%2d5HNxxxxxxxxxxxxxT&TIMESTAMP=2009%2d09%2d02T20%3a50%3a33Z&CORRELATIONID=52f09a0972424&ACK=Success&VERSION=59%2e0&BUILD=000000
Now if I add the NAME, I get
The following information is meant for the website developer for debugging purposes. | ||||||||||
Error Occurred While Processing Request | ||||||||||
|
Copy link to clipboard
Copied
What do you mean by "Add Name"
Where are you adding a Name property and how are you trying to use it?
Copy link to clipboard
Copied
I add a name to the CFHTTP so that I can treat it as a query, but that looks like the wrong approach for sure, that's when it throws the error
There is a CFC with the paypal example codes, but I can't run CFOBJECT on godaddy so that would be a problem, besides, can't get it to work right anyway (on local system)
Copy link to clipboard
Copied
I see and it looks like CF does not want to build a query record set with "result" as a column name.
I admit I have never ran into that, but it is possible.
It should not be to hard to manually parse that data into a record set or some other data construciton with a loop.
<cfset payPalStruct = structNew()>
<cfloop list="#cfhttp.fileContent#" index="elem" delimiter="&">
<cfset payPalStruct[listFirst(elem,"=")] = listLast(elem,"=")>
</cfloop>
<cfdump var="#payPalStruct#">
Copy link to clipboard
Copied
great, it works
Below are the results (btw I had to change delimiter to delimiterS, plural.
I used #paypalstruct.token# and it did the trick.
that's great, I've been killing myself for way too many hours over this.
(Out of interest do you do sub work incase I need further assistance on this or other CF projects that I am involved in)
Thanks
struct | |
---|---|
ACK | Success |
BUILD | 000000 |
CORRELATIONID | 6b80xxxxxxxx3be |
TIMESTAMP | 2009%2d09%2d02T21%3a29%3a30Z |
TOKEN | EC%2d1Rxxxxxxxxxxxxx7001B |
VERSION | 59%2e0 |
Copy link to clipboard
Copied
great, it works
Glad to hear it.
Below are the results (btw I had to change delimiter to delimiterS, plural.
Yes, it is always prudent to double check syntax.
I used #paypalstruct.token# and it did the trick.
that's great, I've been killing myself for way too many hours over this.
(Out of interest do you do sub work incase I need further assistance on this or other CF projects that I am involved in)
Occasionally, but I am not available for much for the next few weeks.
http://www.ilsweb.com