Auto billing for a CRM and lead generation system
The client aggregates sales leads from websites and registration forms and sells them to its customers. Invoices were created by hand in Xero and card payments were charged manually through SecureTrading.
Smartym Pro stabilised the existing PHP codebase and built a billing pipeline that creates invoices, charges cards, sends invoices and chases unpaid ones without manual work.

Project overview
Duration
3 months
Methodology
Agile
Project team
- 2 PHP developers
Technologies
Backend
- Language and framework: PHP 5.6, Yii 1
- Database: MySQL
- Background jobs: RabbitMQ queues for invoices, charges, reports and emails
- Dependencies: Composer
Frontend
- UI: Twitter Bootstrap 3, jQuery
Integrations
- Accounting: Xero API for invoices
- Payments: SecureTrading API for card charges
- Lead sources: WordPress sites and registration forms
Delivery
- Source control and CI: Git on Bitbucket, continuous integration
Inside the system

Billing pipeline
Separate queues create invoices, prepare them for sending and charge cards, so a slow external API never blocks the CRM.

Reports and emails in the background
Report generation and email sending moved to RabbitMQ workers, which made the web interface noticeably faster.

Lead generation dashboard
One place to reach accounts, partners, leads, saved filters and lead groups.

Lead management
Leads arrive from connected sources, are grouped and assigned a price, then sold to partners.

Lead details
Each lead keeps its contact data, group, total amount and statement history, which feed the invoices.

Lead groups and pricing
Lead groups set the price per lead for each introducer, so billing amounts are calculated automatically.
Solution
When we joined, the project was unstable, especially its code. We first put the codebase under Git on Bitbucket, set up continuous integration, moved all dependencies to Composer and carried out a large refactoring. This gave the team a stable base for new features.
At the second stage we built independent services for the Xero and SecureTrading APIs. RabbitMQ connects them with the web application: the UI puts a task in a queue and returns immediately, while workers create invoices, charge cards, generate reports and send emails in the background.
Card payments are processed on the SecureTrading side, so the CRM never stores full card numbers.
Result
In three months the client got a stable, maintainable codebase and an automated billing cycle: invoices are created in Xero, cards are charged through SecureTrading, invoices are sent to customers and reminders go to those who have not paid yet.
The system is tightly integrated with Xero and SecureTrading and with lead sources such as WordPress sites and registration forms.
Want to know more?
If you'd like more details on this project or a reference from the client, let us know.