且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

集成 PayPal 快速结账的更简单方法?

更新时间:2023-11-28 21:37:52

这就是我如何自动重定向到 PayPal 的所有表单详细信息;

This is how i automatically redirect to PayPal with all the form details;

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal">

 <input type="hidden" name="cmd" value="_xclick" />
  <input type="hidden" name="cbt" value="Return to example" />
 <input type="hidden" name="business" value="email" />
 <input type="hidden" name="item_name" value="example Purchase" />
 <input type="hidden" name="amount" value="9.99">
 <input type="hidden" name="button_subtype" value="services" />
 <input type="hidden" name="no_shipping" value="1">
 <input type="hidden" name="return" value="URL" />
 <input type="hidden" name="notify_url" value="URL"/>
 <input type="hidden" name="cancel_return" value="URL" />
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="image_url" value="" />
<input type="hidden" id="custom" name="custom" value="invoice_id to track"/>
 <input type="hidden" class="btn btn-primary" style="width:100%" alt="PayPal - The safer, easier way to pay online!"/>

</form>

对于多个产品,您可以简单地在表单中添加更多产品,例如;

For multiple products, you can simply add more products to the form, example;

<input type="hidden" name="item_name_1" value="Item #1">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="item_name_2" value="Item #2">
<input type="hidden" name="amount_2" value="2.00">

然而,使用这种方法并不是很好

However, using this method is not all great

所有数据都需要用PHP生成并输入到页面中,您还需要在IPN回调时检查交易以确保其已支付.

All the data would need to be generated with PHP and input into the page, you would also need to check the transaction when the IPN calls back to ensure its been paid.

<script type="text/javascript">
  function myfunc () {
     var frm = document.getElementById("paypal");
     frm.submit();
  }
  window.onload = myfunc;
</script>