如何在 PHP 中的页面之间安全地传递信用卡信息

发布于 2024-08-27 00:53:36 字数 189 浏览 10 评论 0原文

如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

久隐师 2024-09-03 00:53:37

好吧,首先您应该使用 HTTPS 协议来确保连接是加密的。

之后,您可以将数据存储在 $_SESSION 超全局中。数据存储在您的服务器上,因此相对安全。

您可以使用类似的技术,将信息插入订单数据库,其中密钥是 GUID 或其他相当随机且唯一的东西。然后,当该人去修改/查看他们的订单时,您应该将订单 ID 存储在 URL 的 GET 部分中(或者如果您偏执,则存储在 cookie/会话变量中):

 https://example.com/order?orderID=akjgflkhaslasdfkjhalsdjkljahs

为了提供额外的安全性,您还可以在订单表中存储 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):

 https://example.com/order?orderID=akjgflkhaslasdfkjhalsdjkljahs

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.

暗恋未遂 2024-09-03 00:53:37

一种替代方法是使用付款资料服务,例如 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.

怎会甘心 2024-09-03 00:53:37

这不是我的专业领域,但我认为您希望将其存储在会话中,同时也使用“同步令牌”(或者现在孩子们所说的任何东西)来帮助避免 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.

白鸥掠海 2024-09-03 00:53:37

我想我必须同意。存储信用卡号码的风险太大,后果可能也很牵强。

理想的方法是将信息传递给第三方处理器,然后使用返回的结果来塑造脚本逻辑。

if (transaction){
     // code goes here
}
else{
     // code goes here
}

希望你明白这一点...:)

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.

if (transaction){
     // code goes here
}
else{
     // code goes here
}

Hope you get the point ... :)

爱的十字路口 2024-09-03 00:53:36

我不会把它存放在任何地方。这风险太大,而且可能不道德。

通过 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?

零崎曲识 2024-09-03 00:53:36

不要将信用卡信息存储在会话中,不要将其存储到数据库中,不要将其存储到文件中。相反,将抄送信息写回隐藏的 html 输入中的审阅页面。

因此程序流程将如下所示:

  1. 用户通过 html 表单将付款和账单信息发布到服务器。
  2. 服务器验证此信息的格式是否正确(即,信用卡具有适当的位数、输入的帐单地址等)。
  3. 验证后,服务器写回作为隐藏表单输入字段提交的所有信息。这包括帐单地址、送货地址和信用卡信息。
  4. 审核页面上的表单(带有隐藏的输入字段)有一个标记为“完成订单”/“完成订单”的按钮。此审核表单会发布到最终确定订单脚本。
  5. 最终脚本将账单/运输信息存储在您的数据库中,并将信用卡信息提交到您的支付网关。

此方法有两个优点:

  1. 您可以节省存储信用信息时所需的额外 PCI 合规性的开销和成本。
  2. 此方法符合 SSL 协议的安全范围。这意味着,在任何情况下都必须将加密的信用卡信息提交到您的服务器 - 此方法继续仅依赖于 SSL 的功效,而不会引入持久信用卡数据的复杂性。

最后一点引起了另一个问题 - 通过查看页面,加密的信用卡数据在网络上传输的次数会增加一倍。使用此方法,至少需要 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:

  1. User posts payment and billing information to the server via an html form.
  2. Server verifies that this information is in the correct format (i.e., credit card has the appropriate number of digits, a billing address was entered, etc.)
  3. After verification the server writes back all the information submitted as hidden form input fields. This includes billing address, shipping address and credit card info.
  4. The form on the review page (with the hidden input fields) has a button labeled "Finish Order" / "Complete Order". This review form posts to the finalize order script.
  5. The finalize script stores billing/shipping info in your database and submits the credit card info to your payment gateway.

The advantages of this method are two-fold:

  1. You save the overhead and cost of additional PCI compliance that is required when storing credit info.
  2. This method stays within the security bounds of the SSL protocol. Meaning, encrypted credit card info will have to be submitted to your server in any instance - this method continues to rely solely on the efficacy of SSL, without introducing the complexities of persisting credit card data.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文