{"_id":"@invertase/firestore-stripe-payments","_rev":"5-5f5d053f7f227d7cc38b24a8ddfa25f3","name":"@invertase/firestore-stripe-payments","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.6":{"name":"@invertase/firestore-stripe-payments","version":"0.0.6","keywords":["firebase","payments","subscriptions","stripe"],"author":{"url":"https://stripe.com/","name":"Stripe"},"license":"Apache-2.0","_id":"@invertase/firestore-stripe-payments@0.0.6","maintainers":[{"name":"dackers86","email":"darren@invertase.io"},{"name":"salakar","email":"mike.diarmid@gmail.com"},{"name":"ehesp","email":"elliot.hesp@gmail.com"}],"contributors":[{"url":"https://firebase.google.com/","name":"Firebase","email":"firebase-support@google.com"}],"dist":{"shasum":"e7b51111cd113d57c1b569b72c7c156f28984222","tarball":"https://registry.npmjs.org/@invertase/firestore-stripe-payments/-/firestore-stripe-payments-0.0.6.tgz","fileCount":36,"integrity":"sha512-a4xXavNMowOEBlnxibdwQYf6hWlTfHvxtRfrG/A5Jx9ChuBR7DwZSwQ330U+JsQbUUnF5WjUd4PsWc2aA+xvtA==","signatures":[{"sig":"MEUCIESmMwkp/AOXEcI+/KCt6gPn91WatqR5YKDwRmuXRQEcAiEA/FDVHy2F+oHQ2sjG5jIGPN0YixbeWfbYsayO2YDgZI8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":200289},"main":"./lib/index.js","gitHead":"ffd8a4bc64dc4f1e1d596f4acc0b5f2e5271b2f1","scripts":{"test":"cd _emulator && firebase emulators:exec --project=demo-test 'NODE_OPTIONS=--openssl-legacy-provider npm run test:unit' && exit 0","build":"tsc","postbuild":"node ./postbuild.js","test:unit":"karma start --single-run","api-extractor":"api-extractor run --verbose","api-documenter":"api-documenter markdown --input-folder temp --output-folder markdown","api-extractor:local":"npm run build && api-extractor run --local --verbose"},"typings":"./lib/index.d.ts","_npmUser":{"name":"dackers86","email":"darren@invertase.io"},"_npmVersion":"8.5.0","description":"Client SDK for the firestore-stripe-payments Firebase Extension","directories":{},"_nodeVersion":"18.17.0","dependencies":{"@firebase/app":"^0.7.5","@firebase/auth":"^0.17.2","@firebase/firestore":"^3.2.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","karma":"^6.3.4","mocha":"^9.1.1","sinon":"^11.1.2","ts-node":"^10.2.1","webpack":"^4.46.0","chai-like":"^1.1.1","ts-loader":"^8.3.0","sinon-chai":"^3.7.0","typescript":"^4.4.2","@types/chai":"^4.2.21","karma-mocha":"^2.0.1","@types/mocha":"^9.0.0","@types/sinon":"10.0.6","karma-webpack":"^4.0.2","firebase-tools":"^9.18.0","replace-in-file":"^6.2.0","@types/chai-like":"^1.1.1","chai-as-promised":"^7.1.1","@types/sinon-chai":"^3.2.5","source-map-loader":"^1.1.3","karma-mocha-reporter":"^2.2.5","karma-chrome-launcher":"^3.1.0","karma-sourcemap-loader":"^0.3.8","@types/chai-as-promised":"^7.1.4","@microsoft/api-extractor":"^7.18.17","@microsoft/api-documenter":"^7.13.65"},"_npmOperationalInternal":{"tmp":"tmp/firestore-stripe-payments_0.0.6_1693420942541_0.006803041971031876","host":"s3://npm-registry-packages"}},"0.0.7":{"name":"@invertase/firestore-stripe-payments","version":"0.0.7","keywords":["firebase","payments","subscriptions","stripe"],"author":{"url":"https://stripe.com/","name":"Stripe"},"license":"Apache-2.0","_id":"@invertase/firestore-stripe-payments@0.0.7","maintainers":[{"name":"dackers86","email":"darren@invertase.io"},{"name":"salakar","email":"mike.diarmid@gmail.com"},{"name":"ehesp","email":"elliot.hesp@gmail.com"}],"contributors":[{"url":"https://firebase.google.com/","name":"Firebase","email":"firebase-support@google.com"}],"dist":{"shasum":"36da9333967e05f94ad40d720c2912576cf9e2a8","tarball":"https://registry.npmjs.org/@invertase/firestore-stripe-payments/-/firestore-stripe-payments-0.0.7.tgz","fileCount":36,"integrity":"sha512-J4R49Z+x13hqQ6wX+xoglnDuwTvAbXMmOJaL8LcqRo2NFRjBEs8zWh5mUvDVwvlRV4ABnYzjzm/t4+wuOIfBPg==","signatures":[{"sig":"MEUCIA+pkBvbNGCtqa2LXo+kEdhn+DDfSxdGZjAl4UkT2JhgAiEAnTP15px8dECnnhGWkVvW0wur1lJeZPOjM0BDVDZw76w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":200310},"main":"./lib/index.js","gitHead":"e570802294cbe59125f57eba9b53a8ccc082d895","scripts":{"test":"cd _emulator && firebase emulators:exec --project=demo-test 'NODE_OPTIONS=--openssl-legacy-provider npm run test:unit' && exit 0","build":"tsc","postbuild":"node ./postbuild.js","test:unit":"karma start --single-run","api-extractor":"api-extractor run --verbose","api-documenter":"api-documenter markdown --input-folder temp --output-folder markdown","api-extractor:local":"npm run build && api-extractor run --local --verbose"},"typings":"./lib/index.d.ts","_npmUser":{"name":"dackers86","email":"darren@invertase.io"},"_npmVersion":"8.5.0","description":"Client SDK for the firestore-stripe-payments Firebase Extension","directories":{},"_nodeVersion":"18.17.0","dependencies":{"@firebase/app":"^0.7.5","@firebase/auth":"^0.17.2","@firebase/firestore":"^3.2.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.4","karma":"^6.3.4","mocha":"^9.1.1","sinon":"^11.1.2","ts-node":"^10.2.1","webpack":"^4.46.0","chai-like":"^1.1.1","ts-loader":"^8.3.0","sinon-chai":"^3.7.0","typescript":"^4.4.2","@types/chai":"^4.2.21","karma-mocha":"^2.0.1","@types/mocha":"^9.0.0","@types/sinon":"10.0.6","karma-webpack":"^4.0.2","firebase-tools":"^9.18.0","replace-in-file":"^6.2.0","@types/chai-like":"^1.1.1","chai-as-promised":"^7.1.1","@types/sinon-chai":"^3.2.5","source-map-loader":"^1.1.3","karma-mocha-reporter":"^2.2.5","karma-chrome-launcher":"^3.1.0","karma-sourcemap-loader":"^0.3.8","@types/chai-as-promised":"^7.1.4","@microsoft/api-extractor":"^7.18.17","@microsoft/api-documenter":"^7.13.65"},"_npmOperationalInternal":{"tmp":"tmp/firestore-stripe-payments_0.0.7_1693421840234_0.26698251941152806","host":"s3://npm-registry-packages"}},"0.0.8":{"name":"@invertase/firestore-stripe-payments","version":"0.0.8","keywords":["firebase","payments","subscriptions","stripe","typescript","sdk"],"author":{"url":"https://stripe.com/","name":"Stripe"},"license":"Apache-2.0","_id":"@invertase/firestore-stripe-payments@0.0.8","maintainers":[{"name":"salakar","email":"mike.diarmid@gmail.com"},{"name":"ehesp","email":"elliot.hesp@gmail.com"},{"name":"cabljac","email":"jacobcable94@gmail.com"},{"name":"dackers86","email":"darren@invertase.io"}],"contributors":[{"url":"https://firebase.google.com/","name":"Firebase","email":"firebase-support@google.com"}],"dist":{"shasum":"498428c43f6f030afe10241796672ba53165eac1","tarball":"https://registry.npmjs.org/@invertase/firestore-stripe-payments/-/firestore-stripe-payments-0.0.8.tgz","fileCount":10,"integrity":"sha512-3qLwKrXG2ygxzeWOFZxdIw/UnWpFyQe7FLqlkfl4fAm5keGi4rY/6MdWI5mdm96cNVhnP5i/4HWnnooc4fXbAA==","signatures":[{"sig":"MEUCIQDmHhZyGyl7ntQoWsmt6ya1IsGuMFDqnZ0zkhYME2QTZgIgY4Ok7TNHRHstp0IqKES5QTxfFrbUtwzogTuKuab9Jk4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":310336},"main":"./lib/index.cjs","types":"./lib/index.d.ts","module":"./lib/index.mjs","exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.cjs"}},"gitHead":"f1671f12a3713515c513daf5101e2143639ad2a6","scripts":{"dev":"tsup --watch","test":"cd _emulator && firebase emulators:exec --project=demo-project \"cd .. && vitest run\"","build":"npm run clean && tsup","clean":"rimraf lib","build:watch":"tsup --watch","api-extractor":"api-extractor run --verbose","api-documenter":"api-documenter markdown --input-folder temp --output-folder markdown","pack-for-examples":"node pack-for-examples.js","api-extractor:local":"npm run build && api-extractor run --local --verbose"},"_npmUser":{"name":"cabljac","email":"jacobcable94@gmail.com"},"_npmVersion":"10.2.4","description":"Client SDK for the firestore-stripe-payments Firebase Extension","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","jsdom":"^26.1.0","rimraf":"^6.0.1","vitest":"^3.1.4","ts-node":"^10.2.1","firebase":"^11.8.1","typescript":"^5.8.3","@vitest/coverage-v8":"^3.1.4","@microsoft/api-extractor":"^7.18.17","@microsoft/api-documenter":"^7.13.65"},"peerDependencies":{"firebase":"^9.0.0 || ^10.0.0 || ^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/firestore-stripe-payments_0.0.8_1749193530449_0.04776209394041753","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2023-08-30T18:42:22.467Z","modified":"2026-03-31T14:20:01.293Z","0.0.6":"2023-08-30T18:42:22.729Z","0.0.7":"2023-08-30T18:57:20.458Z","0.0.8":"2025-06-06T07:05:30.662Z"},"author":{"url":"https://stripe.com/","name":"Stripe"},"license":"Apache-2.0","keywords":["firebase","payments","subscriptions","stripe","typescript","sdk"],"description":"Client SDK for the firestore-stripe-payments Firebase Extension","contributors":[{"url":"https://firebase.google.com/","name":"Firebase","email":"firebase-support@google.com"}],"maintainers":[{"email":"elliot.hesp@gmail.com","name":"ehesp"},{"email":"jacobcable94@gmail.com","name":"cabljac"},{"email":"darren@invertase.io","name":"dackers86"}],"readme":"# Firestore Stripe Payments Web SDK\n\nThis package helps you integrate your web app client with the\n[`firestore-stripe-payments`](https://firebase.google.com/products/extensions/firestore-stripe-subscriptions)\nextension. It abstracts out all the typical Firestore queries, and\nother database interactions necessary to use the extension. Moreover, it provides type\ndefinitions for all the common object types that are used by the extension when processing\npayments.\n\n## Features\n\n- 🔐 **Authentication Integration**: Seamless integration with Firebase Authentication\n- 🛍️ **Product Management**: List and filter products with their prices\n- 💳 **Subscription Handling**: Create and manage subscriptions\n- 🔄 **Real-time Updates**: Listen for subscription and payment changes\n- 🎯 **Type Safety**: Full TypeScript support with comprehensive type definitions\n- 🔌 **Firebase Integration**: Works with Firebase v9, v10, and v11\n\n## API Reference\n\n[API reference](https://github.com/stripe/stripe-firebase-extensions/blob/next/firestore-stripe-web-sdk/markdown/index.md)\n\n## Installation\n\n```bash\nnpm install @invertase/firestore-stripe-payments\n```\n\n## Example usage\n\n### Initialize the SDK\n\nStart by [initializing the Firebase web SDK](https://firebase.google.com/docs/web/setup)\nas usual.\n\nThen, initialize this library by passing in an `App` instance obtained from the Firebase\nweb SDK, and configure the library to use the same Firestore collections you configured\nthe extension to use.\n\n```js\nimport { getApp } from \"@firebase/app\";\nimport { getStripePayments } from \"@invertase/firestore-stripe-payments\";\n\nconst app = getApp();\nconst payments = getStripePayments(app, {\n  productsCollection: \"products\",\n  customersCollection: \"customers\",\n});\n```\n\n### List products and prices\n\nTo fetch all the active products along with their prices, call the\n`getProducts()` function as follows:\n\n```js\nimport { getProducts } from \"@invertase/firestore-stripe-payments\";\n\nconst products = await getProducts(payments, {\n  includePrices: true,\n  activeOnly: true,\n});\nfor (const product of products) {\n  // ...\n}\n```\n\nNote that for `N` products, this results in `(1 + N)` Firestore queries. Fetching\nthe products without the prices only requires 1 Firestore query.\n\nYou can also specify filters and limits on the product query as follows:\n\n```js\nimport { getProducts } from \"@invertase/firestore-stripe-payments\";\n\nconst products = await getProducts(payments, {\n  includePrices: true,\n  activeOnly: true,\n  where: [\n    [\"metadata.type\", \"==\", \"books\"],\n    [\"metadata.rating\", \">=\", 4],\n  ],\n  limit: 10,\n});\nfor (const product of products) {\n  // ...\n}\n```\n\n### Start a subscription checkout session\n\n```js\nimport { createCheckoutSession } from \"@invertase/firestore-stripe-payments\";\n\nconst session = await createCheckoutSession(payments, {\n  price: myPriceId,\n});\nwindow.location.assign(session.url);\n```\n\nCalling `createCheckoutSession()` as shown above will use the current page\n(`window.location.href`) as the success and cancel URLs for the session. Instead you\ncan specify your own URLs as follows:\n\n```js\nimport { createCheckoutSession } from \"@invertase/firestore-stripe-payments\";\n\nconst session = await createCheckoutSession(payments, {\n  price: myPriceId,\n  success_url: \"https://example.com/payments/success\",\n  cancel_url: \"https://example.com/payments/cancel\",\n});\nwindow.location.assign(session.url);\n```\n\nTo create a checkout session for more than one item, pass `line_items`:\n\n```js\nimport { createCheckoutSession } from \"@invertase/firestore-stripe-payments\";\n\nconst session = await createCheckoutSession(payments, {\n  line_items: [\n    { price: myPriceId1 },\n    { price: myPriceId2 },\n  ],\n});\nwindow.location.assign(session.url);\n```\n\n### Listen for subscription updates\n\nOnce a subscription checkout session has been created, you can listen to the\nStripe subscription update events as follows:\n\n```js\nimport { onCurrentUserSubscriptionUpdate } from \"@invertase/firestore-stripe-payments\";\n\nonCurrentUserSubscriptionUpdate(\n  payments,\n  (snapshot) => {\n    for (const change of snapshot.changes) {\n      if (change.type === \"added\") {\n        console.log(`New subscription added with ID: ${change.subscription.id}`);\n      }\n    }\n  }\n);\n```\n\n### Get current user's subscriptions\n\nTo fetch all subscriptions for the currently signed-in user:\n\n```js\nimport { getCurrentUserSubscriptions } from \"@invertase/firestore-stripe-payments\";\n\nconst subscriptions = await getCurrentUserSubscriptions(payments, {\n  status: \"active\" // Optional: filter by status\n});\n```\n\n## Available Examples\n\nThe SDK comes with three example implementations to help you get started:\n\n### 1. CommonJS Example (`/examples/cjs`)\nA basic implementation using CommonJS modules and webpack:\n- Simple product listing\n- Basic checkout functionality\n- Uses webpack for bundling\n- Demonstrates CommonJS module usage\n\n### 2. ESM Example (`/examples/esm`)\nA modern implementation using ES modules and Vite:\n- Product listing with prices\n- Checkout functionality\n- Uses Vite for fast development and building\n- Demonstrates ES module usage\n\n### 3. ESM with Subscriptions (`/examples/esm-with-subscriptions`)\nA complete implementation with subscription features:\n- User authentication\n- Product listing with prices\n- Subscription checkout\n- Real-time subscription monitoring\n- Active subscriptions display\n- Uses Vite for development\n- Demonstrates full subscription lifecycle\n\nTo run any of these examples:\n1. Navigate to the example directory\n2. Run `npm install`\n3. Update the Firebase configuration in `src/firebase-config.js`\n4. Run `npm run dev` to start the development server\n\n## Dependencies\n\n* Cloud Firestore (`@firebase/firestore`)\n* Firebase Auth (`@firebase/auth`)\n* Firebase Core (`@firebase/app`)\n\n## Build, test, release\n\n### Prerequisites\n\n* Node.js 20 or higher\n\n### Development workflows and commands\n\nTo install the dependencies, run `npm install` in the `firestore-stripe-web-sdk` directory.\n\nRun `npm test` to run all unit and integration tests (usually takes about 15 seconds).\n\nTo build a release artifact, run `npm run build` followed by `npm pack`. The resulting tarball\ncan be published to NPM with `npm publish <tarball>`.\n\n### Available Scripts\n\n- `npm run build`: Build the library\n- `npm run build:watch`: Build the library in watch mode\n- `npm run dev`: Start development mode with watch\n- `npm run test`: Run tests using Firebase emulators\n- `npm run clean`: Clean build artifacts\n- `npm run api-extractor`: Generate API documentation\n- `npm run api-documenter`: Generate markdown documentation\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n","readmeFilename":"README.md"}