Craig
Craig

Reputation: 1225

Handling network outage during transaction

In a website kiosk, the user was able to add items to his cart, input all necessary information and pressed the submit button. Displayed to the user was a please wait while order is being processed.

Behind the scenes, the view passed the information to the controller, controller called business logic to card credit card .. the result was successful. Controller then called business logic to save order in database ... that result was successful. The next thing the controller was to do was send a redirect back to the view. The problem is that the user loss connectivity at that time so the web never received the redirect. When the network connection was restored (talking a few seconds), the web still showed the order, so the user resubmitted it. So now the user has a duplicate order (different id's though). How do I go about handling this issue? My guess is that this is a edge case, at least I am hoping that it is.

Upvotes: 0

Views: 86

Answers (1)

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47058

Generate a unique transaction id/order id when the form is loaded. Keep track of used transaction id:s, either in memory or in database to make sure you don't submit the same form twice.

You can also disable submit button on the client on first submit to make sure it can't be clicked twice.

Upvotes: 2

Related Questions