在发送到外部URL(Paypal)之前验证表单输入

时间:2014-05-30 20:51:22

标签: php paypal

我目前正在开发一个系统,为用户提供一个"银行"平衡,用户通过paypal存入资金,并在数据库中更新,以反映他们存放的内容等。我之前用paypal按钮设置了这个,但我现在正在使用输入文本框,我想确保整个过程。这就是我目前对表格

的看法
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top' name='_xclick'>
                <!-- Identify Business -->
                <input type='hidden' name='business' value='email goes here'>

                <!-- Identify Button Type - Buy it Now Button -->
                <input type='hidden' name='cmd' value='_xclick'>

                <!-- Identify Item Details -->
                <input type='hidden' name='currency_code' value='USD'>
                <input type='hidden' name='item_name' value='Bank Deposit'>
                <input type='hidden' name='item_number' value='' id='item_number'>

                How Much Do You Want to Add
                $ <input type='text' name='bank_deposit' placeholder='Amount to deposit' id='bank_deposit' onchange='BankDeposit(this.value)'>

                <input type='hidden' name='amount' value='' id='amount'>

                <input type='hidden' name='custom' value='$user_id'>
                <input name='notify_url' value='ipn url here' type='hidden'>
                <input type='hidden' name='lc' value='US'>
                <input type='hidden' name='bn' value='PP-BuyNowBF'>
                <button type='submit' class='btn_blue' style='border-width: 0px 0px 2px 0px;'>Add To Bank</button>
            </form>

我最好在我的结尾通过php验证所有输入,然后在验证完成后将所有发布的数据安全地发送到paypal。如果有人能提供有关如何做到这一点的见解,将非常感激。

2 个答案:

答案 0 :(得分:0)

使用curl调用PayPal api并按照快速结帐工作流程进行操作。见https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECGettingStarted/

您将看到PayPal将在握手期间验证输入。验证在令牌内。如果用户尝试更改令牌将失败的任何金额

答案 1 :(得分:0)

首先,更安全的方法是收集用户输入,然后执行验证并将验证后的消息发送到付款处理程序(paypal)代码端。

但是,如果您的IPN已正确设置和引用,那么您不必担心太多,因为只有在您的侦听器收到相应的,经过验证的IPN消息时才会发生数据库更改。消息中的付款金额将是paypal报告的实际交易,并且可以信任。