Day 9 Task 02 Exceptions

Task 02. Review Payment Failure Scenarios

Translate error codes like over-limit and delay into reassuring user messages, and build a lock against rapid double payments.

Task 02 Task 02 Payment Failure Scenarios Lab Guide

📥 Lab input

  • • day9_raw_payment_errors.json

💾 Lab output

  • • day9_error_mitigation_guide.md

1. Story and lab background

Right after the order payment page was released, complaints flooded customer support. One customer's card was just over its limit, but the screen suddenly showed 'Error 1042: Transaction Declined by Carrier'. Afraid the money had already left their account with nothing to show for it, they refused to pay. Also, during a network delay, a user anxiously pressed the pay button repeatedly, sending the same order approval query to the database three times in a row — a serious data defect that caused a double charge.

2. Learning goals

  • List 4 typical errors that happen during a payment transaction, like card over-limit, insufficient funds and network delay.
  • Replace raw technical codes with friendly text that removes customer anxiety and tells them what to do next.
  • Design prevention rules against double-charge attempts, like disabling the button and an idempotent order key.

3. Download the lab starter code

Copy or download the JavaScript/JSON skeleton below and save it in your local lab path (day9_raw_payment_errors.json).

json{
  "errors": [
    {
      "code": "ERR_CARD_LIMIT_EXCEEDED",
      "carrier": "PG_KCP",
      "description": "System transaction declined by external carrier due to lack of balance or limit exceeded on card"
    },
    {
      "code": "ERR_NETWORK_TIMEOUT",
      "carrier": "PG_TOSS",
      "description": "Network timeout occurred while communicating with toss payments gateway api"
    },
    {
      "code": "ERR_DUPLICATE_REQUEST",
      "carrier": "INTERNAL_GATEWAY",
      "description": "Idempotency validation failed. Multiple execution request of order id from same client detected"
    }
  ]
}

4. Codex AI Prompt Card

Copy the prompt below, paste it into the Codex Client AI chat and get guidance.

Based on the provided PG raw error log spec `day9_raw_payment_errors.json`, write a friendly \'plain-language message set for each error situation\' that never makes users anxious, and a \'double-approval prevention guideline (Mitigation Playbook)\' that blocks duplicate payment attempts.
← Previous step Next step →