# mageprince/magento2-paymentfee

> Magento 2 Add Payment Fee To Order

`composer require mageprince/magento2-paymentfee`

Canonical URL: https://packagento.com/mageprince/magento2-paymentfee

## At a glance

- **Vendor**: mageprince (https://packagento.com/mageprince.md)
- **Latest version**: 2.1.7 — released 2026-05-18
- **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/mageprince/magento2-paymentfee 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 mageprince/magento2-paymentfee:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Magento 2 Add Payment Fee To Order

## README

The Magento 2 Payment Fee extension by MagePrince allows store owners to add extra charges for specific payment methods. These fees are shown throughout the customer journey — on the cart, checkout, order summary, invoice, credit memo, and sales emails. Admins can configure different types of fees, control visibility based on customer groups or store views, and even apply rules like disabling fees over a certain order amount. The extension also supports tax and refund settings for complete flexibility.

[![Latest Stable Version](https://poser.pugx.org/mageprince/magento2-paymentfee/v)](//packagist.org/packages/mageprince/magento2-paymentfee)
[![Total Downloads](https://poser.pugx.org/mageprince/magento2-paymentfee/downloads)](//packagist.org/packages/mageprince/magento2-paymentfee)
[![Monthly Downloads](https://poser.pugx.org/mageprince/magento2-paymentfee/d/monthly)](//packagist.org/packages/mageprince/magento2-paymentfee)
[![License](https://poser.pugx.org/mageprince/magento2-paymentfee/license)](//packagist.org/packages/mageprince/magento2-paymentfee)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mageprince/magento2-FAQ/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mageprince/magento2-FAQ/?branch=master)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/mageprince/magento2-FAQ/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
  
### ✨ Features
 - Enable or disable the extension from admin configuration
 - Add payment fees for specific payment methods (e.g., COD, PayPal)
 - Fee types supported:
   - Fixed Price
   - Percentage of Order
   - Per Item
   - Per Row
 - Display fees on:
   - Checkout Page
   - Order Summary
   - Sales Emails (Order, Invoice, Credit Memo)
   - Admin Order View
 - Set custom titles for fees
 - Refundable fee option in credit memo
 - Disable fees for orders exceeding a maximum amount
 - Customer group restrictions
 - Store view restrictions
 - Set sort order for fee display
 - Supports tax calculation on the fee
   - Assign tax class
   - Choose display type: Incl., Excl., or Both
 - Multi-store and multi-currency support
 - Option to include discount/shipping in subtotal for calculation

### 💡 Payment Fee Types Explained
**1. Fixed Price**

A flat fee is added to the order, no matter what’s in the cart.

Example: Fee = 10 → You pay 10 extra.

**2. Percentage Price**

The fee is a percentage of the cart subtotal.
- If “Include shipping in subtotal” is Yes:
  - Subtotal = Products + Shipping
- If “Include discount in subtotal” is Yes:
  - Subtotal = Subtotal - Discount

Example: Fee = 10%, Subtotal = 36 → Extra = 3.60

**3. Per Row**

Fee is added based on the number of products (rows) in the cart.

Example: Fee = 10, Cart = 2 products → Extra = 20

**4. Per Item**

Fee is based on the total quantity of all products in the cart.

Example: Fee = 10, Cart = 3 items total → Extra = 30

### 🧪 Demo

<b><a href="http://demo.mageprince.com/">Frontend</a>   |   <a href="http://demo.mageprince.com/admin">Backend</a></b>

### 🚀 Installation Instructions

#### Option 1: Install via Composer (recommended)

```
composer require mageprince/magento2-paymentfee
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```

#### Option 2: Manual Installation
1. Copy the content of the repo to the Magento 2 `app/code/Mageprince/Paymentfee`
2. Run the following Magento CLI commands:
```
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
```

### ✅ Compatibility

- Magento Open Source (Community Edition): 2.4.4 – 2.4.8
- Adobe Commerce (Enterprise Edition): 2.4.4 – 2.4.8
  
### 🤝 Contribution

Want to contribute to this extension? The quickest way is to <a href="https://help.github.com/articles/about-pull-requests/">open a pull request</a> on GitHub.

### 🛠 Support

If you encounter any problems or bugs, please <a href="https://github.com/mageprince/magento2-paymentfee/issues">open an issue</a> on GitHub.

### 📸 Screenshots

#### Checkout Page
<img width="1248" alt="image" src="https://github.com/user-attachments/assets/b22c94e7-5c89-4c48-8929-cde1b6dd68f4" />


#### Configuration
<img width="986" alt="image" src="https://github.com/user-attachments/assets/2e8df15a-2ae3-41cf-91f0-9bb975b35eb0" />
<img width="1007" alt="image" src="https://github.com/user-attachments/assets/8239f224-985f-498e-9af7-b84bc2372534" />

## Recent Versions

| Version | Released |
|---|---|
| 2.1.7 | 2026-05-18 |
| 2.1.6 | 2025-04-22 |
| 2.1.4 | 2021-03-25 |
| 2.1.3 | 2021-02-23 |
| 2.1.2 | 2021-01-19 |
| 2.1.1 | 2020-12-12 |
| 2.0.2 | 2020-06-28 |

## Quality

Latest release (2.1.7) 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 | Pass | 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 | Warning | 26 | 26 warnings (ruleset: Magento2) |
| PHPMD | Warning | 5 | 5 rule violations (UnusedFormalParameter:2, IfStatementAssignment:1, EmptyCatchBlock:1, UnusedLocalVariable:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 1 | valid; 1 advisory note (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 | 13 | 13 | – | – |
| 2.4.8 | – | 13 | 13 | – |
| 2.4.9 | – | – | 11 | 11 |


### 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=["mageprince/magento2-paymentfee"],
  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

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

