{"_id":"@bagou/payment-stripe","_rev":"4-3d327d8509da9170b8ba066ac2778542","name":"@bagou/payment-stripe","dist-tags":{"latest":"0.4.0"},"versions":{"0.0.1":{"name":"@bagou/payment-stripe","version":"0.0.1","keywords":["bagou","bun","checkout","payment","stripe","subscription","typescript","webhook"],"license":"MIT","_id":"@bagou/payment-stripe@0.0.1","maintainers":[{"name":"bagouco","email":"admin@bagou.co"}],"dist":{"shasum":"2dae26e89be19d91173fbbb44f309a2e1b885d0e","tarball":"https://registry.npmjs.org/@bagou/payment-stripe/-/payment-stripe-0.0.1.tgz","fileCount":6,"integrity":"sha512-RlIr3zRJ6qHNrg2anDC7HeIt0fEUwCi78cScqRPA5iwZ3D5mESTM8HY2+x42jwVm6ls2SSg4O+7hBrHwnlBkhg==","signatures":[{"sig":"MEUCIFONckOzpA+vfAUl83R4sQpxSN4ZpYX77PE5sNJMcmkRAiEAvYC6VaK4LTSTM9y056vI3ZpR9g9guIi5R9mFIh5M4aM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":92756},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"2dae26e89be19d91173fbbb44f309a2e1b885d0e","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./package.json":"./package.json"},"scripts":{"lint":"tsgo --noEmit && bunx biome lint","test":"bun test tests","build":"bunup","npm:publish":"bun publish --tolerate-republish --force --production --access public"},"_npmUser":{"name":"bagouco","email":"admin@bagou.co"},"_integrity":"sha512-RlIr3zRJ6qHNrg2anDC7HeIt0fEUwCi78cScqRPA5iwZ3D5mESTM8HY2+x42jwVm6ls2SSg4O+7hBrHwnlBkhg==","_npmVersion":"10.8.3","description":"Stripe payment abstractions (StripeClient, CheckoutSession, WebhookEvent) for bagou-packages","directories":{},"_nodeVersion":"24.3.0","dependencies":{"stripe":"^17.7.0","@ooneex/payment":"^1.1.11","@ooneex/container":"^1.5.1"},"_hasShrinkwrap":false,"devDependencies":{"@ooneex/types":"^1.3.7","@ooneex/currencies":"^1.1.12"},"_npmOperationalInternal":{"tmp":"tmp/payment-stripe_0.0.1_1777890400902_0.6684439547757441","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@bagou/payment-stripe","version":"0.2.0","keywords":["bagou","bun","checkout","payment","stripe","subscription","typescript","webhook"],"license":"MIT","_id":"@bagou/payment-stripe@0.2.0","maintainers":[{"name":"bagouco","email":"admin@bagou.co"}],"dist":{"shasum":"14f4684027ecd4ed89c0eef3db29e5b3aa2639ed","tarball":"https://registry.npmjs.org/@bagou/payment-stripe/-/payment-stripe-0.2.0.tgz","fileCount":6,"integrity":"sha512-fLtOADZZrP6g9ja4rpcPmdAX8OXhDl+FIBxQMRi1N2BTHd0qp3r1oOLvdG9zG0IE6w7KC/GlaOKm3kwZobVZEg==","signatures":[{"sig":"MEQCIDcMoR8XLZDL/OcvUXZ7cKajYfFXQmkcg0Jlp41RjyfLAiBWrT3sKkwClwEjpYFGwd+3DC+x9Rv5rAMMBt13kQeXeA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":92998},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"14f4684027ecd4ed89c0eef3db29e5b3aa2639ed","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./package.json":"./package.json"},"scripts":{"lint":"tsgo --noEmit && bunx biome lint","test":"bun test tests","build":"bunup","npm:publish":"bun publish --tolerate-republish --force --production --access public"},"_npmUser":{"name":"bagouco","email":"admin@bagou.co"},"_integrity":"sha512-fLtOADZZrP6g9ja4rpcPmdAX8OXhDl+FIBxQMRi1N2BTHd0qp3r1oOLvdG9zG0IE6w7KC/GlaOKm3kwZobVZEg==","_npmVersion":"10.8.3","description":"Stripe payment abstractions (StripeClient, CheckoutSession, WebhookEvent) for bagou-packages","directories":{},"_nodeVersion":"24.3.0","dependencies":{"stripe":"^17.7.0","@ooneex/payment":"^1.1.11","@ooneex/container":"^1.5.1"},"_hasShrinkwrap":false,"devDependencies":{"@ooneex/types":"^1.3.7","@ooneex/currencies":"^1.1.12"},"_npmOperationalInternal":{"tmp":"tmp/payment-stripe_0.2.0_1782837912955_0.6236957559370233","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@bagou/payment-stripe","version":"0.3.0","keywords":["bagou","bun","checkout","payment","stripe","subscription","typescript","webhook"],"license":"MIT","_id":"@bagou/payment-stripe@0.3.0","maintainers":[{"name":"bagouco","email":"admin@bagou.co"}],"dist":{"shasum":"2c12f19f74e49ff016a174897f087dc3300fc033","tarball":"https://registry.npmjs.org/@bagou/payment-stripe/-/payment-stripe-0.3.0.tgz","fileCount":6,"integrity":"sha512-Cuswtr8Ul9L7XKc1fJPZKdE5H/hHWzdF5kaZ5RS4pKE1cqtawaKFMzx8jwj9ohDRj3qlcnx5lWUDi/68mr32oA==","signatures":[{"sig":"MEQCIAM28oDTASHYkNiSwu8Vs8SlO4b6r55KEc40rFDt6ADrAiBeL143Zx28bdqhiBJwtQ2pNdbQAO5gTlSDLx2SJ1JgkQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQD0gbh+6dDiE0Xlkcai9zHUKKvaUOUyUe2LGThjjXra6AIgaDbqd5Zy/Y97PtD27qWWyMyJUB7N19VtwmSuOr2MZV4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":96808},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"2c12f19f74e49ff016a174897f087dc3300fc033","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./package.json":"./package.json"},"scripts":{"lint":"tsgo --noEmit && bunx biome lint","test":"bun test tests","build":"bunup","npm:publish":"bun publish --tolerate-republish --force --production --access public"},"_npmUser":{"name":"bagouco","email":"admin@bagou.co"},"_integrity":"sha512-Cuswtr8Ul9L7XKc1fJPZKdE5H/hHWzdF5kaZ5RS4pKE1cqtawaKFMzx8jwj9ohDRj3qlcnx5lWUDi/68mr32oA==","_npmVersion":"10.8.3","description":"Stripe payment abstractions (StripeClient, CheckoutSession, WebhookEvent) for bagou-packages","directories":{},"_nodeVersion":"24.3.0","dependencies":{"stripe":"^17.7.0","@ooneex/payment":"^1.1.11","@ooneex/container":"^1.5.1"},"_hasShrinkwrap":false,"devDependencies":{"@ooneex/types":"^1.3.7","@ooneex/currencies":"^1.1.12"},"_npmOperationalInternal":{"tmp":"tmp/payment-stripe_0.3.0_1790412043313_0.5560482890765523","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"_id":"@bagou/payment-stripe@0.4.0","dist":{"shasum":"9820b3cdef7d15626a86c9a60d10f913be8920fe","tarball":"https://registry.npmjs.org/@bagou/payment-stripe/-/payment-stripe-0.4.0.tgz","fileCount":6,"integrity":"sha512-8kYgw0LM9Bv2aXNNxhKV0mUhZPS11am1PhUzlOwkHq2kkV7QTKXdskUGZ2c3Txaahn7CnGKeh48Vr562QBEd8w==","signatures":[{"sig":"MEUCIBDV5AtHm5WiXSdk4UKN8dELlGqviBA/fK7TZQQVgGBLAiEAqigf5XwWZsEXm1jV2DHQ/18GX5gs92tTykukWJojs8s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGwC/EJeI9LwYD21ImiZMOpuskTrH3qwlu0wExtSWUmXAiEAnZiT6O6/MeTuuiLUkwXjfMW6Z5XLuBlzuEv5PSGVK+c="}],"unpackedSize":98687},"name":"@bagou/payment-stripe","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"9820b3cdef7d15626a86c9a60d10f913be8920fe","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./package.json":"./package.json"},"license":"MIT","scripts":{"lint":"tsgo --noEmit && bunx biome lint","test":"bun test tests","build":"bunup","npm:publish":"bun publish --tolerate-republish --force --production --access public"},"version":"0.4.0","_npmUser":{"name":"bagouco","email":"admin@bagou.co"},"keywords":["bagou","bun","checkout","payment","stripe","subscription","typescript","webhook"],"_integrity":"sha512-8kYgw0LM9Bv2aXNNxhKV0mUhZPS11am1PhUzlOwkHq2kkV7QTKXdskUGZ2c3Txaahn7CnGKeh48Vr562QBEd8w==","_npmVersion":"10.8.3","description":"Stripe payment abstractions (StripeClient, CheckoutSession, WebhookEvent) for bagou-packages","directories":{},"maintainers":[{"name":"bagouco","email":"admin@bagou.co"}],"_nodeVersion":"24.3.0","dependencies":{"stripe":"^17.7.0","@ooneex/payment":"^1.1.11","@ooneex/container":"^1.5.1"},"_hasShrinkwrap":false,"devDependencies":{"@ooneex/types":"^1.3.7","@ooneex/currencies":"^1.1.12"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/payment-stripe_0.4.0_1790412443100_0.9963068639898474"}}},"time":{"created":"2026-05-04T10:26:40.756Z","modified":"2026-09-26T08:47:23.342Z","0.0.1":"2026-05-04T10:26:41.033Z","0.2.0":"2026-06-30T16:45:13.092Z","0.3.0":"2026-09-26T08:40:43.387Z","0.4.0":"2026-09-26T08:47:23.172Z"},"license":"MIT","keywords":["bagou","bun","checkout","payment","stripe","subscription","typescript","webhook"],"description":"Stripe payment abstractions (StripeClient, CheckoutSession, WebhookEvent) for bagou-packages","maintainers":[{"name":"bagouco","email":"admin@bagou.co"}],"readme":"# @bagou/payment-stripe\n\n> Part of the [bagou-packages](../../README.md) monorepo.\n\nStripe payment abstractions built on top of the official Stripe SDK. Covers checkout sessions, webhooks, customers, subscriptions, products, discounts, and analytics — all with typed, injectable services.\n\n## Install\n\n```sh\nbun add @bagou/payment-stripe\n```\n\nSet `STRIPE_SECRET_KEY` in your environment (e.g. via `.env`):\n\n```env\nSTRIPE_SECRET_KEY=sk_live_xxx\nSTRIPE_WEBHOOK_SECRET=whsec_xxx\n```\n\n## Services\n\n| Class | Responsibility |\n|-------|---------------|\n| `StripeClient` | Holds the authenticated Stripe SDK instance |\n| `StripeProvider` | High-level facade — checkout + webhooks |\n| `StripeCheckoutSession` | Create and retrieve Checkout Sessions |\n| `StripeWebhookEvent` | Verify and parse incoming webhook events |\n| `StripeCustomer` | Customer CRUD + listing |\n| `StripeCustomerPortal` | Create Billing Portal sessions |\n| `StripeDiscount` | Coupon / promo-code management |\n| `StripeProducts` | Product and price CRUD |\n| `StripeAnalytics` | Revenue and subscription summary |\n\n## Usage\n\n### Checkout session\n\n```ts\nimport { StripeProvider } from \"@bagou/payment-stripe\";\n\nconst provider = new StripeProvider();\n\nconst session = await provider.createCheckoutSession({\n  lineItems: [{ price: \"price_xxx\", quantity: 1 }],\n  mode: \"subscription\",\n  successUrl: \"https://example.com/success\",\n  cancelUrl: \"https://example.com/cancel\",\n});\n\nconst retrieved = await provider.retrieveSession(session.id);\n```\n\n#### Invoices, billing address and tax ID\n\nA one-time payment (`mode: \"payment\"`) only produces a receipt unless `invoiceCreation` is set; subscriptions always get an invoice per cycle. Collect the billing address and VAT number to print them on the invoice (B2B):\n\n```ts\nawait provider.createCheckoutSession({\n  lineItems: [{ price: \"price_xxx\", quantity: 1 }],\n  mode: \"payment\",\n  successUrl: \"https://example.com/success\",\n  customerId: \"cus_xxx\",\n  invoiceCreation: { metadata: { orderId: \"ord_123\" } }, // or `true`\n  billingAddressCollection: \"required\",\n  taxIdCollection: true,\n});\n```\n\n| Option | Stripe parameter | Default |\n|---|---|---|\n| `allowPromotionCodes` | `allow_promotion_codes` | `true` |\n| `invoiceCreation` | `invoice_creation` (ignored outside `payment` mode) | off |\n| `billingAddressCollection` | `billing_address_collection` | Stripe default (`auto`) |\n| `taxIdCollection` | `tax_id_collection` | off |\n| `locale` | `locale` (checkout page language) | Stripe default (`auto`) |\n\nWith an existing `customerId`, address or tax ID collection also sets `customer_update` so the collected details are saved on the customer.\n\n#### Language of invoices and emails\n\nStripe writes invoices, receipts and customer emails in the customer's `preferredLocales`. Set it when creating or updating the customer:\n\n```ts\nawait customers.create({ email: \"jane@example.com\", preferredLocales: [\"fr\"] });\nawait customers.update(\"cus_xxx\", { preferredLocales: [\"en\"] });\n```\n\n### Webhook verification\n\n```ts\nconst event = await provider.constructWebhookEvent(\n  rawBody,\n  stripeSignatureHeader,\n  process.env.STRIPE_WEBHOOK_SECRET!,\n);\n\nif (event.type === \"checkout.session.completed\") {\n  const data = event.data; // CheckoutSessionCompletedDataType\n}\n```\n\n### Customers\n\n```ts\nimport { StripeClient, StripeCustomer } from \"@bagou/payment-stripe\";\n\nconst customer = new StripeCustomer(new StripeClient());\n\nconst created = await customer.create({ email: \"user@example.com\", name: \"Alice\" });\nconst updated = await customer.update(created.id, { name: \"Alice B.\" });\nconst found   = await customer.get(created.id);\nconst list    = await customer.list({ limit: 20 });\nawait customer.remove(created.id);\n```\n\n### Billing Portal\n\n```ts\nimport { StripeClient, StripeCustomerPortal } from \"@bagou/payment-stripe\";\n\nconst portal = new StripeCustomerPortal(new StripeClient());\n\nconst session = await portal.create({\n  customerId: \"cus_xxx\",\n  returnUrl: \"https://example.com/account\",\n});\n\n// Redirect the user to session.url\n```\n\n### Discounts (coupons)\n\n```ts\nimport { StripeClient, StripeDiscount } from \"@bagou/payment-stripe\";\n\nconst discount = new StripeDiscount(new StripeClient());\n\nconst coupon = await discount.create({\n  name: \"SUMMER20\",\n  type: \"percentage\",\n  amount: 20,\n  duration: \"once\",\n  code: \"SUMMER20\",\n});\n```\n\n### Products & prices\n\n```ts\nimport { StripeClient, StripeProducts } from \"@bagou/payment-stripe\";\n\nconst products = new StripeProducts(new StripeClient());\n\nconst product = await products.create({ name: \"Pro Plan\" });\n\nconst price = await products.createPrice({\n  productId: product.id,\n  currency: \"eur\",\n  unitAmount: 1999,\n  type: \"recurring\",\n  interval: \"month\",\n});\n```\n\n### Analytics\n\n```ts\nimport { StripeClient, StripeAnalytics } from \"@bagou/payment-stripe\";\n\nconst analytics = new StripeAnalytics(new StripeClient());\n\nconst summary = await analytics.get({\n  startDate: new Date(\"2025-01-01\"),\n  endDate: new Date(\"2025-12-31\"),\n  currency: \"eur\",\n});\n\nconsole.log(summary.totalRevenue, summary.activeSubscriptions);\n```\n\n## Supported Webhook Events\n\n| Event | Type constant |\n|-------|--------------|\n| `checkout.session.completed` | `EStripeEvent.CheckoutSessionCompleted` |\n| `invoice.paid` | `EStripeEvent.InvoicePaid` |\n| `customer.subscription.deleted` | `EStripeEvent.CustomerSubscriptionDeleted` |\n| `customer.subscription.updated` | `EStripeEvent.CustomerSubscriptionUpdated` |\n| `payment_intent.payment_failed` | `EStripeEvent.PaymentIntentPaymentFailed` |\n\n## License\n\nMIT © Bagou\n","readmeFilename":"README.md"}