Charge recorded before confirmation
Review this Python payment-charge endpoint.
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 25 min
Mark a line and say what kind of problem it is.0 findings
1@app.route('/v1/charges', methods=['POST'])
2def create_charge():
3 body = request.get_json()
4 amount = body['amount']
5 card = body['card_token']
6
7 charge = gateway.charge(card, amount) # calls external processor
8 db.charges.insert({'id': charge.id,
9 'amount': amount,
10 'status': charge.status})
11 return jsonify({'id': charge.id}), 201
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.