Solved

PayPal Integration:  Sending multiple dynamic items to PayPal

Posted on 2007-11-20
3
686 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 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP equivalent to Windows findstr 3 77
Copy only dates 3 88
Forcing form refresh - classic ASP 7 64
Save ms data to server side. 19 41
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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now