将PayPal Sandbox集成到Web应用程序中

时间:2014-11-02 15:21:39

标签: paypal integration paypal-sandbox

我有一个Web应用程序,我想将PayPal Sandbox集成到它。 这样做的步骤是什么?

1 个答案:

答案 0 :(得分:2)

由于PayPal的集成指南对初学者来说可能不太清楚,而其他在线教程对于简单的结帐实施来说可能太长,因此本Q& A旨在快速,轻松地将PayPal Sandbox集成到您的Web应用程序中。 无需外部库或其他下载。

第1步:创建PayPal沙盒帐户。关注this guide以创建测试帐户。

第2步:在以下示例HTML代码中复制基本的 立即购买 按钮(仅限单项付款):

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="payments@yourbusiness.com">

<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">

<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Your Product">
<input type="hidden" name="amount" value="25.00">
<input type="hidden" name="currency_code" value="USD">

<!-- Specify checkout options. -->
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.yoursite.com/paymentsuccessful.hmtl">
<input type="hidden" name="cancel_return" value="http://www.yoursite.com/paymentcancelled.hmtl">

<!-- Display the payment button. -->
<input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">
</form>
  • 表单操作 - 值为https://www.sandbox.paypal.com/cgi-bin/webscr,删除“沙盒” 表示您使用的是实时PayPal网站

  • 商家 - 不一定是真实的电子邮件,显示在PayPal结帐页面左上角的文字

  • cmd - _xclick表示点击的按钮是“立即购买”按钮

  • item_name - 您商品的名称

  • 金额 - 产品价格

  • currency_code - 阅读here了解支持的值

  • no_note - 不要提示买家在付款时附上说明(0 - false,1 - true)

  • no_shipping - 不要提示买家提供送货地址(0 - 提示但不要求,1 - 不提示,2 - 提示并要求)

  • 返回 - PayPal在完成付款后重定向买方浏览器的网址

  • cancel_return - 如果PayPal在完成付款前取消结帐,会重定向买方浏览器的网址

<强>输出:
enter image description here

<强>参考文献:
Testing Classic API Calls(推荐阅读)
Single-Item Payments – Buy Now Buttons(提供更多选项)
HTML Variables for Displaying PayPal Checkout Pages(提供更多选项)