Skip to content

feat: bulk subscription import and Shopify, Stripe, Circle billing adapters - #2331

Merged
github-actions[bot] merged 6 commits into
Smartdevs17:mainfrom
Mrwicks00:claude/intelligent-ritchie-3b5c7f
Nov 25, 2026
Merged

github-actions[bot] merged 6 commits into
Smartdevs17:mainfrom
Mrwicks00:claude/intelligent-ritchie-3b5c7f

Conversation

@Mrwicks00

Copy link
Copy Markdown
Contributor

feat: bulk subscription import + Shopify, Stripe and Circle billing adapters

Closes #1960
Closes #1961
Closes #1963
Closes #1965

Summary

Issue What shipped Where
#1960 Bulk CSV import with duplicate detection and per-row errors, as a service and a CLI command backend/src/services/import.ts, bin/subtrackr.js, docs/bulk-import.md
#1961 Shopify App Subscription billing adapter with idempotent retries backend/src/gateways/shopify.ts
#1963 Stripe subscription adapter with proration on plan change backend/src/gateways/stripe.ts
#1965 Circle USDC adapter with webhook verification and reconciliation backend/src/gateways/circle.ts

Details

#1960 Bulk import

  • subtrackr subscriptions import <file.csv> [--dry-run] [--format json].
  • Every row gets its own result (created, would_create, duplicate, error) with the line number and field-level errors. One bad row never blocks the others.
  • Duplicates are matched on name (case/space-insensitive) + currency + billing cycle, against existing subscriptions and earlier rows in the same file. Re-running a file is safe.
  • RFC 4180 CSV (quotes, escaped quotes, embedded newlines, CRLF, BOM), 1000-row cap, integer minor-unit prices, strict date validation.
  • Observability: one structured summary log per import, plus a warning for ignored columns.

#1961 Shopify

  • createShopifyBillingAdapter: create, cancel and fetch app subscriptions over Admin GraphQL.
  • Shopify has no idempotency header, so one result is kept per caller key. Concurrent and repeated calls share one request. Failures are not cached.
  • THROTTLED, 429, 5xx and transport errors are retried with backoff; userErrors are non-retryable.

#1963 Stripe

  • createStripeSubscriptionAdapter: create, change plan, preview, cancel and fetch.
  • calculateProration is pure and integer-only (credit for unused old plan, charge for remaining new plan, half-up rounding). changePlan sends the same proration_date to Stripe, so the preview matches the invoice.
  • Retries reuse the same idempotency key, so a retry cannot double-apply a plan change.

#1965 Circle

  • createCircleAdapter (micro-USDC integers internally, decimal strings on the wire).
  • verifyCircleWebhook: ECDSA-SHA256 signature check against the key named by X-Circle-Key-Id.
  • applyCircleEvent: idempotent by notification id; statuses only move forward; amount mismatches are flagged and never applied.
  • reconcileCirclePayments: polls Circle for stale unsettled payments and reports { checked, updated, mismatched, errors }; one failed lookup does not abort the sweep.

Shared change (kept minimal): billingAdapter.ts gains an exported withIdempotentRetry helper, a GatewayProvider type (adds shopify and circle to error/telemetry typing) and a cancel operation. Existing behaviour is unchanged.

Testing

  • 85 new tests, all passing (the 14 existing Shopify webhook tests still pass too): import.test.ts, importCli.test.ts (runs the real CLI against a local fake API), stripe.test.ts, shopifyBilling.test.ts, circle.test.ts.
  • Prettier check passes on every changed file; ESLint reports no errors in the new or changed .ts files; tsc --noEmit reports no errors in them.
  • Commits follow the repo's commitlint rules.

Known pre-existing issues (not touched)

Both fail identically on a clean main and are unrelated to this PR:

  • billingAdapter.test.ts › "maps HTTP 402 to PROVIDER_REJECTED" expects PROVIDER_REJECTED but the existing classifier returns UNKNOWN.
  • certificatePinning.test.ts imports vitest but runs under the Jest backend config.

Checklist

  • Lint: Prettier clean; no ESLint errors in new/changed TypeScript
  • Type Check: no new tsc errors
  • Tests: new tests pass (pre-existing failures listed above)
  • New code has appropriate TypeScript types
  • No hardcoded secrets or credentials
  • New features have corresponding tests
  • Documentation updated (docs/bulk-import.md, backend/src/gateways/README.md)
  • Rust format/clippy/tests/build: not applicable, no contract changes

@drips-wave

drips-wave Bot commented Nov 25, 2026

Copy link
Copy Markdown

@Mrwicks00 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@github-actions
github-actions Bot merged commit 477316b into Smartdevs17:main Nov 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant