cardgate / magento2
CardGate Module for Magento 2
Package info
Type:magento2-module
pkg:composer/cardgate/magento2
Requires
- php: >=7.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- 2.0.63
- 2.0.62
- 2.0.61
- 2.0.60
- 2.0.59
- 2.0.58
- 2.0.57
- 2.0.56
- 2.0.55
- 2.0.54
- 2.0.53
- 2.0.52
- 2.0.51
- 2.0.50
- 2.0.49
- 2.0.48
- 2.0.47
- 2.0.46
- 2.0.45
- 2.0.44
- 2.0.43
- 2.0.42
- 2.0.41
- 2.0.40
- 2.0.39
- 2.0.38
- 2.0.37
- 2.0.36
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- v2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
This package is auto-updated.
Last update: 2026-10-28 14:15:49 UTC
README
CardGate module for Magento 2
Support
This plugin supports Magento 2.1.x - 2.4.x.
Preparation
The usage of this module requires that you have obtained CardGate RESTful API credentials. Please visit My CardGate and retrieve your credentials, or contact your accountmanager.
Installation
The CardGate Module for Magento 2 is installed via Composer.
-
Go to Magento 2 root folder.
-
Enter following commands to install module:
composer require cardgate/magento2Wait while dependencies are updated.
-
Enter following commands to enable module:
php bin/magento module:enable Cardgate_Payment php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:clean -
If Magento is running in production mode, deploy static content:
php bin/magento setup:static-content:deploy
Configuration
- Open the Magento Admin panel and view the CardGate plugin-configuration:
- Stores > Configuration
- Sales > CardGate
- Fill in the CardGate configuration section using the API credentials obtained earlier.
- Save config.
- Refresh the active payment methods:
- CardGate information section
- Payment methods > Refresh active payment methods
- Check the output
- After the payment methods are refreshed successfully, all active Payment method sections can be enabled and edited.
Subscriptions (CuroPayments recurring)
This module can sell products as recurring subscriptions. The first order is paid normally by the customer; every following billing cycle is charged automatically through the CuroPayments recurring entry point, without customer interaction:
- test:
https://secure-staging.curopayments.net/rest/v1/curo/recurring/ - live:
https://secure.curopayments.net/rest/v1/curo/recurring/
See the CuroPayments documentation for the entry point details. The initial (authorizing) transaction of the order acts as the mandate for all following recurring charges.
1. Setup
- Install/upgrade the module and run
php bin/magento setup:upgrade(creates thecardgate_subscriptiontable and the product attributes) followed byphp bin/magento cache:flush. - Make sure the Magento cron is running (
bin/magento cron:runfrom the system crontab). Subscription billing uses its own cron groupcardgate(seeetc/cron_groups.xml), so throttled settings of thedefaultgroup do not delay billing. - Enable at least one of the allowed payment methods (see below).
2. Making a product a subscription
setup:upgrade adds three product attributes (group CardGate Subscription), available for
every product type (simple, configurable, bundle, grouped and virtual):
| Attribute | Code | Meaning |
|---|---|---|
| Sell as Subscription | cardgate_is_subscription |
Yes = buying this product starts a subscription |
| Subscription Interval Count | cardgate_subscription_interval |
Number of units between charges (minimum 1) |
| Subscription Interval Unit | cardgate_subscription_interval_unit |
day, week, month or year (default month) |
Example: count 3 + unit month = billed every three months.
3. Cart and checkout rules
- One subscription product per cart. Adding a second subscription product is refused with the message "Only one subscription product is allowed per cart. You can add non-subscription products."
- Mixed carts are allowed. One-off products are billed only once by the initial order; only the subscription line-item is repeated.
- Allowed payment methods. A subscription is only created when the order is paid with:
Bancontact (
cardgate_bancontact/cardgate_mistercash), Creditcard, Direct Debit, iDEAL, Przelewy24 or onlineueberweisen. Orders paid with any other method are processed as normal orders without a subscription.
4. How a subscription is created
- The customer places the order and pays the initial transaction at CardGate.
- When the CardGate callback confirms the payment, the CardGate transaction id of the order
is stored as the mandate and a subscription record is created for the subscription
line-item (the
sales_order_place_afterobserver tries too, but at that moment there is no mandate yet). Creation is idempotent: one subscription per order + product. - The subscription stores:
- amount: row total incl. tax of the subscribed line-item;
- shipping amount: the order shipping (incl. tax), scaled to the cycle length (cycle days / 30, limited between 0.25x and 2x);
- currency, quantity, interval, payment method and mandate;
- next billing date (
next_run_at): order date + one interval, at 00:00 (UTC).
Renewal orders (created by a subscription) never create a new subscription.
5. Automated billing
The cron job cardgate_process_subscriptions runs every 5 minutes and picks up all
active subscriptions whose next_run_at has passed. For each of them:
- If skip next is set, the flag is cleared and the cycle is moved forward one interval without charging.
- Otherwise a renewal order is created: a copy of the subscribed line-item of the originating order, with the same customer, addresses, shipping and payment method.
- The renewal order is charged through the recurring entry point using the mandate, the order grand total and the order increment id as reference.
- The regular CardGate callback then captures and invoices the renewal order just like a normal order.
- On success
cycles_billedis increased,last_order_id/last_transaction_id/last_run_atare stored, failures are reset andnext_run_atmoves one interval forward.
6. Failures and retries
| Failure | What happens | Next attempt |
|---|---|---|
| Renewal order could not be created (gateway not contacted) | failure_count +1, last_error stored |
15, 30, 60, 120 ... minutes (max 240) |
| Gateway charge failed | Renewal order is cancelled with a comment, failure_count +1, last_error stored |
1, 2, 4, 7, 7 days (start of day) |
After 5 consecutive failures the subscription is set to paused for review. Check
last_error in the admin and var/log/exception.log / var/log/debug.log, fix the cause and
resume the subscription.
7. Statuses
- active – billed automatically when due.
- paused – not billed. Resume resets the failures and schedules the next charge one interval from now.
- cancelled – final; never billed again and cannot be resumed or paused.
8. Customer self-service (My Account → My Subscriptions)
Logged-in customers can, for their own subscriptions:
- Pause / Resume;
- Skip the next billing cycle (active subscriptions only);
- Change the interval (shipping is rescaled and the next charge is scheduled one new interval from now);
- Cancel.
9. Administration (Sales → Operations → CardGate Subscriptions)
Requires the ACL resource Sales → CardGate Subscriptions (Cardgate_Payment::subscriptions);
grant it under System → Permissions → User Roles for non-administrator roles.
The grid lists all subscriptions. On the edit page an administrator can change:
- shipping amount per cycle;
- the skip next flag;
- the next billing date;
- the interval count/unit;
- the status (active / paused / cancelled).
10. Troubleshooting
- Menu not visible: run
setup:upgrade,cache:flushand log in again. - Subscription not created: check that the product has Sell as Subscription = Yes, the payment method is allowed and the CardGate callback reached the shop.
- Nothing is billed: check that the cron runs and the
cardgategroup has entries incron_schedule, and that the subscription is active with a pastnext_run_at.
Testing
The module ships with a PHPUnit test-suite that runs on PHP 7.4 up to 8.3.
composer install
vendor/bin/phpunit
phpunit.xml uses the PHPUnit 10/11 schema and tests/bootstrap.php registers a
small PSR-4 autoloader so the standalone unit tests run without a full Magento
installation. PHPUnit ^10.5 || ^11.0 is declared under require-dev, both of
which support PHP 8.3.
Requirements
No further requirements.