The problem

I worked on a subscription integration with webhook events and older callbacks that could both change account access. I needed to handle retries after failures and distinguish existing-account upgrades from new purchases.

Transactions and retries

I extended the webhook handlers for purchases, upgrades, renewals, cancellations, and expirations. I put the database changes and the event’s processed state inside the same transaction.

I added tests for a failed renewal followed by a successful retry, checking that the handler rolled back the failed attempt and committed the retry.

For upgrades, I added handling and regression tests for adding subscriptions to existing users. I checked that the handler rejected invalid account and event combinations before recording changes.

Legacy callbacks

I worked on changing the legacy callback path to observation-only behaviour. I preserved its response contract, with the aim of leaving access changes to the webhook handlers.

In production records, I traced callbacks that the integration had received but could not match to managed subscriptions. Those mapping gaps required reconciliation outside the transaction handling.

Transaction limits

I used transactions to keep the local database changes together. They do not guarantee exactly-once processing across an external payment provider.