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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP shopping cart for paypal in existing site

Status
Not open for further replies.

sdagger2

Programmer
May 5, 2008
39
0
0
GB
Hi

I currently have a website written in classic ASP hosted with I have developed a site a while ago and now wanting to implement a simple asp shopping cart which will then pass through the information to paypal (not sure if to choose paypal express, standard or pro yet).

I have hunted hi and low for asp carts such as comersus etc but cannot find a simple tutorial on how to implement a shopping cart into my site. The website only has 3 products of food with an option of different flavours.

I would like a basic site that will allow you to choose the products, specify quantity and flavour which an option to continue shopping and have a link to view cart. The view cart will show the quantities (remove option or change quantity) and shipping costs.

When checkout is clicked, I would hope for it to go to the https secure server within paypal, complete transaction then return to the website (maybe refresh the page to say order complete and fire out a cdosys email perhaps).

Most carts and services I have found offer solutions but you need to host your code with them or use their templates...I just want to insert a cart into my existing site then send values to paypal.

My main question I guess is:

1) Is there a shopping cart I can manipulate/extract variables/code and insert into my website.
2) How do I send the variables to paypal to process.
3) A tutorial from start to finish would be great.

Although i'm familiar with ASP and VB, I'm not the best programmer so would like some good ABC steps on how to achieve this?

Thank you for any help you can give.
 
hi.
i have a website that uses paypal for payment and it is in classic asp.
here's the code that i use. after "submit", it goes to paypal, the customer pays and it either stays in paypal or the customer returns to wherever.
Code:
<!-- PayPal Logo -->
<table border="0" cellpadding="10" cellspacing="0" align="center">
<tr><td align="center"></td></tr>
<tr><td align="center">
<a href="#" onclick="javascript:window.open('[URL unfurl="true"]https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no,[/URL] location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350');">
<img  src="[URL unfurl="true"]https://www.paypal.com/en_US/i/bnr/horizontal_solution_PPeCheck.gif"[/URL] border="0" alt="Solution Graphics"></a></td>
</tr>
</table>
<!-- PayPal Logo --> 


  
      <center>
      <form action="[URL unfurl="true"]https://www.paypal.com/cgi-bin/webscr"[/URL] method="post">
            <input type="hidden" name="cmd" value="_cart"/>
            <input type="hidden" name="upload" value="1">
            <input type="hidden" name="business" value="paypal_account_email"/>
            <input type="hidden" name="item_name_1" value="<%=item_name%>"/>
            <input type="hidden" name="amount_1" value="<%=amt%>"/>
            <input type="submit" value="Confirm & Pay">
      </form> 
      </center>
you have to calculate amt and supply item_name. paypal requires that.
 
Paypal has LOTS of tutorials and a huge KB on how to use their payment gateways, don't think this is quite the right place to be asking how to implement paypal onto your site.

As far as a shopping cart is concerned, it's not as hard as many people think to create one from scratch (especially if it's a basic cart).

It's as easy as storing "items" and "totals" in a series of session variables and displaying these values on a "review cart" page. Once the user is ready to pay, you send all this information to paypal, the request is processed and they return a value back to your site with an "approval" or "declined" code. You take this information and process it to either "complete" or "reject" the sale.

Example:

If you have two items in a cart - id #1001 and #1010 for a total of $150:

When the user clicks "pay", you write a new entry into a db table called "orders":

order_id (PK-AUTOINC)
order_items (1001,1010)
order_total ($150)
order_status (0=new, 1=approved, 2=declined)
create_date
completion_date

Once the values are entered, get the ID of the order and the amount, pass those values to Pay Pay.

Once completed, paypal will return the ID of the order back to you with either "approved" or "declined" - you can specify through paypal exactly which page you want the user to be brought to on your site.

On this page...

IF approved, get the ID and update the appropriate record in the db by setting the "order_status" to 1 and update the "completion_date" - redirect the user to a "thank you page" - if declined, update the status to 2 and redirect the user to a "sorry page"


--------

GOOGLE is a great resource to find answers to questions like "how do i..."


--------
 
Hi vicvirk

Thank you for your explanation. Thats the sort of answer I was looking for...nice and simple yet explained nicely.

That is what I didn't know, would it be a case of just passing variables into paypal and receiving variables back. I didn't know if that is how it worked but your explanation made it a lot clearer...I just wish there were a tutorial page that laid it all out as easy as that...ie, this is variables passed in.. this is the variable you get back. Why do all these sites have to over complicate matters?

Thank you again. I should be starting my new project next week so hopefully have a nice cart and payment system in place the week after.

 
Hi

It has been a while since I started this but now got back into it. Now that I have opened a web standard paypal account it is a lot clearer. I have managed to pass in variables to paypal and seen it working where as last time I posted questions, I was working blind.

My new question (hopefully not a silly one) is how can I pass secure values to paypal via the form?

I have created the <form> and supplied paypal with the hidden values (using my web standard email address) but what is stopping the average user downloading the html, changing the html values and re-submitting the form with lesser prices etc.

I first tried using the button creator within paypay and using the hidden value customer ID rather than the email. This worked great but you cannot pass through a discount value this way. the form I have created calculates all the necesary product prices and discounts on my website, then passes the variables through to paypal once payment should be made. I would like to pass through the values securely.

Could anybody give any advise? I am using classic ASP which gets the price and product information from MS Access database.

Thank you to anyone who can help.



 
I think the main question i'm trying to ask is how to pass the values to paypal using ASP?

When a user clicks the submit button, the post action of the form goes to PayPal, but if they view source before clicking, you can see the values (ie, change them). I would like to know how to submit the form to paypal after without this being possible? A code example would be great.
 
Hi

One thing u could do is have ajax display the paypal button that way the form is not visable in a normal view source i have done this my self, but it is only a half fix u could see the source if u used debuger in chrome for instance, i am currently working on a script to fix this in essence u willl submit to my script when u press the paypal button then i will populate varibles server side on send on to paypal

Tim Dodgson
timdodgson@msn.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top