Developing a payment service with recurring billing

01 / 03 image2-1.png
Screen 1 of 3 Screen 2 of 3 Screen 3 of 3

Case study · Laravel · Payment APIs · Subscriptions

A Laravel payment service for managing subscriptions and recurring charges across multiple online projects. A single internal dashboard brings together payment history, revenue analytics, scheduled payments and the results of custom billing jobs.

Published:

One of my first Laravel projects. As it evolved, it brought together CloudPayments and PaySelection integrations, background jobs and tools for day-to-day subscription operations. The most interesting challenges were archiving inactive subscriber records, analysing revenue and implementing configurable billing workflows.

Payment service modules: billing queues, CloudPayments and PaySelection, subscriber archive and analytics
Main service modules. Architecture illustration without customer or payment data.

The task: centralise subscription operations

Managing subscriptions across several websites requires a clear view of active accounts, upcoming payments, successful charges and reasons for declined attempts. Individual projects also need their own amounts, limits and schedules.

My work covered backend development, payment integrations and an internal interface for monitoring subscriptions and background processing.

  • Subscriber archiveMove stopped subscriptions out of the working table while retaining their data and stop reason.
  • Revenue analyticsRevenue, attempt history, revenue per user and subscriber cohort metrics.
  • Custom billing jobsSeparate workflows with their own amount, selection rules, daily cap and operating hours.
  • PlanningA schedule of upcoming payments and an estimated distribution of billing jobs.

Archiving subscribers to reduce the working dataset

Stopped subscriptions accumulate in the working table even though they are no longer needed when selecting the next payment. A separate archive reduces the amount of data handled by the main payment workflow.

The archive command selects records marked as stopped with a specified reason, such as a manual cancellation or an email unsubscribe request. It moves records in bounded batches, retaining subscription details, website, dates, payment state and cancellation reason. The time of the move is recorded separately.

An additional tool finds overlaps between the working table and the archive by subscription identifier. This separates current processing from accumulated inactive records. No numerical performance improvement was measured for this case study.

Revenue analytics and subscriber value

The analytics dashboard shows how the subscription model performs for each website and billing workflow. Operators can use summaries and charts to examine:

  • total revenue and receipts for the current day;
  • attempt counts, successful charges and decline reasons;
  • daily payment history and the next seven days of planned payments;
  • subscriber groups by signup date, with estimated average revenue per user (ARPU);
  • users grouped by their cumulative payments, filtered by website and signup date;
  • custom job statistics, successful-attempt trends and related cancellations.

The module covers the revenue side of the business. Calculating net profit would also require expenses, fees and other costs. Planned amounts and forecasts are estimates; actual receipts depend on payment outcomes.

Summaries use different cache lifetimes, and website cards load through separate AJAX requests to reduce dashboard load.

Custom billing workflows for individual projects

Nonstandard workflows use parameterised background jobs. Launch parameters include the workflow name, website, amount, bank filter, daily cap, queue dispatch interval and operating hours. The same processing mechanism can serve different project rules.

  1. Select a subscription

    The job checks its operating window and current cap, then selects a suitable record by website, bank, next payment date and availability flags.

  2. Call the payment provider

    A recurring payment is submitted to CloudPayments using a token or to PaySelection using a RebillId. Requests can include receipt information.

  3. Record the result

    The service records the workflow, amount, website and result code. It updates the next processing date and uses selected decline codes to stop further attempts.

Jobs check whether the token has already been processed that day within the relevant workflow. The dashboard shows successful amounts, error reasons and attempt trends. A separate forecast models the daily distribution of jobs using a daily cap and the observed cancellation rate.

Launch parameters are configured through console commands and background jobs. The internal interface is used to monitor and analyse their results.

Technical implementation

LayerImplementation
BackendPHP, Laravel 12, Eloquent and MySQL queries
Payment integrationsCloudPayments API, PaySelection API and notification handlers
Background processingLaravel Jobs, queues and console commands for launching workflows
InterfaceBlade, AJAX and charts; the custom billing dashboard uses Inertia.js and React
Data and loadWorking and archive tables, statistical aggregates and cached summaries

Payment processing runs in background jobs. Controllers prepare dashboard data, while reports draw on operation journals and subscription states.

Outcome

The result is an internal service for recurring payments across multiple projects, covering subscription selection, provider requests, result journals, analytics and planning. The archive reduces the working dataset, reports help assess revenue, and custom jobs support different processing rules.

This project gave me practical Laravel experience at the intersection of payment APIs, queues, subscription lifecycles and analytics.

Implementation questions

Which payment providers are integrated?

CloudPayments and PaySelection. Recurring operations use the provider's token or RebillId, with results recorded in the service journal.

Which subscriber records are archived?

Stopped subscriptions that match the archive selection criteria. Subscription details, website, dates, processing state and stop reason are retained.

Can amounts and schedules differ between workflows?

Yes. Custom jobs accept the amount, website, bank filter, daily cap and operating hours as parameters. They are configured through launch commands, and their results are visible in the dashboard.

Does the analytics module calculate net profit?

It shows revenue, billing results, revenue per user and subscriber cohort metrics. The described module does not deduct expenses and fees to calculate net profit.

Laravel payment integration development

For a similar project, we can discuss provider integration, recurring payment rules, background jobs and reporting requirements.

API integrations and data exchange · Backend and API development · More API integration projects

Discuss your project


Let’s discuss your project

Tell me what you would like to build. I will reply by email.

Or message me on Telegram @ifwcom