My current setup: I have a Stripe webhook that listens for checkout success events. After payment success, my koa.js server will fire off a async task that does more processing and immediately returns status 200 to Stripe. Stripe would redirect the user to the /payment_success endpoint.
Here's what I want to achieve: Once the async task finishes, I would like to notify the user (who should be waiting on /payment_success) about the status of this task.
Here's how I plan on implementing this:
- In the /success handler on the server, I would create a redis subscriber that listens for a task completion event using redis streams. The topic would be based on the customer id. Once this event happens, I would send a Server Sent Event to the client.
- The async task would publish the task completion event to redis streams once it finishes.
My questions are:
- How would you design the system to satisfy the requirements?
- Is there anything you would change about my design?