This little script will send your shopping cart to Paypal. It assumes you
have collected the shopping in a database and loops through your database
records to create the required form and submits it to Paypal. You do not have to
change any settings in Paypal to make the script work, however the script does
allow you to specify a Page Style from Paypal if you have one. The script
also includes the "Custom" field allowing you to pass a variable to Paypal.
This "Custom" value is sent back with Paypal IPNs - see the Paypal IPN script.

PaypalCart.asp
<html>
<head>
</head>
<body>
<b>Please wait while you are transferred to PayPal.</b></font>
<p><font face="Verdana" size="2">If you are not transferred within 5 seconds
please <a href="JAVASCRIPT:document.PP.submit();">click here</a></font></p>
<form name="PP" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="page_style" value="IF YOU HAVE A PAGE STYLE SETUP IN PAYPAL ADD THE NAME HERE">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="YOUR PAYPAL EMAIL ADDRESS HERE">
<input type="hidden" name="currency_code" value="GBP">
<%
itemnr=0
' NOW ADD YOUR ITEMS TO THE CART FROM YOUR DATABASE
' CONNECT TO YOUR DATABASE
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("\FPDB\YOUR DATABASE.MDB")
Set RS=Conn.Execute("SELECT * From YOURTABLE WHERE (ADD YOUR FILTER)")
Do Until RS.EOF
' Loop through the records and add to your form
ItemDescription=RS("ItemDescription") '-- description of item in cart
ItemAmount=RS("ItemDescription") '-- cost of the item
ItemQuantity=RS("ItemQuantity") '--- quantity of item ordered
itemnr=itemnr+1
response.write("<input type=""hidden"" name=""item_name_" & itemnr & """ value=""" & ItemDescription & """>" & vbcrlf)
response.write("<input type=""hidden"" name=""amount_" & itemnr & """ value=""" & ItemAmount & """>" & vbcrlf)
response.write("<input type=""hidden"" name=""quantity_" & itemnr & """ value=""" & ItemQuantity & """>" & vbcrlf)
RS.MoveNext
Loop
RS.Close
Conn.Close
response.write("<input type=""hidden"" name=""handling_cart"" value=""0.00"">" & vbcrlf) '--- This is the shipping cost
response.write("<input type=""hidden"" name=""custom"" value=""ADD A CUSTOM VALUE""> '-- Add your own identifier, such as the cart id - this will be included in IPN notifications
%>
</form>
<SCRIPT>
document.PP.submit();
</SCRIPT>
<head>
</head>
<body>
<b>Please wait while you are transferred to PayPal.</b></font>
<p><font face="Verdana" size="2">If you are not transferred within 5 seconds
please <a href="JAVASCRIPT:document.PP.submit();">click here</a></font></p>
<form name="PP" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="page_style" value="IF YOU HAVE A PAGE STYLE SETUP IN PAYPAL ADD THE NAME HERE">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="YOUR PAYPAL EMAIL ADDRESS HERE">
<input type="hidden" name="currency_code" value="GBP">
<%
itemnr=0
' NOW ADD YOUR ITEMS TO THE CART FROM YOUR DATABASE
' CONNECT TO YOUR DATABASE
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("\FPDB\YOUR DATABASE.MDB")
Set RS=Conn.Execute("SELECT * From YOURTABLE WHERE (ADD YOUR FILTER)")
Do Until RS.EOF
' Loop through the records and add to your form
ItemDescription=RS("ItemDescription") '-- description of item in cart
ItemAmount=RS("ItemDescription") '-- cost of the item
ItemQuantity=RS("ItemQuantity") '--- quantity of item ordered
itemnr=itemnr+1
response.write("<input type=""hidden"" name=""item_name_" & itemnr & """ value=""" & ItemDescription & """>" & vbcrlf)
response.write("<input type=""hidden"" name=""amount_" & itemnr & """ value=""" & ItemAmount & """>" & vbcrlf)
response.write("<input type=""hidden"" name=""quantity_" & itemnr & """ value=""" & ItemQuantity & """>" & vbcrlf)
RS.MoveNext
Loop
RS.Close
Conn.Close
response.write("<input type=""hidden"" name=""handling_cart"" value=""0.00"">" & vbcrlf) '--- This is the shipping cost
response.write("<input type=""hidden"" name=""custom"" value=""ADD A CUSTOM VALUE""> '-- Add your own identifier, such as the cart id - this will be included in IPN notifications
%>
</form>
<SCRIPT>
document.PP.submit();
</SCRIPT>