Skip to content

Fix Polar webhook processing - #71

Merged
naaiyy merged 3 commits into
mainfrom
agent/fix-polar-webhooks
Aug 14, 2026
Merged

Fix Polar webhook processing#71
naaiyy merged 3 commits into
mainfrom
agent/fix-polar-webhooks

Conversation

@naaiyy

@naaiyy naaiyy commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • verify Polar webhooks with the official SDK against the unmodified request body
  • process billing events through one atomic Convex mutation
  • make delivery and provider-resource handling idempotent
  • reconcile paid orders, refunds, subscriptions, entitlements, and AI credit grants
  • validate production billing configuration at deployment time
  • remove the previous hand-rolled verification and fragmented event-ordering code

Root cause

The previous webhook boundary did not match Polar's signature contract. Repeated non-2xx responses caused Polar to disable the endpoint, and the paid order was not reflected in the BaseBlocks credit ledger.

Impact

Polar deliveries now return 202 after SDK verification and atomic application. Duplicate delivery and duplicate order redelivery cannot grant credits twice. Refund and stale-event ordering is monotonic.

Verification

  • 244 tests passed
  • 495 assertions passed
  • all workspace TypeScript checks passed
  • Biome lint passed across 520 files
  • production endpoint returned 202 for two deliveries
  • production order granted 5,000,000 prepaid units exactly once

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
base-blocks Ready Ready Preview Aug 14, 2026 11:32pm

Request Review

@naaiyy
naaiyy enabled auto-merge (squash) August 14, 2026 23:34
@naaiyy
naaiyy merged commit 1fe56ed into main Aug 14, 2026
9 checks passed
@naaiyy
naaiyy deleted the agent/fix-polar-webhooks branch August 14, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant