{"_id":"@dsvnpm/firestore-stripe-payments","_rev":"2-343bb50894e05d56670816c72461620f","name":"@dsvnpm/firestore-stripe-payments","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.2":{"name":"@dsvnpm/firestore-stripe-payments","version":"0.0.2","description":"Client SDK for the firestore-stripe-payments Firebase Extension","main":"./lib/index.js","typings":"./lib/index.d.ts","scripts":{"api-documenter":"api-documenter markdown --input-folder temp --output-folder markdown","api-extractor":"api-extractor run --verbose","api-extractor:local":"npm run build && api-extractor run --local --verbose","build":"tsc","postbuild":"node ./postbuild.js","test":"firebase emulators:exec --only firestore,auth --project fake-project-id 'npm run test:unit'","test:unit":"karma start --single-run"},"keywords":["firebase","payments","subscriptions","stripe"],"author":{"name":"Stripe","url":"https://stripe.com/"},"contributors":[{"name":"Firebase","email":"firebase-support@google.com","url":"https://firebase.google.com/"}],"license":"Apache-2.0","devDependencies":{"@microsoft/api-documenter":"^7.13.65","@microsoft/api-extractor":"^7.18.17","@types/chai":"^4.2.21","@types/chai-as-promised":"^7.1.4","@types/chai-like":"^1.1.1","@types/mocha":"^9.0.0","@types/sinon":"^10.0.6","@types/sinon-chai":"^3.2.5","chai":"^4.3.4","chai-as-promised":"^7.1.1","chai-like":"^1.1.1","firebase-tools":"^9.18.0","mocha":"^9.1.1","karma":"^6.3.4","karma-mocha":"^2.0.1","karma-mocha-reporter":"^2.2.5","karma-webpack":"^4.0.2","karma-sourcemap-loader":"^0.3.8","karma-chrome-launcher":"^3.1.0","webpack":"^4.46.0","source-map-loader":"^1.1.3","replace-in-file":"^6.2.0","sinon":"^11.1.2","sinon-chai":"^3.7.0","ts-node":"^10.2.1","ts-loader":"^8.3.0","typescript":"^4.4.2"},"dependencies":{"@firebase/app":"^0.7.5","@firebase/auth":"^0.17.2","@firebase/firestore":"^3.2.0"},"_resolved":"","_integrity":"","_from":"file:dsvnpm-firestore-stripe-payments-0.0.2.tgz","_id":"@dsvnpm/firestore-stripe-payments@0.0.2","_nodeVersion":"14.17.3","_npmVersion":"6.14.13","dist":{"integrity":"sha512-NmchUhNOVUVxV2DCSpzg6kA3IPy6XlzC4du7EO/xoWFLtdanttjq7Gub3f3Dbg4ZFF7hKqx1n+mytMimRtgk+Q==","shasum":"b01e7dff9c14a1b53ae41c167a17d1c2a07e42bf","tarball":"https://registry.npmjs.org/@dsvnpm/firestore-stripe-payments/-/firestore-stripe-payments-0.0.2.tgz","fileCount":32,"unpackedSize":156832,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2EqZCRA9TVsSAnZWagAABAwP/RkikTl5MH6S7gOUAOjn\n/rfGKkn6eFxutZpHq6U30T+D0Jltsvh4QILVfQycxWdZvklp3XxxQLt3n9Wu\n2mYPm7Lyqqt70vCcNQ/BfdRtWzsQWbX467yc6h3PBHGCDYQ7qX3wIBVraNGT\n6ADlmDEEChoYYT44MOHWWir95r1NWmbPcBkoIlAnMUnvy1z/xRkl/5tQgurV\n/+Pu2EOaHuXA2g3nHFh1LvbhV+0sRx8AhG1nx1pK+8P+ls0e00/Rk8XnTWti\nsqE9TNbwtcpz7ibhNH0RShwrgkf6N3pg0YjA9yywvFfpAotod7aSJLoSA7+G\nuUp0XepC10NUvoK+GXfwpEfaw239e5V05HNiZv79ko54jWd8W6tZPpuP0A9K\nxHoKk89xgvsRVx/msyqfU/zlXgsnPvc351Wk92L9VHrQp9yXnfIKEmxVggYW\nBxt/ISmNq3eqrkWyIC8STRHFwB8+OE0aJd84zHxz5AAl2sTeHLu08ywzYDH3\nNhRb6TbkHc5uVvh5P0EMWjsIIbidsdr82Z19qnxDtlAPCjFl9ItpkdGx1jX9\n2G9KxQAauhtmOKcveIok1vXjiGeODm/4IVL9xBkO9bC9z9uQkSMKnUiuWXe9\nTQhyF8PU+Zad7pGbG4CJEzuhAS5ELC8m0SRwqjLyKYDmsDe5ioxmiS/OeGL4\n2OAk\r\n=muxV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICU9FvVWJseQKLKA0ySdpcBTa9XnYbscy9Le090ZW35EAiEAlZn/6x4OAnjxWdUhd3KxKSOJnDl7ilnwjaIB04MbSd8="}]},"_npmUser":{"name":"dsvnpm","email":"dsv.mail@yandex.ru"},"directories":{},"maintainers":[{"name":"dsvnpm","email":"dsv.mail@yandex.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/firestore-stripe-payments_0.0.2_1636065562269_0.7740952068257962"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-04T22:39:22.202Z","0.0.2":"2021-11-04T22:39:22.421Z","modified":"2022-04-05T06:00:31.892Z"},"maintainers":[{"name":"dsvnpm","email":"dsv.mail@yandex.ru"}],"description":"Client SDK for the firestore-stripe-payments Firebase Extension","keywords":["firebase","payments","subscriptions","stripe"],"contributors":[{"name":"Firebase","email":"firebase-support@google.com","url":"https://firebase.google.com/"}],"author":{"name":"Stripe","url":"https://stripe.com/"},"license":"Apache-2.0","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# API Reference\n\n[API reference](./markdown/index.md)\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 \"@stripe/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 \"@stripe/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 \"@stripe/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 \"@stripe/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 \"@stripe/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 \"@stripe/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 \"@stripe/firestore-stripe-payments\";\n\nonCurrentUserSubscriptionUpdate(\n  payments,\n  (snapshot) => {\n    for (const change in 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# 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 12 or higher\n* NPM 6 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","readmeFilename":"README.md"}