refactor(stripe): consume dunite-stripe StripeService (DEV-515 pt 2) #450
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/DEV-515-consume-stripe-service"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Consumer side of DEV-515 part 2. dunite PR #30 moved the async-stripe
StripeServiceinto the shareddunite-stripecrate; this drops bunyip's copy and re-exports the shared one, so a8n-tools and bunyip drive one Stripe client instead of two that drift.What changed
crates/bunyip-domain/src/services/stripe.rsloses ~1400 lines (the whole async-stripe service body plus its tests, which now live in the crate) and becomes a re-export ofStripeService/StripeConfig/StripeServiceErrorplus the bits that are genuinely bunyip's.crate::services::stripe::*import paths are unchanged for every caller.StripeConfig::from_env/from_db_modelbecome the free functionsstripe_config_from_env/stripe_config_from_db_model, sinceStripeConfigis now a foreign type. They stay bunyip-side because they use the{NAME}_FILEcompose-secret convention, thebunyipapp-tag default, theCORS_ORIGIN-derived checkout URLs, and bunyip'sEncryptionKeySetfor secret decryption.StripeServicecall sites across admin, admin_stripe, billing, membership and webhook gain.map_err(stripe_err).dunite-stripepinned at rev41dbbeb(an ancestor of dunite main since #30 merged).Why a neutral error and not
AppErrorThe crate returns its own
StripeServiceErrorandstripe_errmaps it toAppErrorat each call site. Returningdunite_core::AppErrorfrom the crate was tried on a branch and reverted: a path dep on dunite-core forces every git consumer to unify its own dunite-core to the rev dunite-stripe pins, which cascades through dunite-download/oci/oidc and would drag unmerged dunite-oidc changes into bunyip-oidc. A blanketFrom<StripeServiceError> for AppErroris impossible either way, both types being foreign to bunyip (orphan rule), so the.map_errat the call sites is the cost of the decoupling.stripe_errpreserves the variant, so no endpoint changes status code or body.Verification
cargo clippy --workspace --all-targets -- -D warningscleancargo fmt --all --checkcleancargo test --workspace --lib: 294 + 108 + 15 + 9 passed, 0 failed (includes the moved config tests and a newstripe_err_maps_variants)🤖 Generated with Claude Code
https://claude.ai/code/session_01CGnY8JKXCgH2jiUSqH6g4x
Deletes the 1400-line async-stripe service body from bunyip-domain and re-exports `StripeService` / `StripeConfig` from the shared `dunite-stripe` crate, so a8n-tools and bunyip drive the same Stripe client instead of two drifting copies. `crate::services::stripe::*` import paths are unchanged for every caller. What stays bunyip-side is the part that is genuinely bunyip's: `stripe_config_from_env` (uses the `{NAME}_FILE` compose-secret convention, the `bunyip` app-tag default, and the `CORS_ORIGIN`-derived checkout URLs) and `stripe_config_from_db_model` (decrypts with bunyip's `EncryptionKeySet`). Both were inherent `StripeConfig::from_*` constructors before; they become free functions because `StripeConfig` is now a foreign type. The crate returns a neutral `StripeServiceError` rather than `dunite_core::AppError`, and `stripe_err` maps it at the call sites. Returning `AppError` was tried and reverted: it forces the consumer's `dunite-core` rev to unify with the one `dunite-stripe` pins, which cascades through dunite-download/oci/oidc and drags unmerged dunite-oidc changes into bunyip-oidc. A blanket `From<StripeServiceError> for AppError` is impossible either way (orphan rule, both types foreign). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGnY8JKXCgH2jiUSqH6g4x