Solved

PayPal Integration:  Sending multiple dynamic items to PayPal

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating Date 4 30
Extracting nodes  using classical ASP 3 29
Html split(text) Part2 6 25
isNaN issue on the Table input text 2 8
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/…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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