Solved

PayPal Integration:  Sending multiple dynamic items to PayPal

Posted on 2007-11-20
3
693 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
R_Harrison earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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