## Summary
- Makes Stripe Terminal card payment intents always use 25% moms in the
API, independent of any client-supplied `tax_percentage`.
- Updates amount calculation, metadata persistence, stored-intent reuse
matching, the authoritative OpenAPI contracts, and operation-specific
Writerside outputs.
- Prevents double charging and false order closure across stale,
concurrently succeeded, partially recorded, or mismatched intents.
- Serializes payment create/capture/closure with order-item changes and
every order-to-invoice-collection reassignment through shared database
locks.
- Converts expected lock contention and reconciliation cases into
deliberate 409 responses.
## Exact-head evidence
Current head: `3a0f70d315a94d2efe586a2188d2c54f8ff11cd4`
- PHP syntax passed for all changed runtime files.
- Focused Orders suite: **42 tests / 293 assertions passed**.
- `git diff --check` passed.
- Fresh exact-head Tests and Qodana are running.
- Every Codex finding has a concrete reply; a fresh exact-head review is
requested below.
## Safety behavior
- Caller-controlled VAT is absent from request contracts; fixed 25% moms
is server-owned.
- A succeeded payment is preserved, requires the full expected
`amount_received`, and cannot close a changed/mismatched or
already-claimed collection.
- A compatible partially recorded Stripe closure is completed
idempotently; conflicting partial state fails closed for manual
reconciliation.
- Every cancellation/delete caller honors a concurrent-success result
and never falsely reports a completed payment as cleared.
- Price changes and invoice-collection reassignment share the payment
lock through validation, capture, post-capture reload, and closure.
- Reader changes are persisted only for reusable matching intents, so
stale intent cancellation targets the original terminal.
- Accepted legacy succeeded intents normalize stored tax to 25% before
response construction.
---------
Co-authored-by: Jeppe Bundgaard <jb@truckwash.dk>
## Summary
- retire Stripe hosted payment-link creation routes used by POS and
order management
- automatically capture authorized payment intents rather than requiring
a separate manual capture action
- preserve ordinary terminal payment and payment-intent lifecycle
behavior
- add API and wiring regressions for payment-link retirement and
automatic capture
Paired frontend change:
https://github.com/copenhagentruckwash/pleno-vue/pull/233
## Verification
- focused backend unit suite: 2 tests, 36 assertions passed
- PHP syntax checks passed
- paired frontend unit and Playwright suites passed locally
- full required GitHub runner suites are required before this task may
enter Review or merge
## Security and operational notes
- no credentials, terminal secrets, or payment data are added
- no live Stripe account or physical terminal was exercised locally
- automatic merge remains gated on both paired PRs having passing
required checks and current branches
Resolve recommended-profile Critical and High findings, retain narrow analyzer exceptions, and update the edge-broker WebSocket dependency to a non-vulnerable release.
- Implemented `InvoicingPeriodDraftOverlayTest` with coverage for blocking and permitting invoicing actions based on draft states, transactions, and metadata.
- Created `ReferenceSuggestionsApiTest` to validate ranked and filtered suggestions across bookings, orders, and vehicles with varied match relevance, context, and frequency.
- Added `order_reference_suggestions_service` class, including query methods, normalization utilities, and aggregation logic for reference suggestions.
- Enhanced query handling in `InvoicingPeriodDraftOverlayFakeDb` to validate SQL constraints and column cache resets in overlapping invoicing contexts.
- Add branding management feature: API routes, payload handling, and OpenAPI schema updates.
- Implement department branding logic: CRUD operations, validation, and permissions.
- Add order deletion confirmation support with conflict handling and OpenAPI schema updates.
- Enhance tests and API methods for improved order handling and branding workflows.
Transitioned from obsolete gateway object classes (`edge_gateway_shell_action_jobs_o`, `edge_gateway_shell_events_o`, `edge_gateway_shell_sessions_o`, `edge_gateway_update_jobs_o`) to the new agent implementation (`edge-gateway-agent/agent.php`).
- Introduced `safety_seal` column in the `orders` table.
- Updated order creation and completion logic to handle safety seal values.
- Enhanced order and booking classes to manage safety seal attachment and retrieval.
- Added tests to validate safety seal functionality in order processing.
- Use `resolveEffectiveCustomerNumber` for determining customer context.
- Adjust own/department access logic and remove unnecessary casting for `customer_id`.
- Integrate `subusers_permission_node_key` for dynamic subuser-specific permission checks.
- Refactor authentication and permission logic to streamline checks for own vs. department-level access.
- Simplify error handling and enforce scoped permissions for vehicles, orders, and their attachments.
- Localize permission labels and descriptions to Danish for relevant modules.
- Introduced `getCashierName` method in `users_o` for cashier name retrieval.
- Added caching for cashier names with dedicated expiration settings.
- Updated `ordersRoute` to include cashier names in order details.
- Added `$cashierNameCacheExpiration` property in `db_object_t` for centralized cache control.
- Moved redundant order update logic to a centralized `updateOrder` method for better code reuse.
- Simplified route definitions in `ordersRoute` by delegating updates to the new `updateOrder` method.
- Added `NoReturn` attribute for improved type hinting and error handling.
- Added `sendWashCertificateToCustomer` method in `order_bookings_o` to handle email sending for wash certificates.
- Implemented `sendWashCertificateEmailToCustomer` in `email` to generate and attach wash certificate PDFs.
- Updated attachment permission logic in `ordersRoute` and `db_object_t`.
- Changed `object_attachments_o` property types and handling for improved attachment processing.
- Introduced separate permissions for listing all order attachments and own order attachments.
- Added conditional logic to verify ownership of orders for `list_own_order_attachments` permission.
- Improved error responses for unauthorized access to order attachments.
- Introduced `po` property in `orders_o` for handling Purchase Order (PO) numbers, including API integration for retrieval and validation.
- Enhanced customer permissions to allow limited order editing (`po` updates) and attachment downloads for their own orders.
- Added new helper methods to `users_o` for attributes like `showPricesOnBookingPage` and `usePONumbers`.
- Improved order item listing logic with distinct permissions for customers' own orders and price visibility.
- Implemented numeric value casting in filters within `db_object_t`.
- Introduced `is_handheld` field in order creation to identify orders from handheld devices.
- Added logic to set, cache, and expire pending handheld orders automatically at midnight.
- Enhanced `orders_o` class with `setPendingHandheldIndicator` and `isPendingHandheld` methods.
- Updated order processing flow to include `pending_handheld` indicator in responses.
- Implemented CRUD operations for order attachments, including adding, listing, downloading, and deleting.
- Updated `db_object_t` and `attachments` to enhance object-attachment interactions with new methods for formatting, creating, and managing attachments.
- Added new routes (`/orders/attachments` and `/attachments/upload`) for attachment-related functionality.
- Adjusted `file_server.php` to handle temp file downloads and attachment storage.
- Improved typing and error handling across attachment helper methods and classes.
- Introduced a new route `/vehicles/search` to enable searching for vehicles by registration number across multiple categories (e.g., verified, known, booked, unknown).
- Added validation for search parameters, including length and format checks.
- Ensured proper classification of vehicles with clear prioritization and deduplication logic.
- Implemented helper methods to retrieve matching registrations from various sources like bookings, orders, and scanned plates.
- Enhanced response format to include vehicle status, customer details, and references for improved usability.
- Introduced `addArray` method in `orders_o` for streamlined order creation using an associative array.
- Updated `ordersRoute` to utilize `addArray`, replacing older implementation for better manageability.
- Improved input handling by trimming whitespaces from registration numbers.
- Enhanced product pricing by incorporating department-specific prices and discount percentages.
Introduced support for forced pricing in `addItemToOrder` and added stricter validation for array inputs in SQL queries. Enhanced JSON handling in type validation and improved code reuse with new objects. Added new endpoint `/modules/xlvask/related-orders` to fetch related orders by wash IDs.
Introduced a new `wash_id` property to the `orders_o` object and updated related order handling logic. Implemented functionality to restrict users to only list their own orders if they lack permissions to view all orders. Updated permissions and adjusted queries accordingly.
Introduce the closed_at field to track closure dates for order invoices. Updated validation, processing logic, and database integration to ensure correct handling of the new field. Adjusted related routes to pass and store the closed_at value where applicable.
Introduced a new POST route for collected vehicle subscription invoices and enhanced responses with wash subscription transactions. Refactored order handling by adding department-based pricing logic and simplifying reusable methods. Various minor improvements include exception handling, input validation, and updated permissions.
Replaced 'charge_order_stripe' with a more general 'charge_order' permission check in the Stripe payment intent endpoint. This ensures consistent permission handling across payment modules.
Introduced methods to handle Stripe payment capture and updated related classes and endpoints. Refactored constants for payment processors and integrated order collections to reflect Stripe payments. Ensured robust error handling and session validation for payment operations.
This new endpoint allows simulating Stripe payment intents for debugging purposes. It includes validation checks for session, order existence, and payment intent status, ensuring controlled execution. This functionality is intended strictly for testing and should not be used in production environments.
Introduced functionality for handling Stripe payment intents, including creation, retrieval, and cancellation. Added a subscription_allowed flag to products for enabling subscription-specific operations. Integrated the necessary backend endpoints, object property updates, and route handling logic.
Refactored invoice draft handling to improve error checks, added support for optional fetch skipping, and enhanced currency management. Expanded filtering capabilities with date range and attribute-based filters. Adjusted Nginx config to increase FastCGI read timeout for long-running processes.
Implemented a new endpoint to mark orders as completed and updated the `orders_o` object with the necessary logic and database integration. Added a `completed_at` property to track when an order is marked as completed. Includes validation, error handling, and logging to ensure proper functionality.
Introduced customer attribute-based filtering for individual invoicing and enhanced collected order invoice processing with proper associations to customers and orders. Added new endpoints, fields, and utility methods to streamline data retrieval, ensure consistency, and support new use cases like 'Ready to Invoice'. Includes minor fixes, validations, and optimizations throughout the affected modules.
Introduce the booked_invoice_id property in collected_order_invoices_o for improved invoice management. Optimize performance by avoiding redundant requests to external systems when the booked_invoice_id is already set. Enhance routes to include the booked_invoice_id in relevant responses and ensure a consistent structure for associated data.