digraph G {
  rankdir=LR;
  node [shape=box, style="filled,rounded", penwidth=2, fontsize=12, fontname="Arial"];
  edge [penwidth=1.5, fontsize=10, fontname="Arial"];
  "[*]" [shape=circle, label="", width=0.2, fillcolor=black, style=filled];
  "pending" [fillcolor="#e7f3ff", fontcolor="#0056b3", color="#0056b3", fontsize=12];
  "doublepay-refunded" [fillcolor="#e7f3ff", fontcolor="#0056b3", color="#0056b3", fontsize=12];
  "latepay-refunded" [fillcolor="#e7f3ff", fontcolor="#0056b3", color="#0056b3", fontsize=12];
  "received" [fillcolor="#cce5ff", fontcolor="#004085", color="#004085", fontsize=12];
  "expired" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "cancelled" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "confirmed" [fillcolor="#d4edda", fontcolor="#155724", color="#155724", fontsize=12];
  "confirmed-complete" [fillcolor="#d4edda", fontcolor="#155724", color="#155724", fontsize=12];
  "confirmed-overpay" [fillcolor="#cce5ff", fontcolor="#004085", color="#004085", fontsize=12];
  "underpaid-refunded" [fillcolor="#fff3cd", fontcolor="#856404", color="#856404", fontsize=12];
  "out-of-stock-refunded" [fillcolor="#fff3cd", fontcolor="#856404", color="#856404", fontsize=12];
  "confirmed-overpay-refunded" [fillcolor="#fff3cd", fontcolor="#856404", color="#856404", fontsize=12];
  "confirmed-overpay-refunded-complete" [fillcolor="#d4edda", fontcolor="#155724", color="#155724", fontsize=12];
  "confirmed-overpay-not-refunded" [fillcolor="#d4edda", fontcolor="#155724", color="#155724", fontsize=12];
  "latepay-refunded-complete" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "latepay-not-refunded" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "underpaid-refunded-complete" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "underpaid-not-refunded" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "out-of-stock-refunded-complete" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "out-of-stock-not-refunded" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "doublepay-refunded-complete" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "doublepay-not-refunded" [fillcolor="#f8d7da", fontcolor="#721c24", color="#721c24", fontsize=12];
  "terminated" [shape=doubleoctagon, fillcolor="#e0e0e0", fontcolor="#333333", color="#333333", fontsize=12];
  "[*]" -> "pending";
  "[*]" -> "doublepay-refunded" [label="Duplicate payment detected"];
  "[*]" -> "latepay-refunded" [label="Late payment detected"];
  "pending" -> "received" [label="Payment detected in mempool"];
  "pending" -> "expired" [label="Payment timeout (never received)"];
  "pending" -> "cancelled" [label="User cancellation"];
  "received" -> "confirmed" [label="Sufficient payment + confirmations"];
  "received" -> "confirmed-overpay" [label="Overpayment detected"];
  "received" -> "underpaid-refunded" [label="Underpayment detected"];
  "received" -> "out-of-stock-refunded" [label="Product unavailable"];
  "confirmed" -> "confirmed-complete" [label="Swept to cold storage"];
  "confirmed-complete" -> "terminated" [label="✓ Terminal Success"];
  "confirmed-overpay" -> "confirmed-overpay-refunded" [label="Initiate refund"];
  "confirmed-overpay-refunded" -> "confirmed-overpay-refunded-complete" [label="Refund confirmed"];
  "confirmed-overpay-refunded" -> "confirmed-overpay-not-refunded" [label="No refund wallet configured"];
  "confirmed-overpay-refunded-complete" -> "terminated" [label="✓ Terminal Success"];
  "confirmed-overpay-not-refunded" -> "terminated" [label="✓ Terminal Success (Not Refunded)"];
  "expired" -> "terminated" [label="✓ Terminal Failed (Expired)"];
  "latepay-refunded" -> "latepay-refunded-complete" [label="Refund confirmed"];
  "latepay-refunded" -> "latepay-not-refunded" [label="No refund wallet configured"];
  "latepay-refunded-complete" -> "terminated" [label="✓ Terminal Failed (Refund Complete)"];
  "latepay-not-refunded" -> "terminated" [label="✓ Terminal Failed (Not Refunded)"];
  "underpaid-refunded" -> "underpaid-refunded-complete" [label="Refund confirmed"];
  "underpaid-refunded" -> "underpaid-not-refunded" [label="No refund wallet configured"];
  "underpaid-refunded-complete" -> "terminated" [label="✓ Terminal Failed (Refund Complete)"];
  "underpaid-not-refunded" -> "terminated" [label="✓ Terminal Failed (Not Refunded)"];
  "out-of-stock-refunded" -> "out-of-stock-refunded-complete" [label="Refund confirmed"];
  "out-of-stock-refunded" -> "out-of-stock-not-refunded" [label="No refund wallet configured"];
  "out-of-stock-refunded-complete" -> "terminated" [label="✓ Terminal Failed (Refund Complete)"];
  "out-of-stock-not-refunded" -> "terminated" [label="✓ Terminal Failed (Not Refunded)"];
  "doublepay-refunded" -> "doublepay-refunded-complete" [label="Refund confirmed"];
  "doublepay-refunded" -> "doublepay-not-refunded" [label="No refund wallet configured"];
  "doublepay-refunded-complete" -> "terminated" [label="✓ Terminal Failed (Refund Complete)"];
  "doublepay-not-refunded" -> "terminated" [label="✓ Terminal Failed (Not Refunded)"];
  "cancelled" -> "terminated" [label="✓ Terminal Failed (Cancelled)"];
}
