<aside> <img src="/icons/checklist_green.svg" alt="/icons/checklist_green.svg" width="40px" />

</aside>

Persistence Model

Table refunds {
  id                  uuid        [pk, note: 'Khóa chính của refund']
  order_id            uuid        [ref: > orders.id, note: 'Đơn hàng được refund']
  payment_id          uuid        [ref: > payments.id, note: 'Payment gốc']
  user_id             uuid        [ref: > users.id, note: 'Người yêu cầu refund']
  amount              int         [not null, note: 'Số tiền refund']
  currency            varchar     [not null, default: 'VND']
  reason              text        [note: 'Lý do refund']
  status              refund_status [default: 'requested', note: 'requested/processing/completed/failed']
  created_at          timestamp   [default: `now()`]
  updated_at          timestamp   [default: `now()`]
}
Table refund_transactions {
  refund_id           uuid       [ref: > refunds.id, note: 'Liên kết refund']
  gateway              varchar    [note: 'paypal/stripe/bank_transfer']
  provider_transaction_id varchar  [note: 'Mã giao dịch refund ở bên thứ 3']
  status               varchar    [note: 'pending/success/failed']
  response             json       [note: 'Payload callback lưu lại (nếu có)']
  processed_at         timestamp  [note: 'Thời điểm xử lý callback']
  created_at           timestamp  [default: `now()`]
  updated_at           timestamp  [default: `now()`]
}

Domain Rules

Domain Use Cases

Refund Request Command

Initiate Gateway Refund Command

Process Gateway Refund Callback Command

Initiate Manual Refund Command

Confirm Manual Refund Command

Reject Manual Refund Command

Get Refund Detail Query

Get Refunds By Users Query