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!

Need help setting up site with paypal

Status
Not open for further replies.

AlwaysWilling

Programmer
Dec 29, 2005
51
US
Hi all, this is my first post here, so apologies for any mistakes I make.

I am developing a site using coldfusion and want to use paypal as one of the payment methods. But I need some help in setting up my site with paypal and IPN.

I have my own shopping cart, and have already been able to add products to the basket, but now I want to do the actual checkout process. How do I do that?

I have been to the PayPal site and looked at their sample cf code sample and also looked at the paypal ipn tutorial from easycfm.com but I am still lost.

I am using this sample CF code from PayPal's "IPN Code Samples":

Code:
<!-- read post from PayPal system and add 'cmd' -->
<CFSET str="cmd=_notify-validate">
<CFLOOP INDEX="TheField" list="#Form.FieldNames#">
<CFSET str = str & "&#LCase(TheField)#=#URLEncodedFormat(Form[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>
<CFIF IsDefined("FORM.auction_closing_date")>
<CFSET str = str & "&subscr_date=#URLEncodedFormat(Form.auction_closing_date)#">
</CFIF>
<!-- post back to PayPal system to validate -->
<CFHTTP URL="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr?#str#"[/URL] METHOD="GET" RESOLVEURL="false">
</CFHTTP>
<!-- assign posted variables to local variables -->
<CFSET item_name=FORM.item_name>
<CFSET payment_status=FORM.payment_status>
<CFSET payment_amount=FORM.mc_gross>
<CFSET payment_currency=FORM.mc_currency>
<CFSET txn_id=FORM.txn_id>
<CFSET receiver_email=FORM.receiver_email>
<CFSET payer_email=FORM.payer_email>
<CFIF IsDefined("FORM.item_number")>
<CFSET item_number=FORM.item_number>
</CFIF>
<!-- check notification validation -->
<CFIF #CFHTTP.FileContent# is "VERIFIED">
<!-- check that payment_status=Completed -->
<!-- check that txn_id has not been previously processed -->
<!-- check that receiver_email is your Primary PayPal email -->
<!-- check that payment_amount/payment_currency are correct -->
<!-- process payment -->
<CFELSEIF #CFHTTP.FileContent# is "INVALID">
<!-- log for investigation -->
<CFELSE>
<!-- error -->
</CFIF>

But I am totally lost on what I need to do implement my cart to PayPal.

Any help is appreciated?

Thank you very much.
 
first you need to gather the required information about the payment to send to the user paypal.The ammount, your paypal id, your ipn url, your thank you page url, etc etc. I use cflocation to send the user to the paypal payment page after checkout. You could just as well have them click on a link. You will need to read the paypal information on how to properly format this url.

when the user completes checkout, paypal will sent a request to your ipn script. if ewverything is ok, paypal will send you all the details about the transaction to the ipn scrip. then you can do whatever you like with them.

maybe for testng start with a hard coded url to the payment page with a $0.01 ammount (you can refund them later) set up another paypal account in a friends or wifes name or whatever to test with. I find this easier than the paypal test environment.

the paypal cf example script does work just fine. you just need to add the functionality of storing the transaction information.

1. user puts items in cart.
2. user checks out.
3. order details saved to database
4. user sent to paypal for payment
5. pp ipn verifies payment and notifies your ipn script
6. your ipn script saves transaction information to your database to corrospond with the order information you saved previously.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top