I'm currently working on an e-commerce project and I need some help with my payment page. At the checkout page, I get the users' payment info which is a GSM number only, I post it to the payment system service, which returns a synchronous response. Response can be "OK", "NOT OK", "AWAIT" and "TIMEOUT". OK means payment is successful, NOT OK means payment is not successful and of course "TIMEOUT" means the payment operation is timed out.
The tricky part is "AWAIT". This service has a timeout of 4 mins. This 4 mins is used for user to complete his/her payment via his/her cell phone. The payment system works in a such different way, when I start the payment process, the service returns me "AWAIT" immediately and sends users' smart-phone a notification. This notification starts, let's call it a custom wallet, a custom wallet app. Then, user selects his/her payment card, which is pre-defined in this custom wallet system and confirms the payment. The user has a 4 min timeout period. In this 4 min either he/she completes the payment or the operation is timed out. My problem is, this payment service is a synchronous operation. So, I have to call it every 5 seconds for a 4 min period until I get a response other than "AWAIT". By this time I have to return a synchronous response to the page indicating that the payment process has begun and waiting for user confirmation and start an async operation which checks this custom wallet service for 4 mins and gets the response. And then I need to post this async response to the web page.
What I'm looking for is a way to solve this problem in order to avoid possible problems like concurrency or synchronization. I would appreciate a little sample code for this also. Thanks...
What I'm looking for is a way to solve this problemYou have described your task very well. But somehow, I failed to see exactly where the problem is. Would you mind explaining it for people with short-term memory?