Code RoomCharge logs card data
MediumPrep Room Coding #2179

Charge logs card data

Code reviewSecurityMid–Senior~15 min

Review this TypeScript payment-charge function.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 15 min
Mark a line and say what kind of problem it is.0 findings
1async function charge(req: ChargeRequest, logger: Logger) {
2 logger.info('charge request', {
3 user: req.userId,
4 card: req.cardNumber,
5 cvv: req.cvv,
6 amount: req.amount,
7 });
8 const result = await gateway.charge(req);
9 if (!result.ok) {
10 logger.error(`charge failed for ${req.cardNumber}: ${JSON.stringify(req)}`);
11 }
12 return result;
13}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.