Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Burano's avatar

How to deal with shopping cart processing?

So I'm planning on using this package; https://github.com/bumbummen99/LaravelShoppingcart in combination with OmniPay and in general it seems pretty straight forward to integrate them together.

Generally speaking I was thinking of doing something like this;

  • User has a cart session tied to the UUID in the database.
  • They add an item to their cart.
  • They head to checkout.
  • We retrieve their cart based on their UUID.
  • Fetch cart items from cart and do OmniPay stuff.
  • Process Payment.
  • Log some type of transaction or order Model.
  • Deliver Digital Product.
  • Mark as delivered.

However, one concern I've had which I'm not sure how to deal with is that what if the user pays with a payment method that has a delay like a bank transfer for example? The Webhook could be delayed by up to 7-14 days.

So for example, say a user purchases "Product 1" and pays via Bank Transfer and it has a delay of 7 days. On day 4 he decides to buy something else so he comes back to the site, and adds some different items to his cart but then decides he actually would rather wait for "Product 1" to be delivered. However, he leaves "New Product" in his cart.

Now once "Product 1" is processed it instead is going to deliver "New Product" instead of "Product 1".

So what would be the best way of handling this? Should I make a new session for every cart and link that to the payment? That seems like a very messy and unorganised way to do it.

Instead would I be better off logging the product they purchased on some type of transaction/order model and then using that instead to process the payment?

Not really sure what I'm doing here in all honesty since this is the first checkout I've worked on. Hopefully someone can provide some good advice and pointers.

Any help appreciated!

Just as a note: I'm commited to OmniPay. Laravel Cashier looks great but it just really doesn't fit the project I'm working on at the moment so I'm not looking to swap any time soon. :)

0 likes
3 replies
alanholmes's avatar

Hi @burano

Not used the pacakge above, but I work for an eCommerce company (and have done eCommerce before here), and this is the general process that we use:

  • User adds an item to their basket
  • this creates a session with that product in the basket
  • They can add other products if they wish
  • They proceed to through the checkout, and the basket is saved as an order (with the product details at the time of purchase - eg the price at that point)
  • The payment is processed through the payment gateway.
  • Successful payments get updated as such, and things like bank transfer get marked as Pending Payment
  • At this point we clear the basket from the session

So, should the user start a new order either straight away or after a few days, it is treat as that, a new order.

And each order, is a snapshot of the details of that time (customer details, product details, etc), but they are still liked by having the IDs, but this means that should any details change for the product/customer, it doesnt effect previous orders.

So going back to your question, yes I would certainly start a new basket session for each order (unless you are also adding functionality to amend orders, in that case you would need to resume a previous basket session)

anilkumarthakur60's avatar

while migrating the data base it says the error

 SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`identifier` varchar(255) not null, `instance` varchar(255) not null, `content` longtext not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

i am using the package called

https://packagist.org/packages/bumbummen99/shoppingcart
martinbean's avatar

@burano It’s clear that there are more “states” in your checkout flow than you’ve accounted for, and need to accommodate these in your code.

Your cart seems to go through this simplified workflow:

  • Add product to cart
  • Check out via payment gateway
  • Payment submitted
  • Payment resolved
  • Order fulfilled

So you would create an order when a payment is captured. If it’s a card payment then the payment will resolve almost immediate, and you can move the order to fulfilled (and digitally-deliver the product). If they pay using a method like bank transfer that takes a while to resolve, then you need to put the order in a state of, “The customer’s sent the payment, but we’ve not received it yet”. Only when you receive the payment do you move the order to the “fulfilled” state and digitally-fulfil the product.

Also, once an order’s been placed, it should not be editable. It’s been placed, and a payment’s been captured and the cart’s been cleared. If the customer wishes to purchase additional items, then they’ll need to do so via a new checkout session.

Please or to participate in this conversation.