{"_id":"@aethex.os/stripe","_rev":"2-05be95dccd09161c21254e2868d35d88","name":"@aethex.os/stripe","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aethex.os/stripe","version":"1.0.0","keywords":["stripe","subscriptions","checkout","webhook","saas","billing","payments","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","_id":"@aethex.os/stripe@1.0.0","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"homepage":"https://aethex.dev","bugs":{"url":"https://github.com/AeThex-Corporation/AeThex-OS/issues"},"dist":{"shasum":"9e82231e45049a2d01c6d40577d9fb56c43da7fa","tarball":"https://registry.npmjs.org/@aethex.os/stripe/-/stripe-1.0.0.tgz","fileCount":14,"integrity":"sha512-1W3x3jIGzkw5/L8npGmPoKcSO3Kb2MXJR6P0Hqluq4wI1ozluFSrw1Xq00tQDTTRi1lauYazsFDophc6cfJDJQ==","signatures":[{"sig":"MEQCIAlFhJI5hHmJ33uvckEw7QmPdYpVV5L9BZQqBKJ1LbOHAiAi8QWXoqBn8u4xllruCUoxXkg6p4lj/4WJtSHEGayNng==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22863},"main":"lib/index.js","types":"lib/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"b094d5c032765a30612c2348ce0356d3a50d9feb","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"repository":{"url":"git+https://github.com/AeThex-Corporation/AeThex-OS.git","type":"git","directory":"packages/aethex-stripe"},"_npmVersion":"11.12.1","description":"Stripe subscription helpers — checkout sessions, billing portal, and webhook event handlers for SaaS apps","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"devDependencies":{"stripe":"^14.0.0","typescript":"^5.3.0","@types/node":"^20.0.0"},"peerDependencies":{"stripe":">=12.0.0"},"_npmOperationalInternal":{"tmp":"tmp/stripe_1.0.0_1777933710602_0.1132356048640426","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aethex.os/stripe","version":"1.0.1","description":"Stripe subscription helpers — checkout sessions, billing portal, and webhook event handlers for SaaS apps","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch"},"keywords":["stripe","subscriptions","checkout","webhook","saas","billing","payments","aethex"],"author":{"name":"AeThex Corporation"},"license":"MIT","homepage":"https://aethex.dev/docs","repository":{"type":"git","url":"git+https://git.aethex.tech/Labs/os.git","directory":"packages/aethex-stripe"},"peerDependencies":{"stripe":">=12.0.0"},"devDependencies":{"@types/node":"^20.0.0","stripe":"^14.0.0","typescript":"^5.3.0"},"engines":{"node":">=18.0.0"},"bugs":{"url":"https://git.aethex.tech/Labs/os/issues"},"_id":"@aethex.os/stripe@1.0.1","gitHead":"6c77abd6440deb925777f64998d4c67a398236e0","_nodeVersion":"22.22.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-nNOdG90IhUaVAxHS8q9R1KwTLLbTSzxdTeBrON6g/ENCDLUkyF1SBNQujColtexc9q3lh94Nz3AXTEzkXclD8g==","shasum":"45995efad5ec29da912154fc0bfc62ba5b60e676","tarball":"https://registry.npmjs.org/@aethex.os/stripe/-/stripe-1.0.1.tgz","fileCount":14,"unpackedSize":22925,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICXFY5M4wc6BDippGzE7pbpJtw6biyrT4AX9gx5UAUPGAiB4+gZqkAjxGxmBK96drCNdFZwS2L561zJYPqhKEwf0Sw=="}]},"_npmUser":{"name":"mrpiglr","email":"mrpiglr@aethex.dev"},"directories":{},"maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/stripe_1.0.1_1783400213361_0.6034340223005541"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-04T22:28:30.496Z","modified":"2026-07-07T04:56:53.636Z","1.0.0":"2026-05-04T22:28:30.729Z","1.0.1":"2026-07-07T04:56:53.499Z"},"bugs":{"url":"https://git.aethex.tech/Labs/os/issues"},"author":{"name":"AeThex Corporation"},"license":"MIT","homepage":"https://aethex.dev/docs","keywords":["stripe","subscriptions","checkout","webhook","saas","billing","payments","aethex"],"repository":{"type":"git","url":"git+https://git.aethex.tech/Labs/os.git","directory":"packages/aethex-stripe"},"description":"Stripe subscription helpers — checkout sessions, billing portal, and webhook event handlers for SaaS apps","maintainers":[{"name":"mrpiglr","email":"mrpiglr@aethex.dev"}],"readme":"# @aethex.os/stripe\n\nStripe subscription helpers for SaaS apps — checkout sessions, billing portal, and webhook event handling in a few lines of code.\n\n## Install\n\n```bash\nnpm install @aethex.os/stripe stripe\n```\n\n## Checkout\n\n```ts\nimport { createStripeClient, createCheckoutSession } from \"@aethex.os/stripe\";\n\nconst stripe = createStripeClient({ stripeSecretKey: process.env.STRIPE_SECRET_KEY! });\n\nconst { url } = await createCheckoutSession(stripe, {\n  customerEmail: user.email,\n  plan: { name: \"Pro\", priceMonthly: 900 }, // $9/mo in cents\n  successUrl: \"https://myapp.com/dashboard?success=1\",\n  cancelUrl: \"https://myapp.com/pricing\",\n  metadata: { userId: user.id, plan: \"pro\" },\n});\n\nres.redirect(url);\n```\n\nUse an existing Stripe Price ID instead of inline pricing:\n\n```ts\nconst { url } = await createCheckoutSession(stripe, {\n  customerId: user.stripeCustomerId,\n  plan: { name: \"Pro\", priceMonthly: 900, priceId: process.env.STRIPE_PRO_PRICE_ID },\n  successUrl: \"https://myapp.com/dashboard\",\n  cancelUrl: \"https://myapp.com/pricing\",\n  metadata: { userId: user.id, plan: \"pro\" },\n  trialDays: 14,\n});\n```\n\n## Billing Portal\n\n```ts\nimport { createBillingPortalSession } from \"@aethex.os/stripe\";\n\nconst url = await createBillingPortalSession(stripe, user.stripeCustomerId, \"https://myapp.com/settings\");\nres.redirect(url);\n```\n\n## Webhooks\n\n```ts\nimport { parseRawBody, constructWebhookEvent, handleSubscriptionEvent } from \"@aethex.os/stripe\";\n\napp.post(\"/webhooks/stripe\", express.raw({ type: \"application/json\" }), async (req, res) => {\n  const rawBody = await parseRawBody(req);\n  const event = constructWebhookEvent(stripe, rawBody, req.headers[\"stripe-signature\"]!, process.env.STRIPE_WEBHOOK_SECRET!);\n\n  await handleSubscriptionEvent(stripe, event, {\n    onCheckoutComplete: async ({ userId, plan, subscriptionId }) => {\n      await db.users.update(userId, { plan, stripeSubscriptionId: subscriptionId });\n    },\n    onSubscriptionUpdated: async ({ userId, plan, status }) => {\n      if (status === \"canceled\") await db.users.update(userId, { plan: \"free\" });\n    },\n    onSubscriptionDeleted: async ({ userId }) => {\n      await db.users.update(userId, { plan: \"free\", stripeSubscriptionId: null });\n    },\n  });\n\n  res.json({ received: true });\n});\n```\n\n## API\n\n### `createStripeClient(config)`\nReturns a configured `Stripe` instance.\n\n### `createOrRetrieveCustomer(stripe, opts)`\nReturns an existing Stripe customer ID or creates a new one.\n\n### `createCheckoutSession(stripe, opts)`\nCreates a Stripe Checkout session. Returns `{ sessionId, url }`.\n\n### `createBillingPortalSession(stripe, customerId, returnUrl)`\nReturns the billing portal URL for a customer.\n\n### `parseRawBody(req)`\nReads the raw request body as a string (needed for webhook signature verification).\n\n### `constructWebhookEvent(stripe, rawBody, signature, secret)`\nVerifies and constructs a `Stripe.Event`.\n\n### `handleSubscriptionEvent(stripe, event, handlers, getUserId?)`\nRoutes a Stripe event to the appropriate handler. Supports `onCheckoutComplete`, `onSubscriptionUpdated`, `onSubscriptionDeleted`, `onPaymentSucceeded`, `onPaymentFailed`.\n\n---\n\nPart of the [`@aethex.os`](https://www.npmjs.com/search?q=%40aethex.os) toolkit.\n","readmeFilename":"README.md"}