When the payment system finishes a payment, it sends a "payment completed" message. Our points service receives that message and must deduct the user's balance by the points for that order. Complete PointConsumer.handlePaymentCompleted(event). The event contains orderId, userId, and points. Subtract the points you received from that user's balance. Note: the payment system promises to deliver the message "at least once." Depending on network conditions, the same message may arrive once more, late.
This challenge has you build a NestJS consumer that deducts user points from a payment-completed event. The payment system delivers the message at least once, and the same message may arrive again depending on network conditions. You complete the consumer's handling of the payment-completed event and use the in-memory store as the single source of truth for balances.
This problem is about handling where "the same message arriving again must be reflected only once." For resources where something that happened once must be applied only once β points, balances, inventory β code can look fine when the message arrives a single time, yet the real test is the moment the same message is redelivered. Verifying code like this means going beyond a single-process check: you feed the same message twice and confirm the result is reflected only once.