Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PayPal Integration:  Sending multiple dynamic items to PayPal

Posted on 2007-11-20
3
Medium Priority
?
700 Views
Last Modified: 2012-05-05
DWMX
WIN XP PRO
MS Access
Classic ASP VBScript

Hello.  I have created a very small shopping cart that uses session variables and pulls the product information from an MS Access db.  I'm at the "Checkout" page now and need to send these items to PayPal for purchase.  I am not sure how to do that.  I found code on the PayPal Integration site, but I am not sure how to make sense of it.  Even the examples for the "Multiple Items" scenarios look like they are manually generated, but I need to send my current individual items from a session variable.

(To view currently, the website is <http://www.alholley.com/al2/music_details.asp?projID=igim>)
Just "Add to cart" to see how it's working.

I really need some help.  Here is the PayPal Integration code I located for "Individual Items"
==============================================================================
<form action="https://www.paypal.com/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="you@youremail.com">
<input type="hidden" name="item_name" value="Item Name">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="0.00">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
==============================================================================
==============================================================================
Here is the code that displays my product information on the "Checkout" page:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr bgcolor="#FFFFCC">
              <td><font size="2" face="Verdana"><strong>ID</strong></font></td>
              <td><font size="2" face="Verdana"><strong>Product</strong></font></td>
              <td align="center"><font size="2" face="Verdana"><strong>Price</strong></font></td>
              <td align="center"><font size="2" face="Verdana"><strong>Quantity</strong></font></td>
            </tr>
            <tr bgcolor="#FFFFCC">
              <td colspan="4"><hr></td>
              </tr>

<%
FOR x = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, x ) <> "" THEN
orderTotal = orderTotal + ( localCart( CARTPPRICE, x ) * localCart( CARTPQUANTITY, x ) )

DIM chId,chProduct,chPrice,chQuantity
chId=(localCart( CARTPID, x) )
chProduct=Server.HTMLEncode( localCart( CARTPNAME, x ) )
chPrice=formatCurrency( localCart( CARTPPRICE, x ) )
chQuantity=localCart( CARTPQUANTITY, x )%>
            <tr bgcolor="#FFFFCC">
              <td><font size="2" face="Courier New, Courier, mono"><%=chId%></font></td>
              <td><font size="2" face="Courier New, Courier, mono"><%=chProduct%></font></td>
              <td align="center"><font size="2" face="Courier New, Courier, mono"><%=chPrice%></font></td>
              <td align="center"><font size="2" face="Courier New, Courier, mono"><%=chQuantity%></font></td>
            </tr>


<%
END IF
NEXT
%>
          </table>
==============================================================================

I need to pass the "chId,chProduct,chPrice,chQuantity" information, but I'm not sure how to do it.  I know on a "Single Item" button, I would use the "item_number" variable and give it a value of the recordset.  However, I'm not sure how to do this when multiple items are in play.

Thank you so much in advance,
Shane
0
Comment
Question by:lshane
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
R_Harrison earned 2000 total points
ID: 20326436
Below is a page which can submit multiple items.  The "page_style" can be removed if you have not setup a page style in Paypal in which case it will use its default style.  Also as the bottom the "handling_cart" is set so that there is no Postage & Packing.



<html>
<head>
</head>
<body>
<font face="Verdana"><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/us/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="page_style" value="NameOfStyle">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="yourbusiness@yourdomain.com">
<input type="hidden" name="currency_code" value="USD">
<%
itemnr=0
 
REM --- ADD A LOOP HERE TO GO THROUGH YOUR BASKET -----
 
	itemnr=itemnr+1
	response.write("<input type=""hidden"" name=""item_name_" & itemnr & """ value=""Description of the Item"">" & vbcrlf)
	response.write("<input type=""hidden"" name=""amount_" & itemnr & """ value=""100.00"">" & vbcrlf)
	response.write("<input type=""hidden"" name=""quantity_" & itemnr & """ value=""1"">" & vbcrlf)
 
REM --- ADD A LOOP HERE TO GO THROUGH YOUR BASKET -----
 
%>
<input type="hidden" name="handling_cart" value="0.00">
<input type="hidden" name="no_note" value="1">
</form>
<SCRIPT>
document.PP.submit();
</SCRIPT>

Open in new window

0
 
LVL 12

Expert Comment

by:R_Harrison
ID: 20326443
Sorry, on line 25 the REM should be "CLOSE LOOP HERE"
0
 

Author Closing Comment

by:lshane
ID: 31410277
Thanks so much, R Harrison.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question