繁体   English   中英

PHP-使用贝宝进行交易

[英]PHP - Use paypal to do transaction

我正在尝试使用贝宝创建一个简单的购买按钮并获取交易结果,但是我似乎找不到与该主题相关的任何东西,此外,我们是否需要企业帐户才能执行此类操作?

我在该网站IPN上看到了一些文档。 但是我不能使它工作。

有人想分享他的作品或给我提示吗?

首先,您将在贝宝的沙盒环境中工作。

<form method='post' action='https://www.sandbox.paypal.com/cgi-bin/webscr'>
  <input type='hidden' name='cmd' value='_xclick'>
  <input type='hidden' value='2' name='rm'>
  <input type='hidden'  id='content' name='item_name' value='aaa'>
  <input type='hidden' id='amount'  name='amount' value='1'>
  <input type="hidden" name="custom" value="bbb">
  <input type='hidden' name='no_note' value=''>
  <input type='hidden' name='notify_url' value=''>
  <input type='hidden' name='currency_code' value=''>
  <input type='hidden'  name='business' value='write buisness url'>
   <input type='hidden'  name='uname' value='username'>
    <input type='hidden'  name='pword' value='password'>

  <input type='hidden' name='return' value="http://localhost/paypal/return.php">
  <input type='hidden' name='cancel_return' value='http://localhost/s/paypal/cancel.php'>
  <div ><input type="image" src="<?php echo SITE; ?>images/btn_buynowCC_LG.gif" title='buy now'></div>
 </form>

您将一个按钮添加到您的网页上以接受付款。 您可以手动生成按钮,也可以使用PayPal网站为您生成按钮。

购买后,您会收到一封电子邮件,可以手动处理。

如果要以编程方式进行处理,建议您设置IPN“即时付款通知”。 PayPal将向您的网站发送HTTP POST以及订单的详细信息。 然后,您的脚本将向PayPal发送HTTP POST进行验证,然后对其进行处理。

注意:查找PayPal库非常令人困惑。 他们正在推动基于REST和JSON的新API,但这还不包括IPN! 您需要“ merchant-sdk”库。

https://github.com/paypal/merchant-sdk-php/tree/namespace-php5.3/samples/IPN

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM