YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Insert Multiple Items from IPN into DB then view Options
tespun
#1 Posted : Wednesday, August 27, 2003 7:03:47 PM
Rank: Starting Member

Groups: Registered

Joined: 8/27/2003
Posts: 3
Location: ,
I have five items numbers item_number1, item_number2, item_number3, item_number4, item_number5. I want to pull the the values of these item numbers from IPN and insert them into one field of a database delimited by a comma(or something else). I then want to later retrive this information and display it. Using CF: 1) How do I parse the multiple values from the IPN and then insert it into the DB field seperated by commas? 2) How do I then later retrive and separate these values from the db field and display them like: item_number1 item_number2 item_number3 item_number4 item_number5 I've seen much of the CF code in this forum but it doesn't seem to answer my questions. I'm little more then a beginner at CF so any sample code would be helpful. Thanks!!!
Sponsor  
 
paypal_pb
#2 Posted : Wednesday, August 27, 2003 7:58:38 PM
Rank: Starting Member

Groups: Registered

Joined: 9/16/2002
Posts: 2,960
Location: ,
PayPal supports one item_number per product. Do you need to pass 5 pieces of data through for each product? Or do you have 5 products?

Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn
tespun
#3 Posted : Thursday, August 28, 2003 12:10:11 AM
Rank: Starting Member

Groups: Registered

Joined: 8/27/2003
Posts: 3
Location: ,
I have 5 products

thanks
paypal_pb
#4 Posted : Thursday, August 28, 2003 3:12:36 PM
Rank: Starting Member

Groups: Registered

Joined: 9/16/2002
Posts: 2,960
Location: ,
Then you should have 5 Add to Cart or Buy buttons each with a different "item_number".

I don't have enough familiarity with ColdFusion database access, however.

Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn
tespun
#5 Posted : Thursday, August 28, 2003 4:07:18 PM
Rank: Starting Member

Groups: Registered

Joined: 8/27/2003
Posts: 3
Location: ,
This is to take place after I complete the transaction and Paypal gives me the info from the IPN Post. How do I seperate and then insert the five products into the DB from the IPN post using coldfusion.

logic i.e.

<!--- retrieve item numbers from IPN Post then set them equal to my variables --->
x= 0
loop for number of products
myItemnumber[x] = item_number[x]
x + 1

<!---- "myItemnumber" is the variable I create. "item_number" is from the IPN Post ---->



<!--- Insert Item Numbers into one field of my DB as a comma delimited list --->

allmyproducts = myItemnumber[1], myItemnumber[2], myItemnumber[3], myItemnumber[4], myItemnumber[5]

<!---insert into DB field---->
INSERT allmyproducts into myDBItemNumbers



<!---retrieve for later reporting or for customer reciept--->
<!---Delimiate DB field myDBItemNumbers using commas to show--->

Order: 5643 Date:8/27/03
The following items were ordered.

<---actual item numbers posted from paypal IPN--->
321
561
554
751


If anyone has a CF solution for this please share it. Thank YOU!
gideon
#6 Posted : Monday, October 13, 2003 3:23:34 AM
Rank: Starting Member

Groups: Registered

Joined: 10/13/2003
Posts: 3
Location: ,
If anyone has a CF solution for this please share it. Thank YOU!

:) I saw your post and thought - hey, I can write that for this guy!

so here we go - oh, and this first section should work as I did test it just to make sure - I also included a bunch of comments so you could understand what is happening along the way.

I don't come through here - but I'll try to check back and make sure things worked out. otherwise - you can reach me through my biz site at http://www.WebAndAudio.com



========================================

===========
1) How do I parse the multiple values from the IPN and then insert it into the DB field seperated by commas?
===========

<!--- Set an empty variable for the list --->
<CFSET ItemList="">
<!--- run a loop over the fieldnames to extract only the ones called 'item_numberX' --->
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<!--- item_number is 11 char long - so we make sure it's lower case and chop
the variable's name down before checking - and check if it is item_number,
if it is, you add it to the list --->
<cfif LCase(Left(Trim(TheField),11)) IS "item_number">
<CFSET ItemList = ListAppend(ItemList, Trim(Evaluate(TheField)))>
</cfif>
</CFLOOP>
<!--- now we have a list of item_numberX to insert into a field --->
<!--- use ItemList as your inserting variable --->

===========
2) How do I then later retrive and separate these values from the db field and display them like:
item_number1
item_number2
===========

<cfoutput query="YourSearch">
Order: #OrderID# Date:#DateFormat(OrderDate, 'mm/dd/yyyy')#
The following items were ordered:
</cfoutput>
<!--- run your query and set your orderId variable
which has the list to equal this db field --->
<cfset ItemList = "#YourSearch.item_numbers#">

<!--- /////////////// Option A \\\\\\\\\\\\\\ --->
<!--- If you wanted, right here you could ad a query on your item ids --->
<CFQUERY name="GetItems" datasource="#DataSource#">
Select *
From tblItems
Where ItemID IN (#ItemList#)
</CFQUERY>
<cfoutput query="GetItems">
<LI> #ItemName# - #ItemCost#</LI>
</cfoutput>

<!--- /////////////// OR Option B \\\\\\\\\\\\\\\\\\ --->
<!--- Or Loop over the list - output the index and a line break upon each loop --->
<BLOCKQUOTE>
<CFLOOP INDEX="i" list="#ItemList#">
<cfoutput>#i#<BR></cfoutput>
</CFLOOP>
</BLOCKQUOTE>
imstillatwork
#7 Posted : Friday, October 31, 2003 1:19:25 AM
Rank: Starting Member

Groups: Registered

Joined: 1/4/2003
Posts: 5
Location: ,
dont make it too hard on yourself.

build a shopping cart, send paypal ONE price, ONE item, and take care of the line items for your invoices during checkout, not via IPN. set up your invoice data on checkout, then fill in the rest when IP comes back. its WAY easier.
Chipper
#8 Posted : Wednesday, November 05, 2003 9:12:30 PM
Rank: Starting Member

Groups: Registered

Joined: 11/5/2003
Posts: 3
Location: ,
Something to try:
This worked for me quite well until a month ago, but now my IPN processing page is not handling the FORM.custom return - no sure why yet. For passing a list of variables to Paypal and then back to your IPN processing page, use the 'custom' field (up to 255 characters). Just pass a list, with delimiters. Then, when the list returns as FORM.custom, parse the list as follows. Then do your DB insert.

Like I said, I am working on a problem with this right now - not sure why it suddently stopped working. Might be the ugly-but-easy-to-read delimiters ::: ?) Try a conventional comma delimiter.

<CFIF IsDefined("FORM.custom")>
<CFOUTPUT>
<!--- custom variable list composed of stud_sysID:::class_title:::classroom_endDate:::classroom_enrollType:::classroom_tuition4Wks:::ClassFeePerQuarter --->
<CFSET custom = #FORM.custom#>
<CFSET stud_sysID = #ListGetAt(custom, 1,":::")#>
<CFSET class_title = #ListGetAt(custom, 2,":::")#>
<CFSET classroom_endDate = #ListGetAt(custom, 3,":::")#>
<CFSET classroom_EnrollType = #ListGetAt(custom, 4,":::")#>
<CFSET classroom_Tuition4Wks = #ListGetAt(custom, 5,":::")#>
<CFSET classFeePerQuarter = #ListGetAt(custom, 6,":::")#>
<CFSET classroom_numbQtrs = #ListGetAt(custom, 7,":::")#>
<CFSET school_ID = #ListGetAt(custom, 8,":::")#>
</CFOUTPUT>
</CFIF>
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.406 seconds.