0

I have two micro services built using spring boot,

One micro service is: "payment" Which handles actions related to payments.

  1. Like creating a payment link.
  2. Getting the latest status of payment and storing that information in DB (via polling). There is an UI Screen to which user redirects once payment is done and from there polling starts.
  3. Notifying latest status of payment to other micro services using kafka or any other pub sub.

Other Micro service is: "order management system" which handles actions related to orders.

  1. Creation of payment link by calling "payment" service and sends it to user via email or some other media.
  2. Also stores payment link in DB for resending Email if initial email failed.
  3. If failed Event is Received from "payment" service then "order management system" creates a new link and sends it to user.

so far everything is good.

Now there is a new requirement to show the latest payment link on the UI(where polling happens) once there is a payment failure along with sending an EMAIL.

Here are the steps When there is a payment failure.

  1. "payment" service came to know that payment is failed, so puts an event to pubsub.
  2. UI will receive in response that payment is failed. (Here we need to show the new link)
  3. As "order management system" received the payment failure event , "order management system" creates new payment link by calling "payment" service and sends email again to user.

Now the problem is , How can I show the new link to the user on the UI? If let us say UI calls "order management system" for new link , it might not have the new link because it haven't received the Event.

I cannot call "order management system" Service in payment service because, I don't want to pollute payment service with order related data.

I want UI to call "order management system" service for polling but "payment" service also sends event to pub sub which other services are interested in. So "order management system" receives updates via event as well as via rest call now there is a race condition in which some times two new payment links can be generated and last updated will be stored in DB or first which I don't want.

I don't want to stop listening to events from "payment" service because some times "payment" services polls for pending payments(either success or failure) in the system and will give notifications to "order management system" for taking appropriate actions.

How can I give new payment link to UI on a payment failure Event?

2
  • What are the reasons a payment fails, and why do you create a new link instead of reusing the existing one? If you just show outstanding payments on the UI (with either "unpaid" or "failed" status) the order management system only ever needs to create one payment per order. Sep 27 at 16:57
  • Payment Link is for one time usage , it can be used only once due to the restriction from payment gateway..
    – aravind
    Sep 28 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.