Backend Low Level Design 4
About Lesson

A payment microservice is a separate, independent part of a larger software system that handles all payment-related tasks. Unlike traditional applications where everything is combined into one big system, a microservice architecture breaks down the system into smaller, specialized services.

The payment microservice is responsible for processing transactions, managing payment gateways, and ensuring secure and reliable payment operations. This setup makes the system easier to maintain, scale, and integrate with different payment providers like Razorpay, PayPal, or Stripe. By having a dedicated payment microservice, businesses can quickly update and improve their payment processes without affecting the rest of the system.

To create a payment link, follow these steps

  1. Get the orderId.

  2. Call the service to create the link:

    • Retrieve order details.
    • Delegate to the payment gateway:
      • Create the request for the payment link.
      • Hit the API and get the payment link.
      • Save the following in your database:
        • orderId
        • PayId
        • PayStatus
        • PayLink

To get the payment status and update it

  1. Call the payment gateway to get the updated status.
  2. Update your database and return the payment status.

As shown in the diagram below

  1. The user request interacts with our server’s Payment Service.
  2. The Payment Service calls the Payment Gateway to generate the link.
  3. The Payment Gateway returns the payment link to the Payment Service.
  4. The Payment Service sends payment details to the Payment Gateway.
  5. The Payment Gateway redirects to the callback URL.
  6. From the callback URL, we get all required details.
  7. We call the getPaymentStatus API and update our database because all payment details are stored in the Payment Gateway database.

© GeekySanjay