我想发送多个产品到paypal。 我知道将产品发送到payPal的格式是:
<input type="hidden" name="item_name_x" value="test 1">
不幸的是,它不起作用。 您认为问题是什么?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="ronny@hoojima.com">
<input type="hidden" name="item_name_1" value="test 1">
<input type="hidden" name="item_number_1" value="1">
<input type="hidden" name="item_name_2" value="test 2">
<input type="hidden" name="item_number_2" value="2">
<input type="hidden" name="item_name_3" value="test 3">
<input type="hidden" name="item_number_3" value="3">
<input type="hidden" name="amount_1" value="99.00">
<input type="hidden" name="amount_2" value="2">
<input type="hidden" name="amount_3" value="99.00">
<input type="image" name="submit" src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png" alt="PayPal - The safer, easier way to pay online">
</form>
</body>
</html>
答案 0 :(得分:1)
使用PayPal“立即购买”按钮,您无法传递多个项目。允许多个项目使用PayPal使用“购物车上传”按钮代码。请参考以下示例代码和链接供您参考:
<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="paypalemail"><!-- Add your PayPal Seller/Business email address mandatory-->
<input type="hidden" name="item_name_1" value="Item Name 1"> <!-- sample item name -->
<input type="hidden" name="amount_1" value="1.00"><!-- sample amount -->
<input type="hidden" name="shipping_1" value="1.75"><!-- sample shipping -->
<input type="hidden" name="item_name_2" value="Item Name 2">
<input type="hidden" name="amount_2" value="2.00">
<input type="hidden" name="shipping_2" value="2.50">
<input type='hidden' name='invoice' value='your Invoice Id' /> <!-- add Unique invoice for different customer -->
<input type="hidden" name="notify_url" value="www.yourwebsite.com/ipn"> <!-- Please add IPN URL You can use this service to automate back-office and administrative functions, including fulfilling orders, tracking customers, and providing status and other information related to transactions. -->
<input type='hidden' name='currency_code' value='Your currency' />
<input type='hidden' name='cancel_return' value='' /><!-- Take customers to this URL when they cancel their checkout -->
<input type='hidden' name='return' value='' /><!-- Take customers to this URL when they finish their checkout -->
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
</form>
对于PayPal按钮HTML变量,请参阅以下链接:https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
对于即时付款通知(IPN):https://developer.paypal.com/docs/classic/ipn/gs_IPN/
答案 1 :(得分:0)
感谢答案。 为了使它从购物车中通用,你可以使用它:
function updateToPayPal() {
var formChildren = $("#payPalInputs");
var itemsInTable = $("#cartTable").find('tr');
var j = 1;
for (var i = 0; i < itemsInTable.length; i++) {
var tr = itemsInTable[i];
var qty = $(tr).find('.qtyInput').val();
if(qty === undefined)
continue;
var price = $(tr).find('.total').text();
var name = $(tr).find('.name').text();
var itemName = $('<input type="hidden" name="item_name_' + j + '" value="' + name + '">');
var itemPrice = $('<input type="hidden" name="amount_' + j + '" value="' + parseInt(price) + '">');
var itemQty = $('<input type="hidden" name="quantity_' + j + '" value="' + qty + '">');
j++;
$(formChildren).append(itemName).append(itemPrice).append(itemQty);
}
}
&#13;
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="payPalInputs">
<input type="submit" id="paypal" value=""> </input>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="seller@dezignerfotos.com">
<input type="hidden" name="image_url" value="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSh4ggvLtqBjp6ipc-tjwvkb1Cy62J8nTnhdNNCFrE-NMnU70B3">
</form>
<table id="cartTable"><h2>Cart</h2><tr id="" title-row=""><th></th><th>Products</th><th>Qty</th><th>Price</th><th>Total</th></tr><tr id="Products0"><td class="deleteRow"><span>X</span></td><td class="name">Korean / American</td><td><input type="number" class="qtyInput" id="quantity" maxlength="3" size="3" value="1"></td><td>15.88</td><td id="total" class="total">79.4000</td></tr><tr id="Products1"><td class="deleteRow"><span>X</span></td><td class="name">Batman album</td><td><input type="number" class="qtyInput" id="quantity" maxlength="3" size="3" value="1"></td><td>53.59</td><td id="total" class="total">107.1800</td></tr><tr id="Products3"><td class="deleteRow"><span>X</span></td><td class="name">Gravity Falls</td><td><input type="number" class="qtyInput" id="quantity" maxlength="3" size="3" value="1"></td><td>105.64</td><td id="total" class="total">211.2800</td></tr><tr id="total-row"><td>Total</td><td></td><td id="totalQty">9</td><td></td><td id="totalBill">397.8600</td></tr></table>
&#13;
使用从用户输入更新的动态购物车