php - paypal 回调 php 代码中要考虑的安全性

标签 php paypal

我正在接受以下 html 的付款

<form name="myform" action = "https://www.sandbox.paypal.com/cgi-bin/webscr" method = "post">
<input type="hidden" name="cmd" value="_xclick">
<input type = "hidden" name = "business" value = "test@ssssss.com">
<input type = "hidden" name = "item_name" value = "Update Plan">
<input type = "hidden" name = "loggedin_user_id" value="<?php echo $user->id;?>">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="amount" value="4.95">
<input type="hidden" name="tax" value="0">
<input name = "rm" value = "2" type = "hidden">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="custom" id="custom" value="{{ user_id }}">
<input type="hidden" name="currency_code" value="USD">
<input type = "hidden" name = "cancel_return" value = "http://website.com/">
<input type = "hidden" name = "return" value = "<?php echo $this->config->base_url();?>pay">
<input name = "cbt" value = "Return to My Site" type = "hidden">
<button type="submit" class="btn btn-large btn-success">Upgrdate Now</button>
</form>

在 php 中,我只是将 user_role 更新为 1,这意味着用户已付款。

它足够安全吗?有人可以只发布到我的返回 URL 并破解我的支付系统吗?我应该在我的 php 代码中添加什么安全措施?

if(isset($_POST['loggedin_user_id']))
        {
            $this->user_model->set_user_attribute($_POST['loggedin_user_id'],'user_role',1);

        }

最佳答案

不要假设用户仅仅因为访问了您的返回 URL 就完成了购买。用户可以从您的表单中读取返回 URL 并手动访问它。此外,在某些情况下,PayPal 可能会保留付款以进行验证;用户将被发送到返回 URL,但付款尚未完成。

要确定是否发生了购买,请实现 PayPal Instant Payment Notification您网站上的端点。

关于php - paypal 回调 php 代码中要考虑的安全性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43824147/

相关文章:

php - 从数组中删除重复项,然后删除空值,然后重组

PHP 验证 ISO 8601 日期字符串

php - 直接从 jQuery 插件发出 Ajax 请求是不好的做法吗?

php - 如何连接到其他服务器

php - PayPal 沙箱不同于实时模式

php - PayPal 自动返回不会发回任何 POST 数据

javascript - 如何在 Jquery Ajax 中使用 Json 数据

asp.net - PayPalAPI 端点

php - 从没有主键的 MySQL 表中获取随机行 - 优化

jquery - Paypal Jquery 移动集成