如何在 PHP 中的页面之间安全地传递信用卡信息
如何在 PHP 中的页面之间安全地传递信用卡信息?我正在构建一个电子商务应用程序,我希望用户能够像这样进行结帐:
输入信息 ->回顾->完成订单
问题是,我不确定如何安全地传递信用信息,从用户输入信用信息到我处理信用信息(在完成订单步骤)。我听说即使使用加密,使用会话也是不安全的。
任何帮助将不胜感激!
How do you securely pass credit card information between pages in PHP? I am building an ecommerce application and I would like to have the users to go through the checkout like this:
Enter Information -> Review -> Finalize Order
Problem is that I am not sure on how to safely pass credit information from when the user inputs them to when I process it (at the Finalize Order step). I heard using sessions is insecure, even with encryption.
Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
好吧,首先您应该使用 HTTPS 协议来确保连接是加密的。
之后,您可以将数据存储在
$_SESSION
超全局中。数据存储在您的服务器上,因此相对安全。您可以使用类似的技术,将信息插入订单数据库,其中密钥是 GUID 或其他相当随机且唯一的东西。然后,当该人去修改/查看他们的订单时,您应该将订单 ID 存储在 URL 的 GET 部分中(或者如果您偏执,则存储在 cookie/会话变量中):
为了提供额外的安全性,您还可以在订单表中存储 IP 地址,并确保 IP 和订单 ID 匹配。
Well, first you should be using the HTTPS protocol to ensure that the connection is encrypted.
After that, you could store the data in the
$_SESSION
super-global. The data is stored on your servers, so it is relatively safe.You could do a similar technique where you insert the information into an Order database, where the key is a GUID or something else fairly random and unique. Then, when the person goes to modify/review their order, you should have the Order ID stored in the GET part of the URL (or if you're paranoid, a cookie/session variable):
To provide extra security, you could also store an IP Address in the Order Table, and make sure the IP and the Order ID match.
一种替代方法是使用付款资料服务,例如 Authorize.net 的客户信息管理器(还有其他的)。您可以通过 API 将付款信息存储在配置文件中,然后在实际向卡收费时使用配置文件 ID。这样您就永远不会将数据存储在服务器上。
One alternative is to use a payment profile service like Authorize.net's Customer Information Manager (there are others too). You store the payment info in a profile via their API, then use the profile ID when actually charging the card. This way you're never storing the data on your servers.
这不是我的专业领域,但我认为您希望将其存储在会话中,同时也使用“同步令牌”(或者现在孩子们所说的任何东西)来帮助避免 CSRF 攻击。
当然,您希望(正确地)使用 https,避免 URL 和隐藏字段中的敏感数据,避免在任何响应中放入非常敏感的信息,等等。
Not my area of expertise, but I think you want to store it in a session but also use a "synchro token" (or whatever the kids are calling it these days) to help avoid CSRF attacks.
Of course, you want to be using https (correctly), avoiding sensitive data in the URL and hidden fields, avoiding putting very sensitive information in any response at all, etc., etc.
我想我必须同意。存储信用卡号码的风险太大,后果可能也很牵强。
理想的方法是将信息传递给第三方处理器,然后使用返回的结果来塑造脚本逻辑。
希望你明白这一点...:)
I think I will have to agree. Storing creditcard numbers is too big a risk and the consequences could be far fetched.
The ideal way would be to pass the information to a third party processor and just use the result returned to mould your script logic.
Hope you get the point ... :)
我不会把它存放在任何地方。这风险太大,而且可能不道德。
通过 https 发布表单向支付网关发送请求,并仅存储交易结果。
您可能只关心交易是否被批准或拒绝。谁在乎号码是多少?
I wouldn't store it anywhere. It's too much of a risk and probably not ethical.
Send a request to the payment gateway by posting a form over https and store the result of the transaction only.
You probably only care if the transaction was approved or declined. Who cares what the number is?
不要将信用卡信息存储在会话中,不要将其存储到数据库中,不要将其存储到文件中。相反,将抄送信息写回隐藏的 html 输入中的审阅页面。
因此程序流程将如下所示:
此方法有两个优点:
最后一点引起了另一个问题 - 通过查看页面,加密的信用卡数据在网络上传输的次数会增加一倍。使用此方法,至少需要 4 次传输:客户端到服务器、服务器到客户端、客户端到服务器(再次)然后服务器到网关。未经审查,至少有 2 次传输:客户端到服务器和服务器到网关。评论页面的便利值得冒额外传输的风险吗?这是您作为网络开发人员(和您的客户)需要做出的决定。
Don't store the credit card info in the session, don't store it to a database, don't store it to a file. Instead, write the cc info back to the review page in a hidden html inputs.
So the program flow would work like this:
The advantages of this method are two-fold:
This last point raises another concern - by having a review page you're doubling the number of times the encrypted credit card data is being transmitted across the network. With this method there are 4 transmissions minimum: client to server, server to client, client to server (again) then server to gateway. Without review there are 2 transmissions minimum: client to server and server to gateway. Is the convenience of a review page worth the risk of extra transmissions? That's a decision you as a web developer (and your client) get to make.