-
Notifications
You must be signed in to change notification settings - Fork 2
Setup Recurring Module
Magento has an integrated Logic to process Recurring Transactions. The Recurring Products must be ordered standalone, it is not allowed to add more than one nominal item to the cart together with a non-recurring product. The Recurring Profiles are generated per Product, which means that to one Recurring Profile can be attached more than one Order, but only one Nominal Item.
This settings are available for the WPF and for the Processing API as well.
- New Admin Configuration Settings
- Enable Recurring
-
Init Recurring Transaction Types - define the available transactions for the recurring
- InitRecurringSale
- InitRecurringSale (3D-Secure)
- Initial Fee - define an initial fee if it is not define for a product
- Recurring Task Scheduler (cron syntax) - setup the period executing for the cron job
- Recurring Job Log File - keep empty to disable logging
Please follow these Steps in order to create a recurring profile
-
Login to the Admin Panel of Magento
-
Go to
Catalog
->Manage Products
. Choose a Product and clickEdit
-
Click on
Recurring Profile
inProduct Information
and setEnable Recurring Profile
toYes
-
Define the Schedule
-
Define the Billing Periods and Cycles
- Billing Frequency - defines the number of billing periods for one Billing Cycle (ex. The Recurring Profile will be charged every second Month starting from the Profile StartDateTime if Billing Frequency = 2 and Billing Period Unit = Month)
- Maximum Billing Cycles - how many Recurring Sales Transactions should be done (Keep empty if you wish to create an endless Recurring Profile, it can only be Suspended or Canceled by Customer or Admin).
-
Define Initial Fees
- Initial Fee - with this option you can define an Initial Fee per product, which is going to be used for the Init Recurring Transaction (if empty, the global Initial Fee Setting for the Payment Method will be used to send an Init Recurring Transaction
- Allow Initial Fee Failure - If Enabled the Recurring Profile will not be Suspended if an error is generated on the Init Recurring Transaction
We are using the Magento Cron it order to Charge Recurring Profiles (Submit Recurring Sale Transactions). Our cron job is making a check if the Billing Cycle is reached and if so then it Suspends the Recurring Profile.
- Cron Settings
- Go to
Admin
->System
->Configuration
->System
->Cron (Scheduled Tasks)
- Edit the
crontab
for the WebUser-
Use SSH Access or login to CPanel and go to
Cron Jobs
-
Type the following command in the terminal to edit the Cron Jobs for the Web User - Replace
www-data
with your web user.$ sudo crontab -u www-data -e
-
Create a new Job - The following Job will call the Magento Cron Job once per 5 Minutes
*/5 * * * * /bin/sh /path/to/magento/cron.sh cron.php -m=default
*/5 * * * * /bin/sh /path/to/magento/cron.sh cron.php -m=always
-
Unfortunately Magento does not have an integrated module for analyzing and viewing and managing the Scheduled Cron Job. They are stored in the database in the table
cron_schedule
.
-
- Go to
You can use a free extension for Magento, which allows easy to manage and monitor the Magento Cron Jobs. Here is a link to the Aoe_Scheduler Module, which can easily installed and configured in Magento.
-
Installation
$ composer require aoepeople/aoe_scheduler
-
Configuration
- If MenuItem
Admin
->System
->Scheduler
does not exist, go toAdmin
->Cache Management
and clickFlush Magento Cache
- Go to
Admin
->System
->Configuration
->System
->Cron (Scheduled Tasks)
and configure the new Configuration Settings added from the Installed Module - Go to
Admin
->System
->Scheduler
->Job Configuration
- Enable / Disable Magento Cron Jobs
- Manage Cron Job Expression
- Select a Cron Job and select an action you wish from the top and submit - Use this function to schedule manually a cron job
- Overview of the generated Scheduled Jobs
- Go to
Admin
->System
->Scheduler
->List View
- Use the Return Message from Every Job, which is shown in the column
Message
to find out more about what has been done it every job. - Select a Record and choose your
Action
->Delete
orKill
- Pay attention to the Status of every Scheduled Job
- Pending
- Success
- Error
- Go to
- If MenuItem
-
Generating a Script for the scheduler
- Go to
Admin
->System
->Scheduler
->Instructions
- Use the available Settings to generate a configuration
-
Edit your
crontab
$ sudo crontab -u ${webuser} -e
-
Create a new job - this is a sample job which runs one in 30 Minutes if only the Site is not under maintenance and sends an email after the job completes or an error occures.
MAILTO="[email protected]"
*/30 * * * * ! test -e /www/maintenance.flag && /bin/bash /path/to/magento/scheduler_cron.sh --mode always
*/30 * * * * ! test -e /www/maintenance.flag && /bin/bash /path/to/magento/scheduler_cron.sh --mode default
-
- Go to
Our cron jobs are looking to all Active Recurring Profiles generated by our Payment Modules and generates a Recurring Sale Request to our Payment Gateway if the Billing Cycle is not yet reached.
Follow the steps to manage a generated Recurring Profile:
- Go to
Admin
->Sales
->Recurring Profiles
- Choose your profile and edit it
- You can
Suspend
andCancel
- You can view all orders related to the Recurring Profile
- Click on an Order to view on
- Click on transactions to find out the generated transaction for this order
- Refund an Order - if you refund the Init Recurring Transaction then the Recurring Profile will be suspended, because it is no more Recurring Sale Transaction can be requested if the Init Recurring Transaction is refunded.
The Recurring Module has been also configured and installed on our Magento Demo Store.
Note: If you have trouble with the Recurring Module Configurations, get in touch with our support team