Solved

PayPal Integration:  Sending multiple dynamic items to PayPal

Posted on 2007-11-20
3
684 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
Comment Utility
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
Comment Utility
Sorry, on line 25 the REM should be "CLOSE LOOP HERE"
0
 

Author Closing Comment

by:lshane
Comment Utility
Thanks so much, R Harrison.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

11 Experts available now in Live!

Get 1:1 Help Now