Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clarification on paypal's IPN

Status
Not open for further replies.

doyle9732

Programmer
Apr 12, 2002
185
CA
I'm not too sure if IPN is what I need.....I've looked at the tutorial on both paypal and the one linked in another post.

I am doing a Valentine (yes, I'm running late!) donation page where for a $6 donation the user can send their love a virtual chocolate, flower or heart. So the first page is filling in their name and email and the recipients name and email and choosing their gift. If that information is complete, then I redirect them to paypal for the $6 payment. Then I want verification from paypal that they paid before sending the cfmail off. All the examples I've seen are lines and lines of code.....all I want is just the verification that they paid. I'm not using a database for this....just doing it all on the fly.....with sessions keeping track of who is who.

So is IPN what I'm wanting?

thanks!
Stpehanie
 
yeah, IPN is what you need.

for only verification it is simply the few lines at the top, and check for the ok returned.


Code:
<!--- PAYPAL WILL POST TO THIS SCRIPT --->
<cfset str="cmd=_notify-validate">
<cfloop list="#form.FieldNames#" index="TheField">
    <cfset str = str & "&#LCase(TheField)#=#URLEncodedformat(Evaluate(TheField))#">
</cfloop>
<cfif isdefined("form.payment_date")>
    <cfset str = str & "&payment_date=#URLEncodedformat(form.payment_date)#">
</cfif>
<cfif isdefined("form.subscr_date")>
    <cfset str = str & "&subscr_date=#URLEncodedformat(form.subscr_date)#">
</cfif>
<!--- SEND BACK TO PAYPAL SO THEY KNOW YOU GOT IT --->
<cfhttp url="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr?#str#"[/URL] method="GET" resolveurl="false">
</cfhttp>

<!--- paypal is done at this point. now do what you need with the results. since you can't see this script run, do a dump of the post data and save it to a file, then when you know paypal and your site are communicating, add your script to do whatever, after a valid, ok, checked out payment. --->

<cfsavecontent variable="saveipnpost">
<cfdump var="#form#">
</cfsavecontent>
<cffile action="WRITE" file="c:\physicalpathtosavefileto\ipndump.html" output="#saveipn#" nameconflict="OVERWRITE">

BTW: What's the donation for?



Kevin
 
thanks....I'll give it a try....I just registered at the PayPal forum....didn't even know it existed!

So for IPN do I not use <form> to communicate with PayPal like I usually do for donations? (Boxer Rescue Ontario)

Here is my page....those are my two boxers gracing the page.
When I get it up and running it'll be the index.cfm page. And our visitor will have a similar page for St. Patty's Day, Easter, Halloween etc. Gotta get the donations where you can! ;-)

thanks.....but I'm sure I'll be posting again.
Stephanie
 
oh, your going to need to read up on ipn!

Here is an example of me sending paypal the payment info from my site.

then paypal, after the payment is complete, will respond by posting form data to your ipn script (above).

you send paypal the payment info >>

<cflocation url="&business=mypaypapemail@mydomain.com
&item_name=Online Order - #InvoiceID#
&item_number=#OrderID#
&invoice=#invoiceID#
&amount=#GrandTotal#
&return=#path#/thankyou.cfm
&cancel_return=#path#/paymentfailed.cfm
&currency_code=USD
&notify_url=#path#/ipn/ipn.cfm
&first_name=#fname#
&last_name=#lname#
&address1=#add1#
&address2=#add2#
&city=#city#
&state=#state#
&zip=#zip#
&lc=USA
&email=#session.email#
&day_phone_a=#phonea#
&day_phone_b=#phoneb#
&day_phone_c=#phonec#">


Kevin
 
ok, I am totally lost. The way I originally understood it was this:

I have a form, if filled in completely/correctly, I direct user to PayPal, using our account information in hidden variables. Up to this point, all works well. I currently have the donation amount for 1 cent, as not to drain my bank account.

I turned the IPN on at PayPal and put the returning URL to our site, specifically to the actual cfm file that should carry on processing...checks for payment and then sends the cfmail and thanks the user for the donation. It was just making it work that was challenging me. ;-) But the concept of what I needed to do was fairly clear.

I tried your code. First roadblock/stupid question:

<cfloop list="#form.FieldNames#"
is FieldNames a reserved word that automatically picks up all my form field names? (I have 4 text inputs and one radio button - SenderName, SenderEmail, RecipientName, RecipientEmail, gift)...or is this something I am supposed to set previous to this script?

OK, I've read your recent reply.....I am astounded that there doesn't seem to be a clear cut, somewhat easy to understand tutorial on this.....every site I've been to seems to just confuse me more...of course, maybe it's just me. :-s I will read up more on IPN. If I don't have this ready for Feb 14, I'll shoot for St. Patrick's Day.

thanks and wish me luck!
Stephanie
 
FieldNames is a html returned form field that contains a list of the actuall form fields sent.

do a cfdump var="#form#" on any form a FieldNames is one of the fields in the form. its an html thing.

Kevin
 
ok, I think I'm getting close. I have everything working as planned up to when PayPal returns to my page where I get this.....

Element FILECONTENT is undefined in CFHTTP

When it returns to my page, I have all the email and name information because they are session variables....but I just need a trigger that it came from Paypal.

is there an CFHTTP variable that would be returned? I just tried .url, but that was undefined too. Or any other tag that would be a trigger that it's coming from PayPal? If they cancel at PayPal, it goes to another page, and they should only get to this page if they've been to PayPal and completed the transaction.

Sorry if I'm not quite getting this.

Stephanie
 
thecfdump in the first code I posted will have all the form varialbes that paypal sends back. they contain all the payment information, addresses, amounts, names, transaction ids, tax, shipping, billing, emails, phone numbers, payment type, payed or not payed, verified or not, etc.

you need to use this info during the ipn script to verify that the user payed.

Kevin
 
ok, I have tried to work this out on my own and I just have too many questions.

Firstly, my checkForm.cfm file is the action from the original form. I check for valid entries and then have the <form> for paypal.
*************************************
<form action=" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="my@email.com">
<input type="hidden" name="item_name" value="#session.gift#">
<input type="hidden" name="return" value=" <input type="hidden" name="cancel_return" value=" <input type="hidden" name="notify_url" value=" <input type="hidden" name="amount" value=".01">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="CAD">
<input type="image" src=" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

*********************************

should the code at the top of this page go on this page? Even though it has the paypal submit button? I put the top half of the code on the page but get this error:

Element FIELDNAMES is undefined in FORM.

I also don't understand how PayPal knows who I am by this code:

<cfhttp url=" method="GET" resolveurl="false">


What am I not getting??

Stephanie
 
paypal has posted a form to your ipn script, and you reply with exactly what they sent you for verification, otherwise they will resend the same data for a few days until you get it.

Thats how they know you got it, and know not to send it again.

and you have the data from paypal in your form scope to do whatever you need with.

There is a pdf all about ipn that is 150 or so pages on paypal website. check it out!


Kevin
 
yes, I found the pdf on paypal....it did help quite a bit, but I was still confused about the way I told PayPal about the order.

I will try it again.....I do appreciate you answering :) If and when I get it working, I'll send you a virtual chocolate.

Stephanie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top