PHP - 使用paypal进行交易
PHP - Use paypal to do transaction
我正在尝试使用 paypal 创建一个简单的购买按钮并获取交易结果,但我似乎找不到与该主题相关的任何内容,另外,我们是否需要企业帐户才能执行此操作什么样的东西?
我在该网站上看到了一些文档:IPN。但是我做不到。
有人愿意分享他的作品或给我提示吗?
首先你将在paypal的沙箱环境中工作..
<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 "Instant Payment Notification"。 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
我正在尝试使用 paypal 创建一个简单的购买按钮并获取交易结果,但我似乎找不到与该主题相关的任何内容,另外,我们是否需要企业帐户才能执行此操作什么样的东西?
我在该网站上看到了一些文档:IPN。但是我做不到。
有人愿意分享他的作品或给我提示吗?
首先你将在paypal的沙箱环境中工作..
<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 "Instant Payment Notification"。 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