使用 Paypal 锁定模型车

发布于 2024-10-27 06:03:17 字数 499 浏览 1 评论 0原文

我目前正在 Zend 框架应用程序中实现 Paypal Express Checkout,我编写了自己的购物车模型,其中包含两个简单的类 Cart & 。 CartItem,他们能够查询数量,获取总价等。

我对支付系统不太了解,我只使用 Paypal(这是我第一次),但我虽然因为我无法控制什么碰巧在那里(在 Paypal),最好在流程开始时(重定向到 Paypal 时)“锁定”购物车,以避免 Paypal 处理的当前订单与网站上的实际购物车不一致。

例如,如果用户在使用 PayPal 进行付款时打开一个新选项卡并尝试添加产品,则可能会发生这种情况。

如果您的购物车被锁定,则用户无法在购物车中添加或删除任何东西,直到他完成通过 PayPal 处理付款或取消订单。

我的问题是你认为这是一个好方法吗?

编辑:我不在数据库中存储任何内容,而只在会话中存储购物车的原因是所有订单都通过 Paypal 存储,所以我不想存储两次,这真的是一个问题。非常简单的系统。

I'm currently implementing Paypal Express Checkout within a Zend Framework Application, I wrote my own cart model which consist of two simple class Cart & CartItem, and they are able to se quantity, get total price, etc.

I'm not much aware on payment system, and I only use Paypal (it's my first time), but I though since I'm not able to control what's happing there (at Paypal) it is a good idea to "lock" the Cart at the beginning of the process (when redirecting to Paypal) to avoid inconsistencies over the current Order processed by paypal and the actual cart on the website.

It can happen for example if the user open a new tab and try to add products while he is a payment process with paypal.

If your cart is locked the use is not able to add or remove anything from its cart until he finished to process the payment thorough paypal or cancel its order.

My question is do you think it is a good approach?

Edit: The reason I don't store anything in the database but only the shopping cart in session is all order are stored with Paypal, so I don't want to store it twice, it is a really really simple system.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

剩一世无双 2024-11-03 06:03:17

我用不同的方式做到了。

当用户浏览网站时,购物车将使用会话、cookie 或其他方式存储。

一旦他点击“付款”按钮,购物车的内容就会进入具有唯一 ID 的 orders 数据表。
您删除会话或 cookie 以防止他向订单添加新内容。
您使用唯一的 ID 将其提供给 PayPal。付款完成后,Paypal 会向您返回 IPN,并返回给您唯一的 ID。由此您知道它已付款,并且可以在您的 orders 表中放入布尔值或其他内容。

有时用户不会付款,您就会有一些从未付款的订单。您应该有一个 cron 来检查超过一天的订单并将其从表中删除。

I've done it a different way.

When the user browses the site, the cart is stored using a session, a cookie or whatever.

Once he clicks the "pay" button, the content of the cart goes to a orders datable table with a unique ID.
You delete the session or the cookie to prevent him to add new stuff to the order.
You use the unique ID to give it to paypal. Once the payment is done, Paypal comes back to you with IPN, and gives you back the unique ID. From that you know it's paid and can put a boolean or something in your orders table.

Sometimes the user won't pay, and you'll have some never paid orders. You should have a cron that check orders older than one day and remove them from the table.

空袭的梦i 2024-11-03 06:03:17

我认为你的方法很好。但请确保告知用户为什么他们无法将商品添加到购物车,并提供解锁购物车的简单选项。

用例:

  • 填写购物车
  • 开始付款
  • 啊,我忘记了袜子
  • 关闭付款选项卡
  • 在其他选项卡中打开的商店
  • 添加袜子
  • “您无法添加,它已锁定”
  • 我无法返回付款以取消它并且无法添加任何内容购物车=>我离开

I think your approach is fine. But make sure you inform the users why they can't add items to cart and offer an easy option to unlock the cart.

Use case:

  • fill cart
  • start payment
  • ah, I forgot the socks
  • close payment tab
  • shop opened in other tab
  • add socks
  • "you can't add, it's locked"
  • I can't return to payment to cancel it and can't add anything to cart => i leave
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文