2016-05-14 118 views
0

我正在尝试使用PayPal创建一个简单的购买按钮并获取交易结果,但我似乎无法找到与该主题相关的任何内容,还有,我们是否需要商业账户做这种事情?PHP - 使用PayPal做交易

我在那里看到一些文档网站:IPN。但我无法让它工作。

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

回答

1

首先,你将在贝宝的沙箱环境工作..

<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> 
0

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

如果进行了购买,您将收到一封电子邮件,您可以手动处理。

如果您想以编程方式处理它,我建议设置IPN“即时付款通知”。 PayPal会发送一个HTTP POST到您的网站并提供订单的详细信息。然后您的脚本将发送一个HTTP POST到PayPal来验证并处理它。

注意:找到贝宝库非常混乱。他们正在推出新的基于REST和JSON的API,但不包括IPN!你想要“商人sdk”库。

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