Repair payment visibility and add a payer-to-admin refund workflow
Company: Capital One
Role: Machine Learning Engineer
Category: Software Engineering Fundamentals
Difficulty: hard
Interview Round: Onsite
A payments application uses React with Vite and a Python FastAPI backend. Payers should see their own payments, merchants should see payments made to them, and admins should see all payments. A merchant currently sees payments that should be filtered out because the frontend does not send `userId` correctly to the payments API.
You may use a coding assistant, but must explain the application, investigate the defect, review changes, and verify behavior yourself.
### Clarifying Questions
- How does the backend establish the authenticated user's identity and role?
- What does posted mean for a payment, and are full or partial refund requests supported?
- Can a payer request a refund more than once, cancel a request, or retry after denial?
- Does approval initiate a real refund immediately or only record an administrative decision?
### Part 1: Repair merchant visibility
Read the application documentation, reproduce the merchant filtering defect, trace the frontend-to-API flow, and implement a correction. Verify that payer and admin visibility still work.
```hint Check both sides of the request
A correct browser parameter improves the intended request, but a caller can still change or omit it. Identify which layer must enforce ownership.
```
#### What This Part Should Cover
- Reproduction and investigation of the incorrect `userId` request
- Frontend correction and authoritative backend authorization
- Automated and manual checks for all three roles
### Part 2: Add refund requests and decisions
Allow a payer to request a refund for a posted transaction they personally made. Allow admins to approve or deny requests. Plan and implement the frontend, backend, data-model, authorization, and test changes under the clarified refund policy.
```hint Follow one request through repeated actions
Consider a double-clicked request and two administrators acting on the same pending refund.
```
#### What This Part Should Cover
- Refund state, ownership checks, and allowed transitions
- Payer request and admin decision interfaces
- Duplicate requests, concurrent decisions, and end-to-end tests
### Part 3: Prioritize further improvements
Explain what you would improve with one day to one week after completing the fix and refund workflow.
```hint Use observed weaknesses
Connect each proposed improvement to a failure observed in the payment or refund flows, and distinguish short repairs from larger changes.
```
#### What This Part Should Cover
- Priorities grounded in authorization, correctness, or maintainability
- A realistic order of work and verification for the available time
### What a Strong Answer Covers
- Consistent identity and authorization across listing and mutations
- A complete payer-to-admin workflow with visible status and failure handling
- Reviewable assistant use and verification of existing behavior
### Follow-up Questions
- How would you prevent a payer from requesting a refund for another payer's transaction by changing the payment ID?
- How would an uncertain payment-provider result affect an approved refund's status?
Overview: Repair a merchant payment-visibility defect in a React and FastAPI application, then add payer refund requests and admin decisions. Enforce backend ownership, handle duplicate and concurrent actions, and verify the full role-based workflow.
Read the full Capital One Machine Learning Engineer interview experience this question came from