How shall I post a variable number of user-defined data to Paypal?
Friends, I have some shopping cart code that I took over when I started with a company, but unfortunately I'm weak on Java and integrating with Paypal. Here is the form that sends data to Paypal when a customer checks out of the shopping cart. I can get it to send one product, but I would like it to include data on all the products purchased from the cart. I am thinking logic:iterate will help me? But then how do I increment the "on#" and "os#" when presented with a variable amount of products?
<form name="paypal" id="paypal" style="float:left;" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="business" value="shop@myshop.com">
<input type="hidden" name="item_name" value="Order Detail Information">
<input type="hidden" name="amount" id="amount" value="${tdollarTotal}">
<input type="hidden" name="currency_code" id="currency" value="USD">
<input type="hidden" name="o开发者_如何学运维n0" value="buyMethod">
<input type="hidden" name="os0" id="buyMethod" value="Shopping Cart">
<input type="hidden" name="on1" value="orderId">
<input type="hidden" name="os1" id="orderId" value="">
<input type="hidden" name="on2" value="Address">
<input type="hidden" name="os2" value="Kunming Yunnan China">
<input type="hidden" name="on3" value="Purchased at">
<input type="hidden" name="os3" value="www.danyunfairtrade.com">
<logic:present name="shopclass" property="cart">
<logic:iterate id="cartinfo" name="shopclass" property="cart" indexId="index">
<bean:define id="product" name="cartinfo" property="product"></bean:define>
<input type="hidden" name="on4" value="productNo">
<input type="hidden" name="os4" id="productNo" value="${product.productNo }">
<input type="hidden" name="on5" value="productName">
<input type="hidden" name="os5" id="productName" value="${product.name }">
</logic:iterate>
</logic:present>
<input type="hidden" name="notify_url" value="http://www.danyunfairtrade.com/cart.html">
<img name="Paypal" src="/images/qujiesuan.gif" class="jiesuan" border=0 style="cursor: pointer;" onclick="javascript:goPayPal();" />
</form>
What you're looking for is 'cart upload' functionality. See below for an example:
<form action="https://www.paypal.com/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="seller@example.com">
<input type="hidden" name="item_name_1" value="First items">
<input type="hidden" name="amount_1" value="3.00">
<input type="hidden" name="item_name_2" value="Second items">
<input type="hidden" name="amount_2" value="5.00">
<input type="submit" value="PayPal">
</form>
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_cart_upload
精彩评论