Task flow · Owner-issued payment link

Owner-issued payment link

The owner mints a payment link for a quote or expense settlement and sends it to the buyer.

Status Implemented Last reviewed 2026-08-06 All task flows →

Flow

flowchart TD
      A["Owner opens quote console"] --> B["Clicks issue payment link"]
      B --> C["POST /owner/quote/<ref>/lien-paiement"]
      C --> D{"Staff authenticated?"}
      D -- No --> E["404"]
      D -- Yes --> F{"Target?"}
      F -- "mission" --> G["payment_for_quote"]
      F -- "expenses" --> H["payment_for_settlement"]
      G --> I["Create Payment row with reference"]
      H --> I
      I --> J["AuditEvent: payment_link_issued"]
      J --> K["Show absolute URL to owner"]
      K --> L["Owner sends URL to buyer"]
      L --> M["Buyer opens /paiement/<ref>/"]
      M --> N{"Already settled?"}
      N -- Yes --> O["Redirect to return page"]
      N -- No --> P["Show payment page + identity form"]
      P --> Q["Visitor corrects details if needed"]
      Q --> R["POST /paiement/<ref>/demarrer/"]
      R --> S["Create Stripe Checkout session"]
      S --> T["Redirect to Stripe"]
      T --> U{"Buyer action"}
      U -- "Pays" --> V["Webhook settles + grant entitlement"]
      U -- "Cancels" --> W["Nothing charged"]
      V --> X{"Subscription?"]
      X -- Yes --> Y["Show billing portal link"]
      X -- No --> Z["Show receipt + download links"]
            

Payment states and transitions

StateSet byNext
PENDINGView creates the row→ PROCESSING (checkout started)
PROCESSINGView after Stripe session created→ PAID (webhook) or FAILED (provider error)
PAIDWebhook only→ settled; entitlements granted
CANCELLEDBuyer action on Stripe→ terminal; row stays open
FAILEDProvider outage or invalid signature→ terminal; owner may retry
EXPIREDTime or terms window→ terminal; owner must reissue

Security and integrity rules

RuleEnforcement
Amount authorityAmount is frozen at link creation; browser input is never charged.
Terms freezeterms_version is stamped at payment creation.
Settlement authorityOnly the signed Stripe webhook writes PAID.
Reference secrecyPayment references are unguessable; holding the reference grants the right to pay.
No card data on serverStripe hosts the checkout page.
Robots exclusion/paiement/ is blocked by robots.txt.

Validation and recovery

ConditionSystem response
Staff not authenticated404; no link is created.
Payment is already settledRedirect to the return page; no second charge is created.
Webhook signature is invalid400; nothing is written. Stripe retries.
Payment link is expired or failedError message; the owner must issue a new link from the console.

Entitlement and delivery

When the webhook records a settled payment, grant_entitlements() creates the corresponding Entitlement row. For subscriptions, the buyer also receives a link to the Stripe customer portal for cancellation, card updates, and invoice history.