{"_id":"@codesled/stripe-payments","_rev":"3-916be8660f7dffea9d1e2651eb18929c","name":"@codesled/stripe-payments","dist-tags":{"latest":"1.0.2"},"versions":{"0.1.0":{"name":"@codesled/stripe-payments","version":"0.1.0","keywords":["stripe","checkout","payments","codesled","subscriptions"],"author":{"name":"CodeSled"},"license":"MIT","_id":"@codesled/stripe-payments@0.1.0","maintainers":[{"name":"codesled","email":"visciijs@gmail.com"}],"dist":{"shasum":"a55dd3b3239f8705e58e79c6a33ec2fdb2eec6f8","tarball":"https://registry.npmjs.org/@codesled/stripe-payments/-/stripe-payments-0.1.0.tgz","fileCount":5,"integrity":"sha512-Nrkl5WACfb6fM2hQZhHfG7BfQsPxF0yhEi2o4VIRlxvlPC1+LyZVbGspgrTCaVjjibkKd4ooO5BReBjY1Zoj7A==","signatures":[{"sig":"MEQCIBVjisZagOjjQsjX+KorVWdMWDL8apkWGGxlj1V0syIvAiBzS7mfJZtS7YflX7piFIXOoiyePzLFcLZadcS0BczGmw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4870},"main":"src/index.js","gitHead":"8f02d2e45a8ba9fe2a7172a4728909ddaa692461","_npmUser":{"name":"codesled","email":"visciijs@gmail.com"},"_npmVersion":"10.9.0","description":"Simple Stripe checkout integration module from CodeSled","directories":{},"_nodeVersion":"22.12.0","dependencies":{"stripe":"^12.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/stripe-payments_0.1.0_1743774698747_0.18217474869788686","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@codesled/stripe-payments","version":"1.0.1","keywords":["stripe","checkout","payments","codesled","subscriptions"],"author":{"name":"CodeSled"},"license":"MIT","_id":"@codesled/stripe-payments@1.0.1","maintainers":[{"name":"codesled","email":"visciijs@gmail.com"}],"dist":{"shasum":"43b1e47857fb850abf425c37a9b702ca3417df07","tarball":"https://registry.npmjs.org/@codesled/stripe-payments/-/stripe-payments-1.0.1.tgz","fileCount":5,"integrity":"sha512-9SEFj/lBEJA7HMTco0S/mjwIN4X1e2M3PuuUxT9Y0hEOC8bL/3MB2DKaWPWIymqQpjTMu86cvNLvgLWHo/15tw==","signatures":[{"sig":"MEUCIHpNl0r7v3+EU6Ub2Jo4rT6G7agnesgyV9lx+fgHkfjFAiEA/8FaNJAxa26NOR5Tc9O5ejmX8xun5qYJsliTk5/sMM4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5117},"main":"src/index.js","gitHead":"8f02d2e45a8ba9fe2a7172a4728909ddaa692461","_npmUser":{"name":"codesled","email":"visciijs@gmail.com"},"_npmVersion":"10.9.0","description":"Simple Stripe checkout integration module from CodeSled","directories":{},"_nodeVersion":"22.12.0","dependencies":{"dotenv":"^16.4.7","stripe":"^12.18.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/stripe-payments_1.0.1_1743778475832_0.22947030033356564","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@codesled/stripe-payments","version":"1.0.2","description":"Simple Stripe checkout integration module from CodeSled","main":"src/index.js","keywords":["stripe","checkout","payments","codesled","subscriptions"],"author":{"name":"CodeSled"},"license":"MIT","dependencies":{"dotenv":"^16.4.7","stripe":"^12.18.0"},"_id":"@codesled/stripe-payments@1.0.2","gitHead":"8f02d2e45a8ba9fe2a7172a4728909ddaa692461","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-sbMsbkEODLKSWNJj7+jM/9G3pA4u2ZiN2pFKy3MxmRqQ9h04TcYORMMsPUp3to/ssp7jaTwcTR9UkWpXduFLwQ==","shasum":"c5dcaa84b495e6d5385056cebce8862062a48e45","tarball":"https://registry.npmjs.org/@codesled/stripe-payments/-/stripe-payments-1.0.2.tgz","fileCount":6,"unpackedSize":6443,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCqU5FfORh0Jj168nD2I3mbRa1mHezZd6gElbd4w2zppgIhAJ8aQfwaQv58oQDg7IOhZePfgBti9DtZOnDlDOZnd9Gv"}]},"_npmUser":{"name":"codesled","email":"visciijs@gmail.com"},"directories":{},"maintainers":[{"name":"codesled","email":"visciijs@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/stripe-payments_1.0.2_1743832604561_0.24649804079857285"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-04T13:51:38.685Z","modified":"2025-04-05T05:56:44.939Z","0.1.0":"2025-04-04T13:51:38.933Z","1.0.1":"2025-04-04T14:54:36.016Z","1.0.2":"2025-04-05T05:56:44.764Z"},"author":{"name":"CodeSled"},"license":"MIT","keywords":["stripe","checkout","payments","codesled","subscriptions"],"description":"Simple Stripe checkout integration module from CodeSled","maintainers":[{"name":"codesled","email":"visciijs@gmail.com"}],"readme":"# @codesled/stripe-payments\r\n\r\nSimple, composable Stripe checkout integration for Node.js applications. Create Stripe Checkout sessions and verify webhooks with minimal setup — no boilerplate, no complexity.\r\n\r\nFramework-agnostic and dev-first. Designed to make payments frictionless to implement.\r\n\r\n> 🚀 Part of the CodeSled developer toolkit — reusable modules that help you build apps faster.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- Create Stripe Checkout sessions with one function\r\n- Supports both **one-time** and **subscription** payments\r\n- Minimal setup with secure defaults\r\n- Verify Stripe webhook signatures\r\n- Compatible with Express, Next.js, or any Node backend\r\n- Plug-and-play — no need to read Stripe docs\r\n- Now supports manual Stripe key initialization with `initStripe()`\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @codesled/stripe-payments\r\n```\r\n\r\n> You must have a Stripe account and access to secret keys.\r\n\r\n---\r\n\r\n## Environment Setup\r\n\r\nCreate a `.env` file (or set env variables) with the following:\r\n\r\n```\r\nSTRIPE_SECRET_KEY=sk_test_...\r\nSTRIPE_WEBHOOK_SECRET=whsec_...\r\n```\r\n\r\nThese values are found in your [Stripe Dashboard](https://dashboard.stripe.com/test/apikeys).\r\n\r\n---\r\n\r\n## Initialization\r\n\r\nYou **must call `initStripe()` once** before using `createCheckoutSession()` or `verifyWebhookSignature()`.\r\n\r\n### Option 1 — Using `.env` (recommended):\r\n\r\n```js\r\nrequire(\"dotenv\").config();\r\nconst { initStripe } = require(\"@codesled/stripe-payments\");\r\n\r\ninitStripe(); // uses STRIPE_SECRET_KEY from .env\r\n```\r\n\r\n### Option 2 — Manual Stripe key:\r\n\r\n```js\r\nconst { initStripe } = require(\"@codesled/stripe-payments\");\r\n\r\ninitStripe(\"sk_test_yourSecretKeyHere\");\r\n```\r\n\r\n---\r\n\r\n## Usage Example\r\n\r\n### Creating a Checkout Session\r\n\r\n```js\r\nconst {\r\n  initStripe,\r\n  createCheckoutSession,\r\n} = require('@codesled/stripe-payments');\r\n\r\ninitStripe(); // or pass the key manually\r\n\r\nconst sessionUrl = await createCheckoutSession({\r\n  priceId: 'price_123',\r\n  successUrl: 'https://yourapp.com/success',\r\n  cancelUrl: 'https://yourapp.com/cancel',\r\n  customerEmail: 'user@example.com',\r\n  mode: 'payment' // \"payment\" for one-time or \"subscription\" for recurring\r\n});\r\n\r\nconsole.log('Redirect to:', sessionUrl);\r\n```\r\n\r\n---\r\n\r\n### Verifying Webhook Events\r\n\r\nUse in a raw body parser route (e.g. in Express or Next.js API route):\r\n\r\n```js\r\nconst {\r\n  initStripe,\r\n  verifyWebhookSignature,\r\n} = require('@codesled/stripe-payments');\r\n\r\ninitStripe(); // or initStripe(\"sk_test_...\")\r\n\r\nconst event = verifyWebhookSignature(req.rawBody, req.headers['stripe-signature']);\r\n\r\n// Handle event type\r\nif (event.type === 'checkout.session.completed') {\r\n  const session = event.data.object;\r\n  console.log('Checkout complete:', session.id);\r\n}\r\n```\r\n\r\n---\r\n\r\n## Functions\r\n\r\n| Function                   | Purpose                                        |\r\n|----------------------------|------------------------------------------------|\r\n| `initStripe()`             | Initializes Stripe with your secret key       |\r\n| `createCheckoutSession()`  | Generate a hosted Stripe Checkout session URL |\r\n| `verifyWebhookSignature()` | Validate incoming webhook using Stripe secret |\r\n\r\n---\r\n\r\n## Notes\r\n\r\n- Supports both **subscription mode** and **one-time mode** via the `mode` option.\r\n- Requires raw body middleware for webhook validation (e.g., `express.raw({ type: 'application/json' })`).\r\n- `initStripe()` must be called before any other function.\r\n\r\n---\r\n\r\n## Local Testing\r\n\r\nUse Stripe CLI or Dashboard to trigger test webhooks:\r\n\r\n```bash\r\nstripe listen --forward-to localhost:3000/webhook\r\n```\r\n\r\n---\r\n\r\n## Why Use This Package?\r\n\r\nStripe is powerful, but overkill for simple needs. This package abstracts away Stripe’s verbose API and lets you:\r\n\r\n- 🚫 Avoid boilerplate\r\n- 🧐 Skip reading docs\r\n- 🧹 Reuse across all CodeSled apps\r\n\r\nFocus on shipping — we handle the payment logic.\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT — Free to use, share, and build on.\r\n\r\n---\r\n\r\n## About CodeSled\r\n\r\n**CodeSled** is a modular developer toolkit — reusable code blocks for core app functionality (auth, payments, CMS, and more). Build faster. Ship smarter.\r\n\r\n> Follow [@codesled](https://github.com/code-sled) for updates.\r\n\r\n","readmeFilename":"README.md"}