Step 1 - Clarifications
Is there any specific part of the payments that you would want me to design or the overall payment design from the checkout page to the screen where the payment is successful and the order is confirmed.
Interviewer - The entire flow would be nice
When we say supporting third party integrations, will we integrate with payment gateways like Stripe/Razorpay or are we integrating directly with providers like Mastercard/Visa.
Interviewer - Let's assume we will integrate with payment gateways.
That's good because that kind of renders my next question irrelevant. I wanted to ask about what are the payment modes available. Is it primarily credit and debit cards or do we also need to support geography specific mechanisms like UPI, etc.
Step 2 - Describe the product
What I want to do is describe from a UI standpoint what happens and then go behind the scenes and explain the APIs needed.
When we go to the check out page of any app and click on Pay Now, it will be taken to a gateway where the user is expected to enter the credit card details (if it is a new credit card or card payment mechanism) and then click on payment to complete the payment.
If the payment goes through an order gets created and the details are shared with the user. If the payment doesn't go through, the information is shared with the user and they are asked to repeat the transaction.
Step 3 - Describe the attributes
There are some important attributes here.
- Security
- Successful payments
- Speed of payment
Step 4 - Explain the business goals
From a business goals perspective, it is important to minimize the information to be entered by the user so that they don't always enter the credit card information, thus leading to a greater number of order completions. They also need to take care of the security aspect where the card information should never get exposed
Step 5 - Prioritize the attributes
With the business goal in mind, I will prioritize for security and speed of payments.
Step 6 - Design the APIs
For a new order, we can create a payment service that first calls the Razorpay API and pass the order number and some basic details to Razorpay, including the email of the person and the amount to be charged. Then we get taken to the razorpay screen where the details of the card or other payment details need to be entered. Once the payment is completed, the success/failure message along with the transaction ID of the transaction will be shared via the response and this can be captured in the order service. From there it is up to us whether to ask the user to repay or confirm the transaction and collect the payment on completion of the service.