Orders

Commands

Overview

Commands are used to perform specific tasks in the application. They are used to perform tasks that are not related to the web application. For example, the orders:recover command is used to recover orders that were successfully paid but not created.

RecoverOrder

PurposeRecover orders that were successfully paid but not created.
DependenciesPaymentService, OrderService
Command Signatureorders:recover
Logic Flow- Retrieve incomplete successful transactions.
- Iterate through orders and validate with transactions.
- Create orders if validation passes.
- Log success or failure messages.

RecoverSingleOrder (extends RecoverOrder)

PurposeRecover a single order based on a specified transaction ID.
Command Signatureorders:recover-single {transaction}
Logic Flow- Find specified transaction and associated cached order data.
- Validate order with the associated transaction.
- Create order if validation passes.
- Log success or failure messages.

RetryPendingRefunds

PurposeAttempt to process refunds for orders with hold reason PENDING_REFUND.
DependenciesLaravel logging system (Log)
Command Signatureorders:retry-pending-refunds
Logic Flow- Retrieve orders with hold reason PENDING_REFUND.
- Process each order, find original order, and dispatch refund job.
- Log information and warnings for each processed order.

UpdateOrder Class (Not a Command):

PurposeProvides a generic mechanism to update order properties.
DependenciesDedicated classes for specific property updates.
Logic Flow- Iterate through provided order details to update.
- Call appropriate order updater class for each property.
- Save updates applied by order updaters.

Key Concepts:

  • Laravel Console Commands: Artisan commands for executing tasks via the command line.
  • Service Injection: Dependency injection of PaymentService and OrderService.
  • Exception Handling: Uses OrderModuleException for order validation exceptions.
  • Dispatching Jobs: Dispatches jobs for asynchronous processing.
  • Logging: Utilizes Laravel's logging system (Log).
  • Config Checks: Checks configuration setting before proceeding.
  • Interface Implementation: References OrderUpdater interface.
  • Dynamic Class Instantiation: Uses app() for dynamic instantiation.

Copyright © 2026