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!你想要"商人sdk"库。

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