On the clientside, how do I listen for external changes on the server?

I'm certain this has been asked before so I'm ready for a torrent of downvotes, but I just can't find anything. I don't know if my problem is specific to my situation or there is a general-purpose solution.

Basic Outline

I'm setting up a payment process using Wechat QR codes on my website. The user scans the QR code and completes payment via Wechat Pay on their phone.

This means the user physically completes the process on a different platform, completely away from the website.

After completing the payment, the wechat app sends data to the given callback URL (e.g. www.mywebsite.com/Finance/PaymentFinished), where details can be taken from the request headers in the callback.

Via this callback, the server can be updated correctly, thus the payment process is completed and marked on the database.

Problem

My question is, how can I tell the website to keep a connection open and listen for that payment update?

Solution

Is there a specific way to do this, or should I just write some Javascript that repetitively calls the server (via something like www.mywebsite/com/Finance/CheckPaymentComplete?userID=1&productID=123) until it sees a change, and times out if it has to wait too long?

Thanks.

#c-sharp #ajax #asp.net

3 Likes1.45 GEEK