# mage-os/module-rma

> Return Merchandise Authorization

`composer require mage-os/module-rma`

Canonical URL: https://packagento.com/mage-os/module-rma

## At a glance

- **Vendor**: mage-os (https://packagento.com/mage-os.md)
- **Latest version**: 2.4.0 — released 2026-07-08
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/mage-os/module-rma and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require mage-os/module-rma:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Return Merchandise Authorization

## README

Return Merchandise Authorization (RMA) module for Magento / MageOS.

### Installation

#### Via Composer

```bash
composer require mage-os/module-rma
```

#### Enable the module

```bash
bin/magento module:enable MageOS_RMA
bin/magento setup:upgrade
bin/magento cache:flush
```

> The `setup:upgrade` command creates the database tables and inserts default data (status, reason, resolution type, item condition) via Data Patches.

### Configuration

Module settings are located at **Stores > Configuration > Sales > RMA - Return Management**.

#### General

| Field | Type | Default | Description |
|---|---|---|---|
| Enable RMA | Yes/No | No | Enable or disable the RMA feature (scope: website) |
| Increment ID Prefix | Text | `RMA-` | Prefix for the return increment ID (e.g. `RMA-000001`) |
| Return Period (Days) | Numeric | `30` | Number of days after order placement within which a return can be requested |

#### Policy

| Field | Type | Default | Description |
|---|---|---|---|
| Auto-Approve Returns | Yes/No | No | When enabled, new return requests are automatically approved |
| Allowed Order Statuses | Multiselect | `complete` | Only orders with these statuses can have a return request |

#### Email Notifications

| Field | Type | Default | Description |
|---|---|---|---|
| Email Sender | Select | `General Contact` | Sender identity for RMA emails |
| New RMA Email Template (Customer) | Select | — | Email template sent to the customer when a new return is created |
| Status Change Email Template (Customer) | Select | — | Email template sent to the customer on return status change |
| New RMA Email Template (Admin) | Select | — | Email template sent to the admin when a new return is created |
| Admin Notification Email | Text (email) | — | Email address to receive admin notifications about returns |

#### Attachments

| Field | Type | Default | Description |
|---|---|---|---|
| Allowed File Extensions | Text | `jpg,jpeg,png,gif,webp,mp4,mov,pdf,doc,docx,zip` | Comma-separated list of allowed file extensions |
| Maximum File Size (MB) | Numeric | `10` | Maximum allowed file size in megabytes per single file |
| Maximum Files Per Upload | Numeric | `5` | Maximum number of files allowed per RMA creation or comment |

### Admin Area

#### Menu

Module entries are located under **Sales > RMA**:

- **RMA Requests** — main grid with all return requests
- **Statuses** — manage the return lifecycle statuses
- **Reasons** — manage return reasons
- **Resolution Types** — manage resolution types (refund, replacement, etc.)
- **Item Conditions** — manage item conditions (opened, sealed, etc.)

#### Creating an RMA from admin

1. Go to **Sales > RMA > RMA Requests**, click **Add New RMA**
2. Search and select an order in the **Order** field (only shows orders from websites with RMA enabled)
3. Customer fields (name, email) and store are automatically filled from the order
4. Select reason and resolution type
5. In the **Items to Return** section, select the order items to include in the return, specifying quantity and condition for each
6. Save — the system automatically generates an increment ID (e.g. `RMA-000001`) and sends notification emails

#### Edit RMA

In edit mode, the form shows order and item information as read-only. You can modify status, reason, resolution type and admin notes.

Changing the status automatically sends a notification email to the customer.

#### Attachments

The RMA edit page displays a unified **Attachments** section above the comments timeline. This section shows all attachments associated with the RMA, regardless of whether they were uploaded at RMA creation or within a comment.

- Each attachment has a **download** link and a **delete** button
- Deleting an attachment from the unified section also removes it from the corresponding comment in the timeline (and vice versa)
- The section updates dynamically when new comments with attachments arrive via polling

#### Comments / Chat

The RMA edit page includes a **Comments** section that enables communication between admin and customer.

- Admin can write comments visible to the customer or **internal notes** (not visible to the customer) via the "Visible to Customer" checkbox
- Internal notes display an **Internal Note** badge in the timeline
- Admin can attach files to comments via drag & drop or file picker
- Comments update in real time via AJAX polling with progressive backoff (10s → 30s → 60s)
- Polling pauses when the browser tab is not visible and resumes when it becomes active again
- Messages can be sent with **Ctrl+Enter** in addition to the button

### Frontend — Customer

#### My Returns

A **My Returns** link appears in the customer account sidebar. The page shows all of the customer's returns sorted by date descending, with pagination.

Table columns:

| Column | Description |
|---|---|
| RMA # | Return increment ID (e.g. `RMA-000001`) |
| Order # | Associated order increment ID |
| Status | Current return status (translated per store view) |
| Created At | Creation date |
| Action | **View** link to the detail page |

The **Request Return** button at the top leads to the creation form.

#### RMA Detail

The page displays return information and the items table:

- **General information**: increment ID, order, status, reason, preferred resolution, creation and update dates
- **Items table**: product name, SKU, requested quantity, item condition
- **Attachments section**: all attachments uploaded across the RMA lifecycle (creation and comments) displayed in a unified list with download links. The section is always present and updates dynamically when new comments with attachments arrive
- All labels (status, reason, resolution, condition) are translated according to the current store view

##### Customer Comments / Chat

Below the detail section there is a comments area that allows the customer to communicate with support:

_(README truncated for .md surface. Full README on https://packagento.com/mage-os/module-rma.)_

## Changelog

### [2.4.0] - 2026-07-05

#### Added
- Guest-form RMA requests are now linked to the customer account when the order belongs to a registered customer, so they appear in "My Returns"

#### Fixed
- **[i18n]** Lookup labels (status, reason, resolution type, item condition) now translated in transactional emails (store emulation in `Service\Email\Sender`) and frontend selects (`__()` in `AbstractLookupSource::toOptionArray()`); seed label translations added to all i18n CSVs
- **[Code Quality]** `TypeError` on repository `getList()` — dedicated SearchResults classes in `Model/Data/` wired via `di.xml` preferences

### [2.3.3] - 2026-06-22

#### Fixed
- Add a new event (`rma_commit_after`) to use for sending new RMA emails. This fixes the issue #39

### [2.3.2] - 2026-06-18

#### Fixed
- Shortened long DB constraint names to comply with database limitations

#### Added
- **Romanian translations** for UI, emails, and configuration

### [2.3.1] - 2026-06-05
#### Fixed
- Fix unqualified column reference in customer RMA list (#36)

### [2.3.0] - 2026-05-10

#### Changed
- **Enable RMA** system configuration default switched from `Yes` to `No` at installation — RMA feature must now be explicitly enabled by the admin after install (#34)
- README updated to reflect the new `Enable RMA` default value (#34)

### [2.2.1] - 2026-04-27

#### Fixed
- **[Code Quality]** Raw SQL `getConnection()->fetchOne()` in `RMARepository::save()` for old status detection replaced with repository pattern `$this->get()->getStatusId()` (#22)
- **[Code Quality]** N+1 query in customer RMA history — `ListRma::getOrderIncrementId()` calling `orderRepository->get()` per row replaced with single LEFT JOIN on `sales_order` via new opt-in `Collection::joinSalesOrder()` method (#24)
- **[Compatibility]** PHP 8.5: nullable getter return values cast to `(int)`/`(string)` before use as array keys in 5 admin DataProviders (`RMA`, `Status`, `Reason`, `ResolutionType`, `ItemCondition`), 3 UI listing columns (`RmaActions`, `StatusActions`, `GenericEntityActions`), and `ReturnDataProvider` GraphQL lookup — prevents null-as-array-key warnings on PHP 8.5+

### [2.2.0] - 2026-04-21

#### Fixed
- **[Security]** Trailing slash gap on absolute attachment paths in `AttachmentService` allowed potential path-traversal edge cases (#32)

#### Added
- Unit test coverage for `AbstractRepository`, `RMARepository`, `StatusResolver`, `OrderEligibility`, `RmaSubmitService`, `AttachmentService`, attachment upload, and customer attachment download (#32)

### [2.1.0] - 2026-04-15

#### Fixed
- **[Security]** Allowed file extensions config switched from free-form comma list to multiselect with server-side mimetype validation in `AttachmentService` (#30)

#### Added
- `Model/Config/Source/AllowedExtensions.php` source model backing the new multiselect config (#30)

### [2.0.1] - 2026-04-09

#### Fixed
- `NoSuchEntityException` resolved in wrong namespace in `Block/Customer/Rma/ListRma.php` — catch block never matched
- `SearchCriteriaBuilder::addSortOrder()` called with two strings instead of `SortOrder` object in `AbstractRmaManagement` — runtime error when sorting items/comments via management layer

### [2.0.0] - 2026-04-08

#### Breaking Changes
- `RmaSubmitService::saveItems()` now requires `OrderInterface $order` as third parameter
- `AbstractRmaManagement` now injects `SearchCriteriaBuilderFactory` instead of `SearchCriteriaBuilder` (affects `RmaItemManagement` and `RmaCommentManagement` constructors)

_(Changelog truncated for .md surface. Full history on https://packagento.com/mage-os/module-rma.)_

## Recent Versions

| Version | Released |
|---|---|
| 2.4.0 | 2026-07-08 |
| 2.3.3 | 2026-06-22 |
| 2.3.2 | 2026-06-18 |
| 2.3.1 | 2026-06-05 |
| 2.3.0 | 2026-05-10 |
| 2.2.1 | 2026-04-27 |
| 2.2.0 | 2026-04-21 |
| 2.1.0 | 2026-04-15 |
| 2.0.1 | 2026-04-09 |
| 2.0.0 | 2026-04-08 |

Showing 10 of 17 versions. Full release history on https://packagento.com/mage-os/module-rma.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | * |
| magento/module-graph-ql | * |
| magento/module-sales | * |
| magento/module-webapi | * |
| php | >=8.3 |

## Quality

Latest release (2.4.0) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | not tested | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | Pass |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 344 | 8 errors, 336 warnings (ruleset: Magento2), 8 auto-fixable with phpcbf |
| PHPMD | Warning | 64 | 64 rule violations (UnusedFormalParameter:43, MissingImport:11, TooManyPublicMethods:4, EmptyCatchBlock:3, NPathComplexity:2) |
| Cpd | Warning | 4 | 4 duplicated chunks spanning 276 total lines (min-lines=5, min-tokens=70) |
| Composer validate | Info | 4 | valid; 4 advisory notes (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 124 | 35 | – | – |
| 2.4.8 | – | 35 | 35 | – |
| 2.4.9 | – | – | 35 | 35 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["mage-os/module-rma"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

mage-os is a Magento 2 vendor on Packagento. See https://packagento.com/mage-os.md for their full catalogue.

