Prevent Transaction to happen twice if a button clicked at the same time

I’m currently facing an issue with the shared cart functionality in our online shop and could use some guidance.

The problem arises when two users click on the “Pay” button simultaneously (same second) I want to ensure that only one transaction is processed, and the second user receives an error message, preventing any double transactions.

I attempted to address this by creating a database entry. The idea was that once a user clicks the “Pay” button, the system would register the transaction, preventing another user from initiating a payment. However, this approach doesn’t seem to be working as expected.

I’m reaching out to seek your input and expertise on resolving this issue. Do you have any suggestions or alternative solutions to ensure a seamless and error-free checkout process for our users?

Hey @mo13
Ideally recording a transaction record with timestamp constrain should help you disable the button. If that’s not working try handling the payment flow via backend workflows? where you only schedule it if condition is satisfied.


I would set a custom state yes/no with initial value no. When clicking the button change the value to yes. Then set a condition i.e. when state is yes, this button is not clickable.

States are faster then creating a database entry and doesn’tcost you WU.

thank you. can you elaborate more. Unfortunately I can handle the payment flow over the backend flow.

thank you. I did the exact same thing but with database and it do no work why should it work with custom states.

Additionally its shared cart so it has to be done over the database or not?

Do a search for race conditions on Bubble. It’s been a while since I’ve read on the topic but I as far as I know there’s no reliable solution to this using Bubble’s database.

This topic was automatically closed after 70 days. New replies are no longer allowed.