2017-07-16 74 views
1

我想发送多个产品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="[email protected]"> 
 
       <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

使用贝宝立即购买按钮,也无法通过多个项目。为了允许多个项目进入Pay​​Pal,请使用“购物车上传”按钮代码。请参阅下面的示例代码和链接如下,供大家参考:

<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/

+0

非常感谢你:) –

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); 
 
      } 
 
     }
  <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="[email protected]"> 
 
       <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>

与动态车,从用户输入更新