PaymentsSenior Backend Engineerteam: 5-12 engineers, depending on the project stageclient: Payment gateway for subscription e-commerceDetails anonymized (NDA)

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.

Nov 2023May 2025

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
  1. 01Context
  2. 02Problem & constraints
  3. 03Architecture
  4. 04Key decisions
  5. 05Results
  6. 06What I'd do differently
  7. 07Stack
01

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.

02

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.
03

Architecture

Scroll the diagram sideways

fig. 01: Payment flow. One contract in front of two processors, webhooks verified and deduplicated, every state change written to the audit trail.From Storefront and billing jobs to Payment API. From Payment API to Routing. From Routing to CyberSource. From Routing to PayPal. From Payment API to Payment state. From the processors to Webhook ingress, as webhooks. From Webhook ingress to Payment state, after verification. From Payment state to Audit trail, on every change. From Webhook ingress to Chargebacks and disputes. From Chargebacks and disputes to Audit trailStorefrontand billing jobsPayment APIone provider contractRoutingby configCyberSourcePayPalPayment statestate machine, retriesWebhook ingressverify signature · deduplicateAudit trailstate changes · no PIIChargebacks and disputeshandled for both processorswebhooks
fig. 01Payment flow. One contract in front of two processors, webhooks verified and deduplicated, every state change written to the audit trail.
04

Key decisions

DR-01

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.
DR-02

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.
DR-03

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.
05

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.
06

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.
07

Stack

  • C#
  • .NET
  • ASP.NET Core
  • SQL Server
  • Dapper
  • Redis
  • IdentityServer
  • CyberSource
  • PayPal
  • Webhooks
  • AWS