Multi-processor payment platform
A single payment layer for a subscription business: two processors behind one contract, every state change recorded, no charge taken twice.
Millions
transactions per month
How it was measured
Payment transactions processed through the platform per calendar month (authorizations, captures, refunds), counted from internal transaction records reconciled against CyberSource and PayPal reports.
99.9%
uptime
How it was measured
Monthly availability of the payment API from production monitoring and health checks over the whole project.
~60%
less time to onboard a new payment provider
How it was measured
Engineering effort to add a payment provider: the integration built before the shared provider contract compared with the next one built on top of it.
On this page
Context
The client sells magazine subscriptions online and has been in business for more than 20 years. Payments run through CyberSource and PayPal.
Two processors mean two APIs, two sets of decline codes and two ways of failing. I worked on the payment platform as a contractor through Valletta Software.
Problem & constraints
- At millions of transactions a month, a rare failure happens every day.
- A charge must never be taken twice, even when a request is retried or a webhook arrives twice.
- PII must stay out of logs, and every change of payment state must be traceable.
- Chargebacks, disputes, failed charges and several currencies are normal operation, not edge cases.
- Adding a payment provider should not mean rewriting business code.
Architecture
Scroll the diagram sideways
Key decisions
One provider contract instead of per-processor code
- Context
- CyberSource and PayPal have different APIs, payment states and decline codes.
- Options considered
- A: keep separate integrations and branch in business code. B: one internal contract with an adapter per processor.
- Trade-offs
- B needs more design up front and hides some processor-specific features. In return, business code talks to one API.
- Outcome
- Chose B. Onboarding a new payment provider takes ~60% less time.
Deduplicate at the webhook boundary
- Context
- PSPs deliver webhooks at least once, and sometimes more than once.
- Options considered
- A: trust each webhook and apply it directly. B: verify the signature, deduplicate, then apply the event.
- Trade-offs
- B adds storage for processed events and one more step before any state change. It makes duplicates and replays harmless.
- Outcome
- Chose B. Webhooks are verified by signature and deduplicated before they touch payment state.
An audit trail for every payment state change
- Context
- Chargebacks and disputes can arrive long after the charge. Someone has to explain what happened.
- Options considered
- A: keep only the current state of a payment. B: record every state change in an audit trail.
- Trade-offs
- B stores more data and needs discipline about what is written: no PII in logs.
- Outcome
- Chose B. Every payment state change is recorded and PII stays out of logs.
Results
- Chargebacks and disputes handled for CyberSource and PayPal.
- Retry rules for failed charges and multi-currency support.
- Audit trail of payment state changes, with PII kept out of logs.
- One v2 transaction API, with several active processors per merchant project.
- Encryption keys moved to a separate database on its own SQL Server, apart from card data.
What I'd do differently
- I would build reconciliation against provider reports into the first release instead of adding it later. It catches mismatches before anyone has to ask about a payment.
- I would design the provider contract from both processors' documentation before writing the first adapter, so the second processor would not force changes to it.
- I would agree with the support team early on what goes into the audit trail, so dispute questions can be answered without extra queries.