BroadleafCommerce/blc-authorizenet — pull request #1 by phillipuniverse (2013-10-18 06:38:02+00:00)
Title: User can submit the same order to authorize.net twice and the Authorize.net Controller will process it twice

**BLC-authnet version:** 2.0.3-SNAPSHOT
**BLC core version:** 2.0.8-SNAPSHOT

This problem occurs when a user hits the submit button twice in quick succession. Both requests go straight to Authorize.net and Authorize.net then hits back to the Broadleaf process URL twice. In this example, the first submit was approved but the second request was (correctly denied). Authorize.net forwards the approved response to Broadleaf, but also forwards a denied request. Because of this, even though the Broadleaf controller that receives the authorize.net request had already submitted the order from the first request, the Broadleaf controller also processes the *second* request thus changing the order back to IN_PROCESS and returning the error response back to Authorize.net.

At the end of this, Authorize.net would have successfully charged the user's credit card once but the final result for the user is that they are left back on the checkout page with a message that there was a problem processing their credit card. If they they resubmit the same order (which, in this state, is a "valid" action for them to perform), their credit card will be charged a second time.

@bpolster I have attached a working copy of a fix here based on our discussion earlier. Wanted to see if I'm on the right track. This feels a bit like overkill but I think this fixes the problem of 2 requests attempting to operate on the same order as once. The desired result here is that the first Authorize.net request (in the above example) completes the order while the 2nd request (which is for the same order ID) blocks. Then, after the 1st request is finished, the 2nd request is allowed to continue, sees that the order has been submitted, and then simply returns the success response back to Authorize.net.