Skip to content

7.2 — Trigger Refund #30462

Closed
1 of 1 issue completed
Closed

Description

@mbertucci

Priority (MoSCoW): Must
Persona: Registry Analyst (staff-facing outcome only)
Value: Ensure the filer’s fee is refunded automatically when a filing request is rejected, so analysts don’t need to handle refunds manually and filers are reimbursed promptly.


User Story

As a registry analyst, I want the system to automatically initiate a refund when I reject a filing request, so that the filer is reimbursed quickly and I don’t need to perform manual refund steps.

Context

  • Where: Triggered by Reject action (Epic 6).
  • Before: Filing request set to Rejected and preserved as historical record (Epic 6). Payment reference already captured at intake.
  • After: Refund call sent to payment service; refund reference/amount stored; staff-facing outcome available.
  • Policy fit (BA to confirm):
    • Manufactured Home Act — s. 10(1): Registrar must refuse incomplete/non-compliant records.
      How this story meets it: Refund initiated upon rejection to reverse payment for a filing that cannot be accepted.

UX/UI Link (Design-owned)

_does not need design - need for 7.3


MVP Boundary (story-level; PO-owned)

  • In:
    • System calls payment service to initiate full refund to original payment method.
    • Store refund reference/ID, amount, and timestamp in audit log.
    • Display basic staff-facing confirmation of refund initiation.
  • Out:
    • No partial refunds, split tenders, retries, or cheque handling.
    • No chargeback management.
    • No advanced staff dashboards (basic confirmation only).

Acceptance Criteria (PO-owned; user-observable)

  • On Reject (Epic 6), the system initiates a refund automatically.
  • Refund is sent to the original payment method (as captured at intake).
  • Refund reference/ID, amount, and timestamp are stored in the audit log.
  • Staff can see a confirmation that refund was initiated.
  • If refund fails, staff see a simple error/flag instructing manual follow-up (retry is Post-MVP).
  • Accessibility: Refund confirmation and error flags are accessible (keyboard, focus, AT).

BA Section (Required before Dev)

BA — please cover

  • Business & validation rules: What triggers refund (Reject only? any edge cases)?
    • A duplicate or overpayment occurred.
    • A technical error prevented payment processing.
    • A technical error prevented service delivery.
  • Error wording for refund failures.
    "A refund could not be processed at this time. Please verify payment details and retry. Contact support if the issue persists.”
  • Unavailable wording: Plain-language message if payment service is down.
    “Payment could not be processed due to a temporary service outage. Please retry later or contact support if the issue continues.”
  • Authoritative source: Confirm refund reference/amount comes from Payment Service.
  • Constraints/NFRs: Expected response time, audit retention.
  • Visibility rules: Who can see refund outcome (staff vs filer)?
  • Policy references (MHA/FOIPPA) confirmed.

Business and Validation Rules

Business Rules

  • Refund trigger: On save of a valid rejection, initiate a refund to the original payment method. Store refund ID, amount, and timestamp. Show staff confirmation.
  • No payment on rejected filings: Rejected filings must not be charged. If captured earlier, issue a refund.
  • Repository and notice independence: The rejection notice and filing snapshot remain preserved regardless of refund or delivery outcomes. Email failure must not block download.
  • Duplicate or overpayment handling
    If duplicate captures exist, issue one refund per captured payment and prevent duplicates using idempotency.
    If overpayment occurred, refund the overage. The total refund must not exceed the total paid.
  • Technical error during payment processing: If refund initiation fails or times out, keep the rejection saved, flag the refund for follow up, and do not auto‑retry (MVP).
  • Technical error during service delivery: If email fails, keep the notice downloadable, log the failure with timestamps, and provide a resend action after address correction.
  • Audit and traceability: Record all refund and delivery events with timestamps, references, and filing ID.
  • Staff visibility: Show staff a concise success or failure banner for refund initiation with clear next steps.

Validation Rules

A) Preconditions and state

  • Filing must be In Review at save time; otherwise block with a conflict message.
  • A valid coded reason must be present; otherwise block save.
    B) Payment artifacts
  • A payment reference is required when a refund is needed; otherwise block refund and flag for staff.
  • Validate refund amount equals captured amount net of overpayment and never exceeds total paid.
    C) Idempotency and duplicates
  • Send refund requests with an idempotency key. If a prior refund exists, record the original refund ID and stop further refunds.
    D) Error control on payment processing
  • On error or timeout, record failure, do not mark refund complete, and surface a follow‑up flag. No automatic retry in MVP.
    E) DRS storage before delivery
  • Store the rejection notice in the repository before any delivery attempt. If storage fails, do not start delivery; show retry.
    F) Delivery validation
  • Validate email format before send; if invalid, block email and keep notice downloadable. Log attempts and failures.

Edge Cases

• Duplicate payment captures due to gateway retry: issue exactly one refund per capture; prevent duplicates via idempotency.
• Overpayment at intake: refund overage on rejection and cap at total paid.
• Payment service outage or timeout: rejection remains saved; refund flagged for follow up; no silent retry in MVP.
• Repository write failure: notice not sent; show retry; rejection status remains saved.
• Email failure with successful storage: download available; failure logged; present resend action.
• Network timeout after refund call: reconcile later; if refund exists, record refund ID and stop retries.
• Double‑click on Reject: idempotency prevents duplicate refunds and notices.
• Payment pending after approval: no rejection‑driven refund in this state.

Policy references

  • Manufactured Home Act — s. 10(1): Registrar must refuse incomplete/non-compliant filings (refund ensures filer isn’t charged). Link
  • Manufactured Home Acts - s. 34: The registrar must give an applicant a notice of refusal whenever the registrar refuses to file a submitted record. The notice must briefly explain the reason for the refusal and list any additional requirements the registrar needs. Link
  • FOIPPA — The registrar collects only the personal information required for program operations, protects it with reasonable security, and limits collection, use, and disclosure to what is necessary, which supports using a refund reference number instead of full payment card or PAD dataLink

BA — Edge cases

Edge case What triggers it What the user sees Can they continue?
Payment service unavailable Refund call error or timeout Refund pending, no response, follow up required Yes, refund pending
Refund partially processed Gateway returns less than expected Refund mismatch, reconciliation required Yes, finance review
No payment reference found Missing or invalid payment reference Refund cannot start, add reference and retry Yes, refund blocked
Duplicate refund attempt Double click or retry without idempotency Duplicate refund prevented, existing reference recorded Yes, no new refund
Overpayment detected Paid amount exceeds fee Overpayment, overage will be refunded Yes, overage only
Payment method invalid Original card or account closed Refund failed to settle, manual follow up Yes, manual refund
Timeout after refund call Status unknown after send Refund status unknown, system will reconcile, do not retry Yes, reconcile
Conflicting payment state Payment pending from prior flow Refund not applicable, resolve payment first Yes, then refund
Partial repository outage Storage ok, linkage failed Notice stored, some references unavailable, will retry Yes, proceed

BA — Acceptance Criteria (Gherkin)

Scenario: Refund initiated after a valid rejection
Given a paid filing is In Review
And a valid rejection reason is selected
When the analyst saves the rejection
Then the system initiates a refund to the original payment method
And stores the refund ID, amount, and timestamp
And shows a confirmation to staff

Scenario: Duplicate captures for the same filing
Given two payment captures exist for the filing
When the filing is rejected
Then the system issues exactly one refund per captured payment
And idempotency prevents duplicate refunds on retry

Scenario: Overpayment at intake
Given the total paid exceeds the fee
When the filing is rejected
Then the system refunds the overage
And the refund does not exceed the total paid

Scenario: Refund call fails or times out
Given a refund is required on rejection
When the payment service returns an error or times out
Then the rejection remains saved
And the refund is flagged for staff follow up
And no automatic retry is queued

Scenario: Email delivery fails after storage
Given the rejection notice is stored in the repository
When email delivery fails
Then the notice remains available for download
And the failure is logged with timestamp
And staff see a resend action after address correction

Scenario: Repository write fails
Given an analyst records a rejection
When the system cannot store the notice in the repository
Then delivery does not start
And staff see a retry prompt

Constraints

Refund on rejection:
Refund triggers only after a valid rejection is saved.
Original payment method must be used for refund.
A payment reference must exist to start a refund.
Refund amount must not exceed total paid for the filing.
Overpayment must refund only the overage.
Duplicate captures must result in one refund per capture, no duplicates.
An idempotency key must be used for every refund request.
Refund state must be persisted with a single source of truth.

Payment errors
If the payment service is unavailable or times out, the rejection stands.
Refund status must be set to Pending when no response is received.
No automatic retries are performed in MVP.
Manual follow up must be flagged when the refund call fails.
A prior successful refund must block any further refund attempts.

Service delivery errors
The rejection notice must be stored before any delivery attempt.
If storage fails, no delivery must occur.
If email fails, the notice must remain available for download.
Invalid email addresses must block sending until corrected.
Duplicate delivery must be blocked unless explicitly requested again.

Records and integrity
A point‑in‑time snapshot of the filing must be preserved at decision time.
Refund ID, amount, and timestamp must be recorded with the filing ID.
Delivery outcomes must be recorded with timestamps and correlation IDs.
Internal notes must not appear on applicant‑facing notices.

Security and access
Only authorized staff may trigger or resend notices and refunds.
Repository documents must not be publicly addressable.

Communication content
Filer‑facing notice must include clear rejection reasons and resubmission steps.
Refund communication must report refund status without exposing internal notes.


BA notes

  • The refund must be marked as Pending when the payment service fails to respond. For the MVP, Pending status must be used with a manual follow‑up flag, and no automatic retries must occur. A refund attempt must be queued only when reliable asynchronous retries and idempotency are supported. Repeated submissions must produce a single refund result, enforced through an idempotency key.

  • On rejection, call payment service once: If the service responds with success, record refund ID, amount, and timestamp, and show a success confirmation to staff.
    If the service does not respond in time
    Persist the rejection and notice as normal. Do not block the decision.
    Set Refund Status = Pending and display a visible follow‑up flag for staff.

  • MVP does not queue silent retries.

Refund Alerts and Messages

Success: “Refund initiated. Reference: {INSERT ID}. Time: {INSERT TS}.”
Pending (timeout/no response): “Refund is pending. The payment service did not respond. Follow up is required.”
Delivery failed but downloadable: “Email delivery failed. The notice is available for download. Correct the address and resend.”


Design — Prompts

  • Confirm placement of staff-facing refund confirmation and error flag.
  • Ensure accessibility basics.
  • Paste design link above.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions