• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFHTTP/PayPal SetExpressCheckout Api

Enthusiast ,
Sep 02, 2009 Sep 02, 2009

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

TOPICS
Advanced techniques

Views

2.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 02, 2009 Sep 02, 2009

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"].

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 02, 2009 Sep 02, 2009

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

Error Occurred While Processing RequestThe web site you are  accessing has experienced an unexpected error.
Please contact the website  administrator.

The following information is meant for the website developer for  debugging purposes.
Error Occurred While Processing Request

The column  name TOKEN=EC%2d5T01xxxxxxxxxx42G is invalid.

Column names must be valid variable  names. They must start with a letter and can only include letters, numbers, and  underscores.
The  error occurred in D:\ACS\paypal\index.cfm: line 27
25 : <CFHTTPPARAM NAME="RETURNURL" VALUE="http://www.xxxxxxxxxxx.com/buy.cfm" TYPE="FormField" ENCODED="YES">
26 :
27 : <CFHTTPPARAM NAME="CANCELURL" VALUE="http://www.xxxxxxxxxxx.com" TYPE="FormField" ENCODED="YES">
28 :
29 :

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 02, 2009 Sep 02, 2009

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 02, 2009 Sep 02, 2009

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 02, 2009 Sep 02, 2009

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#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 02, 2009 Sep 02, 2009

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
ACKSuccess
BUILD000000
CORRELATIONID6b80xxxxxxxx3be
TIMESTAMP2009%2d09%2d02T21%3a29%3a30Z
TOKENEC%2d1Rxxxxxxxxxxxxx7001B
VERSION59%2e0

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 02, 2009 Sep 02, 2009

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation