├── .github ├── ISSUE_TEMPLATE │ ├── 1.Bug_report.md │ ├── 2.Feature_request.md │ └── config.yml └── workflows │ ├── test.yml │ └── validate.yml ├── .gitignore ├── .prettierignore ├── .prettierrc.yaml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── codelab-steps ├── .gitignore ├── img │ ├── 2abaf5b7823ad034.png │ ├── 2e03923c9d7f1f29.png │ ├── 2eb4bd60034d22fb.png │ ├── 58d6543a156e56f9.png │ ├── 5d1889c05b9cb856.png │ ├── 6c0519e8f48a3a6f.png │ ├── 7c7e056460256f11.png │ ├── 88c964177c2bccea.png │ ├── 94abfc5963d7944b.png │ ├── 9c7f68621a459c2.png │ ├── b938d9b07a1f609c.png │ ├── c39f0aff311ed0a2.png │ ├── c78ba01bf5aee63a.png │ ├── d841eb724fc5a07a.png │ ├── d8acda168a6d0f3.png │ ├── ed0f449a872f7287.png │ └── f2c920ac6174e69a.png └── index.lab.md ├── firestore-stripe-invoices ├── .gitignore ├── CHANGELOG.md ├── POSTINSTALL.md ├── PREINSTALL.md ├── README.md ├── extension.yaml ├── functions │ ├── .gitignore │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── config.ts │ │ ├── events.ts │ │ ├── index.ts │ │ ├── interfaces.ts │ │ └── logs.ts │ └── tsconfig.json └── icon.png ├── firestore-stripe-payments ├── .gitignore ├── CHANGELOG.md ├── POSTINSTALL.md ├── PREINSTALL.md ├── README.md ├── _emulator │ ├── .gitignore │ ├── extensions │ │ ├── firestore-stripe-payments.env.local │ │ └── firestore-stripe-payments.secret.local.example │ ├── firebase.json │ ├── firestore.indexes.json │ ├── firestore.rules │ ├── functions │ │ ├── .gitignore │ │ ├── index.js │ │ └── package.json │ └── storage.rules ├── extension.yaml ├── functions │ ├── .gitignore │ ├── __tests__ │ │ ├── firebase.json │ │ ├── firestore.rules │ │ ├── helpers │ │ │ ├── collections.ts │ │ │ ├── forms │ │ │ │ └── runCheckout.ts │ │ │ ├── setupEmulator.ts │ │ │ ├── setupEnvironment.ts │ │ │ ├── setupProducts.ts │ │ │ ├── stripeApi │ │ │ │ ├── customers.ts │ │ │ │ └── subscriptions.ts │ │ │ └── utils.ts │ │ ├── jest.global-setup.ts │ │ ├── jest.global-teardown.ts │ │ ├── jest.setup.ts │ │ └── tests │ │ │ ├── checkoutsessions │ │ │ ├── createCheckoutSession.test.ts │ │ │ └── subscriptionCheckoutSessions.test.ts │ │ │ ├── customers │ │ │ ├── createCustomer.test.ts │ │ │ └── customerDataDeleted.test.ts │ │ │ ├── portalLinks │ │ │ └── createPortalLink.test.ts │ │ │ ├── unit │ │ │ └── handlers │ │ │ │ ├── checkout-session-create.test.ts │ │ │ │ └── webhook-events.test.ts │ │ │ └── webhookevents │ │ │ ├── handleWebhookEvents.test.ts │ │ │ └── subscriptions.test.ts │ ├── jest.config.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── config.ts │ │ ├── handlers │ │ │ ├── checkout-session-creation.ts │ │ │ └── webhook-events.ts │ │ ├── index.ts │ │ ├── interfaces.ts │ │ ├── logs.ts │ │ └── utils.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── icon.png ├── runTests.sh └── runTestsWatch.sh ├── firestore-stripe-subscriptions └── README.md ├── firestore-stripe-web-sdk ├── .gitignore ├── LICENSE ├── NOTICE.txt ├── README.md ├── _emulator │ ├── .gitignore │ ├── extensions │ │ ├── firestore-stripe-payments.env.local │ │ └── firestore-stripe-payments.secret.local.example │ ├── firebase.json │ ├── firestore.indexes.json │ ├── firestore.rules │ └── functions │ │ ├── .gitignore │ │ ├── index.js │ │ └── package.json ├── api-extractor.json ├── deploy.sh ├── etc │ └── firestore-stripe-payments.api.md ├── examples │ ├── .gitignore │ ├── cjs │ │ ├── README.md │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── firebase-config.example.js │ │ │ └── main.js │ │ └── webpack.config.js │ ├── esm-with-subscriptions │ │ ├── README.md │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ │ ├── firestore-config.example.js │ │ │ └── main.js │ │ └── vite.config.js │ └── esm │ │ ├── README.md │ │ ├── index.html │ │ ├── package.json │ │ ├── src │ │ ├── firestore-config.example.js │ │ └── main.js │ │ └── vite.config.js ├── markdown │ ├── firestore-stripe-payments.commonlineitemparams.description.md │ ├── firestore-stripe-payments.commonlineitemparams.md │ ├── firestore-stripe-payments.commonlineitemparams.quantity.md │ ├── firestore-stripe-payments.commonsessioncreateparams.allow_promotion_codes.md │ ├── firestore-stripe-payments.commonsessioncreateparams.automatic_tax.md │ ├── firestore-stripe-payments.commonsessioncreateparams.cancel_url.md │ ├── firestore-stripe-payments.commonsessioncreateparams.client_reference_id.md │ ├── firestore-stripe-payments.commonsessioncreateparams.md │ ├── firestore-stripe-payments.commonsessioncreateparams.metadata.md │ ├── firestore-stripe-payments.commonsessioncreateparams.mode.md │ ├── firestore-stripe-payments.commonsessioncreateparams.payment_method_types.md │ ├── firestore-stripe-payments.commonsessioncreateparams.promotion_code.md │ ├── firestore-stripe-payments.commonsessioncreateparams.success_url.md │ ├── firestore-stripe-payments.commonsessioncreateparams.tax_id_collection.md │ ├── firestore-stripe-payments.commonsessioncreateparams.trial_from_plan.md │ ├── firestore-stripe-payments.create_session_timeout_millis.md │ ├── firestore-stripe-payments.createcheckoutsession.md │ ├── firestore-stripe-payments.createcheckoutsessionoptions.md │ ├── firestore-stripe-payments.createcheckoutsessionoptions.timeoutmillis.md │ ├── firestore-stripe-payments.getcurrentusersubscription.md │ ├── firestore-stripe-payments.getcurrentusersubscriptions.md │ ├── firestore-stripe-payments.getprice.md │ ├── firestore-stripe-payments.getprices.md │ ├── firestore-stripe-payments.getproduct.md │ ├── firestore-stripe-payments.getproductoptions.includeprices.md │ ├── firestore-stripe-payments.getproductoptions.md │ ├── firestore-stripe-payments.getproducts.md │ ├── firestore-stripe-payments.getproductsoptions.activeonly.md │ ├── firestore-stripe-payments.getproductsoptions.includeprices.md │ ├── firestore-stripe-payments.getproductsoptions.limit.md │ ├── firestore-stripe-payments.getproductsoptions.md │ ├── firestore-stripe-payments.getproductsoptions.where.md │ ├── firestore-stripe-payments.getstripepayments.md │ ├── firestore-stripe-payments.getsubscriptionsoptions.md │ ├── firestore-stripe-payments.getsubscriptionsoptions.status.md │ ├── firestore-stripe-payments.lineitem.amount.md │ ├── firestore-stripe-payments.lineitem.currency.md │ ├── firestore-stripe-payments.lineitem.description.md │ ├── firestore-stripe-payments.lineitem.md │ ├── firestore-stripe-payments.lineitem.name.md │ ├── firestore-stripe-payments.lineitem.price.md │ ├── firestore-stripe-payments.lineitem.quantity.md │ ├── firestore-stripe-payments.lineitemparams.md │ ├── firestore-stripe-payments.lineitemsessioncreateparams.line_items.md │ ├── firestore-stripe-payments.lineitemsessioncreateparams.md │ ├── firestore-stripe-payments.md │ ├── firestore-stripe-payments.oncurrentusersubscriptionupdate.md │ ├── firestore-stripe-payments.paymentmethodtype.md │ ├── firestore-stripe-payments.price.active.md │ ├── firestore-stripe-payments.price.currency.md │ ├── firestore-stripe-payments.price.description.md │ ├── firestore-stripe-payments.price.id.md │ ├── firestore-stripe-payments.price.interval.md │ ├── firestore-stripe-payments.price.interval_count.md │ ├── firestore-stripe-payments.price.md │ ├── firestore-stripe-payments.price.product.md │ ├── firestore-stripe-payments.price.trial_period_days.md │ ├── firestore-stripe-payments.price.type.md │ ├── firestore-stripe-payments.price.unit_amount.md │ ├── firestore-stripe-payments.priceidlineitemparams.md │ ├── firestore-stripe-payments.priceidlineitemparams.price.md │ ├── firestore-stripe-payments.priceidsessioncreateparams.md │ ├── firestore-stripe-payments.priceidsessioncreateparams.price.md │ ├── firestore-stripe-payments.priceidsessioncreateparams.quantity.md │ ├── firestore-stripe-payments.product.active.md │ ├── firestore-stripe-payments.product.description.md │ ├── firestore-stripe-payments.product.id.md │ ├── firestore-stripe-payments.product.images.md │ ├── firestore-stripe-payments.product.md │ ├── firestore-stripe-payments.product.metadata.md │ ├── firestore-stripe-payments.product.name.md │ ├── firestore-stripe-payments.product.prices.md │ ├── firestore-stripe-payments.product.role.md │ ├── firestore-stripe-payments.session.allow_promotion_codes.md │ ├── firestore-stripe-payments.session.automatic_tax.md │ ├── firestore-stripe-payments.session.cancel_url.md │ ├── firestore-stripe-payments.session.client_reference_id.md │ ├── firestore-stripe-payments.session.created_at.md │ ├── firestore-stripe-payments.session.id.md │ ├── firestore-stripe-payments.session.line_items.md │ ├── firestore-stripe-payments.session.md │ ├── firestore-stripe-payments.session.metadata.md │ ├── firestore-stripe-payments.session.mode.md │ ├── firestore-stripe-payments.session.payment_method_types.md │ ├── firestore-stripe-payments.session.price.md │ ├── firestore-stripe-payments.session.promotion_code.md │ ├── firestore-stripe-payments.session.quantity.md │ ├── firestore-stripe-payments.session.success_url.md │ ├── firestore-stripe-payments.session.tax_id_collection.md │ ├── firestore-stripe-payments.session.trial_from_plan.md │ ├── firestore-stripe-payments.session.url.md │ ├── firestore-stripe-payments.sessioncreateparams.md │ ├── firestore-stripe-payments.stripepayments.app.md │ ├── firestore-stripe-payments.stripepayments.customerscollection.md │ ├── firestore-stripe-payments.stripepayments.md │ ├── firestore-stripe-payments.stripepayments.productscollection.md │ ├── firestore-stripe-payments.stripepaymentserror._constructor_.md │ ├── firestore-stripe-payments.stripepaymentserror.cause.md │ ├── firestore-stripe-payments.stripepaymentserror.code.md │ ├── firestore-stripe-payments.stripepaymentserror.md │ ├── firestore-stripe-payments.stripepaymentserror.message.md │ ├── firestore-stripe-payments.stripepaymentserrorcode.md │ ├── firestore-stripe-payments.stripepaymentsoptions.customerscollection.md │ ├── firestore-stripe-payments.stripepaymentsoptions.md │ ├── firestore-stripe-payments.stripepaymentsoptions.productscollection.md │ ├── firestore-stripe-payments.subscription.cancel_at.md │ ├── firestore-stripe-payments.subscription.cancel_at_period_end.md │ ├── firestore-stripe-payments.subscription.canceled_at.md │ ├── firestore-stripe-payments.subscription.created.md │ ├── firestore-stripe-payments.subscription.current_period_end.md │ ├── firestore-stripe-payments.subscription.current_period_start.md │ ├── firestore-stripe-payments.subscription.ended_at.md │ ├── firestore-stripe-payments.subscription.id.md │ ├── firestore-stripe-payments.subscription.md │ ├── firestore-stripe-payments.subscription.metadata.md │ ├── firestore-stripe-payments.subscription.price.md │ ├── firestore-stripe-payments.subscription.prices.md │ ├── firestore-stripe-payments.subscription.product.md │ ├── firestore-stripe-payments.subscription.quantity.md │ ├── firestore-stripe-payments.subscription.role.md │ ├── firestore-stripe-payments.subscription.status.md │ ├── firestore-stripe-payments.subscription.stripe_link.md │ ├── firestore-stripe-payments.subscription.trial_end.md │ ├── firestore-stripe-payments.subscription.trial_start.md │ ├── firestore-stripe-payments.subscription.uid.md │ ├── firestore-stripe-payments.subscriptionchangetype.md │ ├── firestore-stripe-payments.subscriptionsnapshot.changes.md │ ├── firestore-stripe-payments.subscriptionsnapshot.empty.md │ ├── firestore-stripe-payments.subscriptionsnapshot.md │ ├── firestore-stripe-payments.subscriptionsnapshot.size.md │ ├── firestore-stripe-payments.subscriptionsnapshot.subscriptions.md │ ├── firestore-stripe-payments.subscriptionstatus.md │ ├── firestore-stripe-payments.wherefilter.md │ └── index.md ├── pack-for-examples.js ├── package.json ├── src │ ├── index.ts │ ├── init.ts │ ├── payment.ts │ ├── product.ts │ ├── session.ts │ ├── subscription.ts │ ├── user.ts │ └── utils.ts ├── test │ ├── emulator.spec.ts │ ├── init.spec.ts │ ├── payment.spec.ts │ ├── product.spec.ts │ ├── session.spec.ts │ ├── setup.ts │ ├── subscription.spec.ts │ └── testdata.ts ├── tsconfig.build.json ├── tsconfig.json ├── tsup.config.ts └── vitest.config.ts ├── lerna.json └── package.json /.github/ISSUE_TEMPLATE/1.Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report for one of the extensions. 4 | --- 5 | 6 | # Bug report 7 | 8 | - Extension name: [e.g. `firestore-stripe-payments`] 9 | 10 | ## Describe the bug 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | ## To Reproduce 15 | 16 | Steps to reproduce the behavior, please provide code snippets or a repository: 17 | 18 | 1. Go to '…' 19 | 2. Click on '…' 20 | 3. Scroll down to '…' 21 | 4. See error 22 | 23 | ## Expected behavior 24 | 25 | A clear and concise description of what you expected to happen. 26 | 27 | ## Screenshots 28 | 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | ## System information 32 | 33 | - OS: [e.g. macOS, Windows] 34 | - Browser (if applies) [e.g. Chrome, Safari] 35 | 36 | ## Additional context 37 | 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/2.Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Request a new feature or extension. 4 | --- 5 | 6 | # Feature request 7 | 8 | - Extension name: [e.g. `firestore-stripe-payments`, or leave empty if suggesting a new extension] 9 | 10 | ## Is your feature request related to a problem? Please describe. 11 | 12 | A clear and concise description of what you want and what your use case is. 13 | 14 | ## Describe the solution you'd like 15 | 16 | A clear and concise description of what you want to happen. 17 | 18 | ## Describe alternatives you've considered 19 | 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | 22 | ## Additional context 23 | 24 | Add any other context or screenshots about the feature request here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Need help with your integration? 4 | url: https://support.stripe.com 5 | about: Ask questions via our email support or the technical chat on IRC. 6 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Testing 2 | 3 | on: 4 | push: 5 | branches: 6 | - next 7 | - master 8 | pull_request: 9 | branches: 10 | - "**" 11 | 12 | jobs: 13 | nodejs: 14 | runs-on: ubuntu-latest 15 | concurrency: 16 | group: ${{ github.workflow }} 17 | cancel-in-progress: false 18 | strategy: 19 | matrix: 20 | node: ["20"] 21 | max-parallel: 1 22 | name: node.js_${{ matrix.node }}_test 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Setup node 26 | uses: actions/setup-node@v4 27 | with: 28 | node-version: ${{ matrix.node }} 29 | cache: "npm" 30 | cache-dependency-path: "**/package-lock.json" 31 | 32 | - name: Install Dependencies 33 | run: npm install 34 | 35 | - name: Build emulator functions 36 | run: | 37 | cd firestore-stripe-payments/_emulator/functions && npm i && cd ../../.. 38 | cd firestore-stripe-web-sdk/_emulator/functions && npm i && cd ../../.. 39 | 40 | - name: Install Firebase CLI 41 | uses: nick-invision/retry@v3 42 | with: 43 | timeout_minutes: 10 44 | retry_wait_seconds: 60 45 | max_attempts: 3 46 | command: npm i -g firebase-tools@14 47 | 48 | - name: Install Stripe CLI 49 | run: | 50 | wget -q https://github.com/stripe/stripe-cli/releases/latest/download/stripe_1.27.0_linux_x86_64.tar.gz 51 | tar -xzf stripe_1.27.0_linux_x86_64.tar.gz 52 | sudo mv stripe /usr/local/bin/ 53 | 54 | - name: Run Tests 55 | run: npm test 56 | env: 57 | STRIPE_API_KEY: ${{ secrets.STRIPE_API_KEY }} 58 | -------------------------------------------------------------------------------- /.github/workflows/validate.yml: -------------------------------------------------------------------------------- 1 | name: Validate 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - "**" 7 | 8 | jobs: 9 | formatting: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: NPM Install & Build 14 | run: npm i 15 | - name: Prettier Lint Check 16 | run: npm run lint 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | node_modules/ 3 | *.env 4 | firebase-debug.log 5 | .DS_Store 6 | mods-test-data/key.json 7 | .gradle 8 | .idea 9 | build 10 | *.iml 11 | local.properties 12 | coverage 13 | package-lock.json 14 | yarn.lock 15 | firestore-stripe-payments/_emulator/extensions/firestore-stripe-payments.secret.local 16 | *.secret.local -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | api-extractor.json 2 | package.json 3 | extension.yaml 4 | package-lock.json 5 | 6 | **/node_modules/** 7 | 8 | # generated files 9 | README.md 10 | **/etc/** 11 | **/functions/lib/** 12 | **/lib/** 13 | **/dist/** 14 | **/markdown/** 15 | coverage 16 | 17 | # extension install md files 18 | # - excluded as prettier escapes variables e.g. `${PROJECT_ID}` becomes `\${PROJECT_ID}` 19 | CHANGELOG.md 20 | POSTINSTALL.md 21 | PREINSTALL.md 22 | -------------------------------------------------------------------------------- /.prettierrc.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Stripe, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | trailingComma: es5 16 | arrowParens: always 17 | overrides: 18 | - files: "*.{yml,yaml}" 19 | options: 20 | proseWrap: always 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We highly appreciate feedback and contributions from the community! If you'd like to contribute to this project, please make sure to review and follow the guidelines below. 4 | 5 | ## Code of conduct 6 | 7 | In the interest of fostering an open and welcoming environment, please review and follow our [code of conduct](./CODE_OF_CONDUCT.md). 8 | 9 | ## Code and copy reviews 10 | 11 | All submissions, including submissions by project members, require review. We 12 | use GitHub pull requests for this purpose. Consult 13 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 14 | information on using pull requests. 15 | 16 | ## Report an issue 17 | 18 | Report all issues through GitHub Issues using the [Report a Bug](https://github.com/stripe/stripe-firebase-extensions/issues/new?template=1.Bug_report.md) template. 19 | 20 | To help resolve your issue as quickly as possible, read the template and provide all the requested information. 21 | 22 | ## File a feature request 23 | 24 | We welcome all feature requests, whether it's to add new functionality to an existing extension or to offer an idea for a brand new extension. 25 | 26 | File your feature request through GitHub Issues using the [Feature Request template](https://github.com/stripe/stripe-firebase-extensions/issues/new?template=2.Feature_request.md). 27 | 28 | ## Create a pull request 29 | 30 | When making pull requests to the repository, make sure to follow these guidelines for both bug fixes and new features: 31 | 32 | - Before creating a pull request, file a GitHub Issue so that maintainers and the community can discuss the problem and potential solutions before you spend time on an implementation. 33 | - In your PR's description, link to any related issues or pull requests to give reviewers the full context of your change. 34 | - For commit messages, follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format. 35 | - For example, if you update documentation for a specific extension, your commit message might be: `docs(extension-name) updated installation documentation`. 36 | 37 | ### Features 38 | 39 | Before creating pull requests for new features, first file a GitHub Issue describing the reasoning and motivation for the feature. This gives maintainers and the community the opportunity to provide feedback on your idea before implementing it. 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UPDATE 2023-10-08: 2 | This project has now being officially transferred to [Invertase](https://github.com/invertase), who will maintain this extension going forward. Please see [this issue](https://github.com/stripe/stripe-firebase-extensions/issues/524) for more details. 3 | It is now recommended to uninstall the `stripe/firestore-stripe-payments` extension and install `invertase/firestore-stripe-payments` from the Firebase Extension Hub. 4 | 5 | Alternatively, you can also use the following link to convert your current installation to the Invertase version 6 | 7 | `https://console.firebase.google.com/project/_/extensions/install?instanceId=STRIPE_EXTENSION_INSTANCE_ID&ref=invertase%2Ffirestore-stripe-payments@0.3.12` 8 | 9 | # Stripe Firebase Extensions 10 | 11 | This repository contains the source code for Firebase Extensions that enable payment functionality. Created and tested by Stripe, these official Stripe Firebase extensions are reliable and secure. To learn more about Firebase Extensions, including how to install them in your Firebase projects, visit the [Firebase documentation](https://firebase.google.com/docs/extensions). 12 | 13 | Each directory in this repo contains the source code for the extension and a README to explain how the extension works, including information about the enabled APIs, resources created, and the access granted to the extension. 14 | 15 | ## Extension Directory 16 | 17 | - [Explore all Firebase Extensions](https://firebase.google.com/products/extensions) 18 | 19 | This repository includes the source code for the following extensions: 20 | 21 | 1. Stripe backend for web, mobile, and subscription payments 22 | - [Homepage](https://firebase.google.com/products/extensions/firestore-stripe-payments) 23 | - [Source code](./firestore-stripe-payments) 24 | 1. Send invoices using Stripe 25 | - [Homepage](https://firebase.google.com/products/extensions/firestore-stripe-invoices) 26 | - [Source code](./firestore-stripe-invoices) 27 | -------------------------------------------------------------------------------- /codelab-steps/.gitignore: -------------------------------------------------------------------------------- 1 | stripe-firebase-extensions/* 2 | !stripe-firebase-extensions/.firebaserc 3 | !stripe-firebase-extensions/firebase.json -------------------------------------------------------------------------------- /codelab-steps/img/2abaf5b7823ad034.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/2abaf5b7823ad034.png -------------------------------------------------------------------------------- /codelab-steps/img/2e03923c9d7f1f29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/2e03923c9d7f1f29.png -------------------------------------------------------------------------------- /codelab-steps/img/2eb4bd60034d22fb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/2eb4bd60034d22fb.png -------------------------------------------------------------------------------- /codelab-steps/img/58d6543a156e56f9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/58d6543a156e56f9.png -------------------------------------------------------------------------------- /codelab-steps/img/5d1889c05b9cb856.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/5d1889c05b9cb856.png -------------------------------------------------------------------------------- /codelab-steps/img/6c0519e8f48a3a6f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/6c0519e8f48a3a6f.png -------------------------------------------------------------------------------- /codelab-steps/img/7c7e056460256f11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/7c7e056460256f11.png -------------------------------------------------------------------------------- /codelab-steps/img/88c964177c2bccea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/88c964177c2bccea.png -------------------------------------------------------------------------------- /codelab-steps/img/94abfc5963d7944b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/94abfc5963d7944b.png -------------------------------------------------------------------------------- /codelab-steps/img/9c7f68621a459c2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/9c7f68621a459c2.png -------------------------------------------------------------------------------- /codelab-steps/img/b938d9b07a1f609c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/b938d9b07a1f609c.png -------------------------------------------------------------------------------- /codelab-steps/img/c39f0aff311ed0a2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/c39f0aff311ed0a2.png -------------------------------------------------------------------------------- /codelab-steps/img/c78ba01bf5aee63a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/c78ba01bf5aee63a.png -------------------------------------------------------------------------------- /codelab-steps/img/d841eb724fc5a07a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/d841eb724fc5a07a.png -------------------------------------------------------------------------------- /codelab-steps/img/d8acda168a6d0f3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/d8acda168a6d0f3.png -------------------------------------------------------------------------------- /codelab-steps/img/ed0f449a872f7287.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/ed0f449a872f7287.png -------------------------------------------------------------------------------- /codelab-steps/img/f2c920ac6174e69a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/codelab-steps/img/f2c920ac6174e69a.png -------------------------------------------------------------------------------- /firestore-stripe-invoices/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | # Logs 3 | logs 4 | *.log 5 | npm-debug.log* 6 | yarn-debug.log* 7 | yarn-error.log* 8 | firebase-debug.log* 9 | 10 | # Firebase cache 11 | .firebase/ 12 | 13 | # Firebase config 14 | .firebaserc 15 | 16 | # Uncomment this if you'd like others to create their own Firebase project. 17 | # For a team working on the same Firebase project(s), it is recommended to leave 18 | # it commented so all members can deploy to the same project(s) in .firebaserc. 19 | # .firebaserc 20 | 21 | # Runtime data 22 | pids 23 | *.pid 24 | *.seed 25 | *.pid.lock 26 | 27 | # Directory for instrumented libs generated by jscoverage/JSCover 28 | lib-cov 29 | 30 | # Coverage directory used by tools like istanbul 31 | coverage 32 | 33 | # nyc test coverage 34 | .nyc_output 35 | 36 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 37 | .grunt 38 | 39 | # Bower dependency directory (https://bower.io/) 40 | bower_components 41 | 42 | # node-waf configuration 43 | .lock-wscript 44 | 45 | # Compiled binary addons (http://nodejs.org/api/addons.html) 46 | build/Release 47 | 48 | # Dependency directories 49 | node_modules/ 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional REPL history 58 | .node_repl_history 59 | 60 | # Output of 'npm pack' 61 | *.tgz 62 | 63 | # Yarn Integrity file 64 | .yarn-integrity 65 | 66 | # dotenv environment variables file 67 | .env 68 | # firebase.json 69 | test-params.env 70 | -------------------------------------------------------------------------------- /firestore-stripe-invoices/functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | firebase.json 3 | lib 4 | !package-lock.json -------------------------------------------------------------------------------- /firestore-stripe-invoices/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firestore-stripe-invoices", 3 | "engines": { 4 | "node": "20" 5 | }, 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "prepare": "npm run build", 9 | "build": "npm run clean && tsc", 10 | "build:watch": "npm run clean && tsc --watch", 11 | "clean": "rimraf lib", 12 | "compile": "tsc", 13 | "generate-readme": "firebase ext:info .. --markdown > ../README.md", 14 | "test": "echo \"Error: no test specified\" && exit 0" 15 | }, 16 | "author": "Stripe (https://stripe.com/)", 17 | "license": "Apache-2.0", 18 | "dependencies": { 19 | "firebase-admin": "^11.10.1", 20 | "firebase-functions": "^3.14.1", 21 | "rimraf": "^3.0.2", 22 | "stripe": "8.56.0", 23 | "typescript": "^4.9.5" 24 | }, 25 | "devDependencies": { 26 | "firebase-functions-test": "^0.1.6", 27 | "@types/express": "^4.17.3" 28 | }, 29 | "prettier": { 30 | "singleQuote": true, 31 | "printWidth": 80 32 | }, 33 | "private": true 34 | } 35 | -------------------------------------------------------------------------------- /firestore-stripe-invoices/functions/src/config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Stripe, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export default { 18 | stripeSecretKey: process.env.STRIPE_API_KEY, 19 | stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET, 20 | daysUntilDue: Number(process.env.DAYS_UNTIL_DUE_DEFAULT), 21 | invoicesCollectionPath: process.env.INVOICES_COLLECTION, 22 | }; 23 | -------------------------------------------------------------------------------- /firestore-stripe-invoices/functions/src/events.ts: -------------------------------------------------------------------------------- 1 | export const relevantInvoiceEvents = new Set([ 2 | 'invoice.created', 3 | 'invoice.finalized', 4 | 'invoice.payment_failed', 5 | 'invoice.payment_succeeded', 6 | 'invoice.payment_action_required', 7 | 'invoice.voided', 8 | 'invoice.marked_uncollectible', 9 | 'invoice.updated', 10 | 'invoice.paid', 11 | ]); 12 | -------------------------------------------------------------------------------- /firestore-stripe-invoices/functions/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Stripe, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export interface InvoicePayload { 18 | email?: string; 19 | uid?: string; 20 | items: [OrderItem]; 21 | daysUntilDue?: number; 22 | default_tax_rates?: string[]; 23 | transfer_data?: { 24 | destination: string; 25 | amount?: number; 26 | }; 27 | description?: string; 28 | } 29 | 30 | export interface OrderItem { 31 | amount: number; 32 | currency: string; 33 | quantity?: number; 34 | description: string; 35 | tax_rates?: string[]; 36 | } 37 | -------------------------------------------------------------------------------- /firestore-stripe-invoices/functions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["es2020"], 4 | "types": ["./node_modules/stripe/types/2020-03-02"], 5 | "module": "commonjs", 6 | "noImplicitReturns": true, 7 | "outDir": "lib", 8 | "sourceMap": true, 9 | "target": "es2020", 10 | "esModuleInterop": true 11 | }, 12 | "compileOnSave": true, 13 | "include": ["src"] 14 | } 15 | -------------------------------------------------------------------------------- /firestore-stripe-invoices/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/firestore-stripe-invoices/icon.png -------------------------------------------------------------------------------- /firestore-stripe-payments/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | # Logs 3 | logs 4 | *.log 5 | npm-debug.log* 6 | yarn-debug.log* 7 | yarn-error.log* 8 | firebase-debug.log* 9 | 10 | # Firebase cache 11 | .firebase/ 12 | 13 | # Firebase config 14 | .firebaserc 15 | 16 | # Uncomment this if you'd like others to create their own Firebase project. 17 | # For a team working on the same Firebase project(s), it is recommended to leave 18 | # it commented so all members can deploy to the same project(s) in .firebaserc. 19 | # .firebaserc 20 | 21 | # Runtime data 22 | pids 23 | *.pid 24 | *.seed 25 | *.pid.lock 26 | 27 | # Directory for instrumented libs generated by jscoverage/JSCover 28 | lib-cov 29 | 30 | # Coverage directory used by tools like istanbul 31 | coverage 32 | 33 | # nyc test coverage 34 | .nyc_output 35 | 36 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 37 | .grunt 38 | 39 | # Bower dependency directory (https://bower.io/) 40 | bower_components 41 | 42 | # node-waf configuration 43 | .lock-wscript 44 | 45 | # Compiled binary addons (http://nodejs.org/api/addons.html) 46 | build/Release 47 | 48 | # Dependency directories 49 | node_modules/ 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional REPL history 58 | .node_repl_history 59 | 60 | # Output of 'npm pack' 61 | *.tgz 62 | 63 | # Yarn Integrity file 64 | .yarn-integrity 65 | 66 | # dotenv environment variables file 67 | .env 68 | # firebase.json 69 | test-params.env 70 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | firebase-debug.log* 8 | firebase-debug.*.log* 9 | 10 | # Firebase cache 11 | .firebase/ 12 | 13 | # Firebase config 14 | 15 | # Uncomment this if you'd like others to create their own Firebase project. 16 | # For a team working on the same Firebase project(s), it is recommended to leave 17 | # it commented so all members can deploy to the same project(s) in .firebaserc. 18 | # .firebaserc 19 | 20 | # Runtime data 21 | pids 22 | *.pid 23 | *.seed 24 | *.pid.lock 25 | 26 | # Directory for instrumented libs generated by jscoverage/JSCover 27 | lib-cov 28 | 29 | # Coverage directory used by tools like istanbul 30 | coverage 31 | 32 | # nyc test coverage 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 36 | .grunt 37 | 38 | # Bower dependency directory (https://bower.io/) 39 | bower_components 40 | 41 | # node-waf configuration 42 | .lock-wscript 43 | 44 | # Compiled binary addons (http://nodejs.org/api/addons.html) 45 | build/Release 46 | 47 | # Dependency directories 48 | node_modules/ 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Optional REPL history 57 | .node_repl_history 58 | 59 | # Output of 'npm pack' 60 | *.tgz 61 | 62 | # Yarn Integrity file 63 | .yarn-integrity 64 | 65 | # dotenv environment variables file 66 | .env 67 | *.secret -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/extensions/firestore-stripe-payments.env.local: -------------------------------------------------------------------------------- 1 | LOCATION=us-central1 2 | PROJECT_ID=demo-project 3 | PRODUCTS_COLLECTION=products 4 | CUSTOMERS_COLLECTION=customers 5 | SYNC_USERS_ON_CREATE=Sync 6 | DELETE_STRIPE_CUSTOMERS=Auto delete 7 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/extensions/firestore-stripe-payments.secret.local.example: -------------------------------------------------------------------------------- 1 | STRIPE_API_KEY= 2 | STRIPE_WEBHOOK_SECRET= 3 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": { 3 | "firestore-stripe-payments": ".." 4 | }, 5 | "storage": { 6 | "rules": "storage.rules" 7 | }, 8 | "emulators": { 9 | "hub": { 10 | "port": 4000 11 | }, 12 | "firestore": { 13 | "port": 8080 14 | }, 15 | "storage": { 16 | "port": 9199 17 | }, 18 | "auth": { 19 | "port": 9099 20 | }, 21 | "ui": { 22 | "enabled": true 23 | }, 24 | "functions": { 25 | "port": 5001 26 | } 27 | }, 28 | "firestore": { 29 | "rules": "firestore.rules", 30 | "indexes": "firestore.indexes.json" 31 | }, 32 | "functions": [ 33 | { 34 | "source": "functions", 35 | "codebase": "default", 36 | "ignore": [ 37 | "node_modules", 38 | ".git", 39 | "firebase-debug.log", 40 | "firebase-debug.*.log" 41 | ] 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/firestore.indexes.json: -------------------------------------------------------------------------------- 1 | { 2 | "indexes": [], 3 | "fieldOverrides": [] 4 | } 5 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/firestore.rules: -------------------------------------------------------------------------------- 1 | service cloud.firestore { 2 | match /databases/{database}/documents { 3 | match /{document=**} { 4 | // This rule allows anyone with your database reference to view, edit, 5 | // and delete all data in your database. It is useful for getting 6 | // started, but it is configured to expire after 30 days because it 7 | // leaves your app open to attackers. At that time, all client 8 | // requests to your database will be denied. 9 | // 10 | // Make sure to write security rules for your app before that time, or 11 | // else all client requests to your database will be denied until you 12 | // update your rules. 13 | allow read, write: if request.time < timestamp.date(2022, 7, 2); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/functions/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Import function triggers from their respective submodules: 3 | * 4 | * const {onCall} = require("firebase-functions/v2/https"); 5 | * const {onDocumentWritten} = require("firebase-functions/v2/firestore"); 6 | * 7 | * See a full list of supported triggers at https://firebase.google.com/docs/functions 8 | */ 9 | 10 | // Create and deploy your first functions 11 | // https://firebase.google.com/docs/functions/get-started 12 | 13 | // exports.helloWorld = onRequest((request, response) => { 14 | // logger.info("Hello logs!", {structuredData: true}); 15 | // response.send("Hello from Firebase!"); 16 | // }); 17 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "description": "Cloud Functions for Firebase", 4 | "scripts": { 5 | "serve": "firebase emulators:start --only functions", 6 | "shell": "firebase functions:shell", 7 | "start": "npm run shell", 8 | "deploy": "firebase deploy --only functions", 9 | "logs": "firebase functions:log" 10 | }, 11 | "engines": { 12 | "node": "18" 13 | }, 14 | "main": "index.js", 15 | "dependencies": { 16 | "firebase-admin": "^11.8.0", 17 | "firebase-functions": "^4.3.1" 18 | }, 19 | "devDependencies": { 20 | "firebase-functions-test": "^3.1.0" 21 | }, 22 | "private": true 23 | } 24 | -------------------------------------------------------------------------------- /firestore-stripe-payments/_emulator/storage.rules: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service firebase.storage { 3 | match /b/{bucket}/o { 4 | match /{allPaths=**} { 5 | allow read, write: if true; 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | firebase.json 3 | lib 4 | !package-lock.json -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": { 3 | "source": "functions" 4 | }, 5 | "emulators": { 6 | "functions": { 7 | "port": 5001 8 | }, 9 | "firestore": { 10 | "port": 8080 11 | }, 12 | "auth": { 13 | "port": 9099 14 | }, 15 | "ui": { 16 | "enabled": true 17 | } 18 | }, 19 | "firestore": { 20 | "rules": "firestore.rules", 21 | "indexes": "firestore.indexes.json" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/firestore.rules: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service cloud.firestore { 3 | 4 | match /databases/{database}/documents { 5 | 6 | match /products/{id} { 7 | allow read, write; 8 | } 9 | 10 | match /checkouts/{id} { 11 | allow read, write; 12 | } 13 | 14 | match /customers/{id} { 15 | allow read, write; 16 | } 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/collections.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import { DocumentReference, DocumentData } from '@google-cloud/firestore'; 3 | import { 4 | waitForDocumentToExistInCollection, 5 | waitForDocumentToExistWithField, 6 | } from './utils'; 7 | import { UserRecord } from 'firebase-functions/v1/auth'; 8 | import setupEmulator from './setupEmulator'; 9 | 10 | if (admin.apps.length === 0) { 11 | admin.initializeApp({ projectId: 'demo-project' }); 12 | } 13 | 14 | setupEmulator(); 15 | 16 | const firestore = admin.firestore(); 17 | 18 | function customerCollection() { 19 | return firestore.collection('customers'); 20 | } 21 | 22 | function paymentsCollection(userId) { 23 | return firestore.collection('customers').doc(userId).collection('payments'); 24 | } 25 | 26 | export async function findCustomerInCollection(user: UserRecord) { 27 | const doc = firestore.collection('customers').doc(user.uid); 28 | 29 | const customerDoc = await waitForDocumentToExistWithField( 30 | doc, 31 | 'stripeId', 32 | 60000 33 | ); 34 | 35 | return Promise.resolve({ docId: user.uid, ...customerDoc.data() }); 36 | } 37 | 38 | export async function findCustomerPaymentInCollection( 39 | userId: string, 40 | stripeId: string 41 | ) { 42 | const paymentDoc: DocumentData = await waitForDocumentToExistInCollection( 43 | paymentsCollection(userId), 44 | 'customer', 45 | stripeId 46 | ); 47 | 48 | const paymentRef = paymentsCollection(userId).doc(paymentDoc.doc.id); 49 | 50 | const updatedPaymentDoc = await waitForDocumentToExistWithField( 51 | paymentRef, 52 | 'prices' 53 | ); 54 | 55 | return updatedPaymentDoc.data(); 56 | } 57 | 58 | export async function createCheckoutSession(userId, subscription) { 59 | const checkoutSessionCollection = customerCollection() 60 | .doc(userId) 61 | .collection('checkout_sessions'); 62 | 63 | const checkoutSessionDocument: DocumentReference = 64 | await checkoutSessionCollection.add({ 65 | success_url: 'http://test.com/success', 66 | cancel_url: 'http://test.com/cancel', 67 | ...subscription, 68 | }); 69 | 70 | const checkoutSessionDoc = await waitForDocumentToExistWithField( 71 | checkoutSessionDocument, 72 | 'created' 73 | ); 74 | 75 | return checkoutSessionDoc.data(); 76 | } 77 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/forms/runCheckout.ts: -------------------------------------------------------------------------------- 1 | import { chromium } from 'playwright'; 2 | 3 | export default async (url: string): Promise => { 4 | console.info('Running checkout form in headless mode...'); 5 | const browser = await chromium.launch(); 6 | try { 7 | const context = await browser.newContext(); 8 | const page = await context.newPage(); 9 | 10 | await page.goto(url, { 11 | waitUntil: 'networkidle', 12 | timeout: 120000, 13 | }); 14 | 15 | await page.focus('#cardNumber'); 16 | await page.keyboard.type('4242424242424242', { delay: 100 }); 17 | await page.keyboard.press('Enter'); 18 | 19 | await page.focus('#cardExpiry'); 20 | await page.keyboard.type('1224'); 21 | 22 | await page.focus('#cardCvc'); 23 | await page.keyboard.type('123'); 24 | 25 | await page.focus('#billingName'); 26 | await page.keyboard.type('testing'); 27 | 28 | await page.focus('#billingAddressLine1'); 29 | await page.keyboard.type('1600 Amphitheatre Parkwa'); 30 | await page.keyboard.press('Enter'); 31 | 32 | await page.focus('#billingLocality'); 33 | await page.keyboard.type('Mountain View'); 34 | 35 | await page.focus('#billingPostalCode'); 36 | await page.keyboard.type('CA 94043'); 37 | await page.keyboard.press('Enter'); 38 | 39 | await page.waitForLoadState('networkidle'); 40 | await browser.close(); 41 | } catch (exception) { 42 | console.error('Error during checkout automation:', exception); 43 | } finally { 44 | await browser.close(); 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/setupEmulator.ts: -------------------------------------------------------------------------------- 1 | export default () => { 2 | process.env.FIRESTORE_EMULATOR_HOST = '127.0.0.1:8080'; 3 | process.env.FIREBASE_FIRESTORE_EMULATOR_ADDRESS = '127.0.0.1:8080'; 4 | process.env.FIREBASE_AUTH_EMULATOR_HOST = '127.0.0.1:9099'; 5 | }; 6 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/setupEnvironment.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import dotenv from 'dotenv'; 3 | 4 | export const pathToenvFile = path.resolve( 5 | __dirname, 6 | '../../../_emulator/extensions/firestore-stripe-payments.env.local' 7 | ); 8 | 9 | export const pathTosecretsFile = path.resolve( 10 | __dirname, 11 | '../../../_emulator/extensions/firestore-stripe-payments.secret.local' 12 | ); 13 | 14 | export const setupEnvironment = () => { 15 | dotenv.config({ 16 | path: pathToenvFile, 17 | }); 18 | console.log('CUSTOMERS_COLLECTION:', process.env.CUSTOMERS_COLLECTION); 19 | 20 | console.log('Loading secrets file from:', pathTosecretsFile); 21 | dotenv.config({ 22 | path: pathTosecretsFile, 23 | }); 24 | console.log('STRIPE_API_KEY exists:', !!process.env.STRIPE_API_KEY); 25 | }; 26 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/setupProducts.ts: -------------------------------------------------------------------------------- 1 | import { faker } from '@faker-js/faker'; 2 | import config from '../../lib/config'; 3 | import { Product, Subscription } from '../../src/interfaces'; 4 | 5 | const stripe = require('stripe')(config.stripeSecretKey); 6 | 7 | export const generateRecurringPrice = async () => { 8 | const name = faker.commerce.product(); 9 | const product = await stripe.products.create({ 10 | name, 11 | description: `Description for ${name}`, 12 | }); 13 | 14 | const price = await stripe.prices.create({ 15 | unit_amount: 1000, 16 | currency: 'gbp', 17 | recurring: { interval: 'month' }, 18 | product: product.id, 19 | }); 20 | 21 | return price; 22 | }; 23 | 24 | export const createRandomProduct = async (): Promise => { 25 | const name = faker.commerce.product(); 26 | const product: Product = await stripe.products.create({ 27 | name, 28 | description: `Description for ${name}`, 29 | }); 30 | 31 | return Promise.resolve(product); 32 | }; 33 | 34 | export const updateProduct = async (id, update): Promise => { 35 | const product: Product = await stripe.products.update(id, { 36 | ...update, 37 | }); 38 | 39 | return Promise.resolve(product); 40 | }; 41 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/stripeApi/customers.ts: -------------------------------------------------------------------------------- 1 | import config from '../../../lib/config'; 2 | const stripe = require('stripe')(config.stripeSecretKey); 3 | 4 | export const findCustomer = async (id) => { 5 | return stripe.customers.retrieve(id); 6 | }; 7 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/helpers/stripeApi/subscriptions.ts: -------------------------------------------------------------------------------- 1 | import { faker } from '@faker-js/faker'; 2 | import config from '../../../lib/config'; 3 | import { Product, Subscription } from '../../../src/interfaces'; 4 | 5 | const stripe = require('stripe')(config.stripeSecretKey); 6 | 7 | export const createRandomSubscription = async ( 8 | customer 9 | ): Promise => { 10 | const name = faker.commerce.product(); 11 | 12 | /** create a product */ 13 | const product: Product = await stripe.products.create({ 14 | name, 15 | description: `Description for ${name}`, 16 | }); 17 | 18 | /** create a price */ 19 | const price = await stripe.prices.create({ 20 | unit_amount: 1000, 21 | currency: 'gbp', 22 | recurring: { interval: 'month' }, 23 | product: product.id, 24 | }); 25 | 26 | /** Attach the test PaymentMethod to the customer */ 27 | const attachedPaymentMethod = await stripe.paymentMethods.attach( 28 | 'pm_card_visa', 29 | { customer: customer } 30 | ); 31 | 32 | /** Update the customer's default PaymentMethod */ 33 | await stripe.customers.update(customer, { 34 | invoice_settings: { default_payment_method: attachedPaymentMethod.id }, 35 | }); 36 | 37 | /** Create a subscription */ 38 | const subscription: Subscription = await stripe.subscriptions.create({ 39 | customer: customer, 40 | items: [{ price: price.id }], 41 | }); 42 | 43 | return Promise.resolve(subscription); 44 | }; 45 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/jest.global-teardown.ts: -------------------------------------------------------------------------------- 1 | export default async function globalTeardown() { 2 | // Skip Stripe setup for non-integration tests 3 | if (process.env.INTEGRATION_TEST !== 'true') { 4 | console.log('Skipping Stripe setup for unit tests'); 5 | return; 6 | } 7 | if (global.stripeListenProcess) { 8 | global.stripeListenProcess.kill(); 9 | global.stripeListenProcess = null; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/jest.setup.ts: -------------------------------------------------------------------------------- 1 | (async function () { 2 | // Skip Stripe setup for non-integration tests 3 | if (process.env.INTEGRATION_TEST !== 'true') { 4 | console.log('Skipping Stripe setup for unit tests'); 5 | return; 6 | } 7 | try { 8 | // Verify critical environment variables are set 9 | if (!process.env.CUSTOMERS_COLLECTION) { 10 | throw new Error('CUSTOMERS_COLLECTION environment variable is not set'); 11 | } 12 | if (!process.env.PROJECT_ID) { 13 | throw new Error('PROJECT_ID environment variable is not set'); 14 | } 15 | } catch (error) { 16 | console.error('Failed to setup test environment:', error); 17 | process.exit(1); 18 | } 19 | })(); 20 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/checkoutsessions/subscriptionCheckoutSessions.test.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import runCheckout from '../../helpers/forms/runCheckout'; 3 | 4 | import { UserRecord } from 'firebase-functions/v1/auth'; 5 | import { Subscription } from '../../../src/interfaces'; 6 | import setupEmulator from '../../helpers/setupEmulator'; 7 | import { createRandomSubscription } from '../../helpers/stripeApi/subscriptions'; 8 | import { createFirebaseUser } from '../../helpers/utils'; 9 | 10 | import { 11 | findCustomerInCollection, 12 | createCheckoutSession, 13 | findCustomerPaymentInCollection, 14 | } from '../../helpers/collections'; 15 | 16 | if (admin.apps.length === 0) { 17 | admin.initializeApp({ projectId: 'demo-project' }); 18 | } 19 | 20 | setupEmulator(); 21 | 22 | describe('createSubscriptionCheckoutSession', () => { 23 | let user: UserRecord; 24 | 25 | beforeEach(async () => { 26 | user = await createFirebaseUser(); 27 | }); 28 | 29 | afterEach(async () => { 30 | await admin.auth().deleteUser(user.uid); 31 | }); 32 | 33 | describe.skip('using a web client', () => { 34 | test('successfully creates a subscription based checkout session', async () => { 35 | /** find the customer document */ 36 | const { docId, stripeId } = await findCustomerInCollection(user); 37 | /** create a new subscription */ 38 | const stripeSubscription: Subscription = await createRandomSubscription( 39 | stripeId 40 | ); 41 | 42 | /** create a new checkout session */ 43 | const { client, success_url, url } = await createCheckoutSession(docId, { 44 | line_items: [ 45 | { 46 | //@ts-ignore 47 | price: stripeSubscription.items.data[0].price.id, 48 | quantity: 1, 49 | }, 50 | ], 51 | }); 52 | 53 | expect(client).toBe('web'); 54 | expect(success_url).toBe('http://test.com/success'); 55 | 56 | // /** complete the checkout form */ 57 | await runCheckout(url); 58 | 59 | // /** find user payment */ 60 | const { prices } = await findCustomerPaymentInCollection(docId, stripeId); 61 | 62 | // /** extract prices from array */ 63 | // const priceRef = await prices[0].get(); 64 | // const price = priceRef.id; 65 | 66 | // /** assert values */ 67 | // //@ts-ignore 68 | // expect(price).toEqual(stripeSubscription.items.data[0].price.id); 69 | }); 70 | }); 71 | }); 72 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/customers/createCustomer.test.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import { DocumentData } from '@google-cloud/firestore'; 3 | 4 | import setupEmulator from '../../helpers/setupEmulator'; 5 | import { UserRecord } from 'firebase-functions/v1/auth'; 6 | import { 7 | createFirebaseUser, 8 | waitForDocumentToExistInCollection, 9 | } from '../../helpers/utils'; 10 | 11 | admin.initializeApp({ projectId: 'demo-project' }); 12 | setupEmulator(); 13 | 14 | const firestore = admin.firestore(); 15 | 16 | describe('createCustomer', () => { 17 | let user: UserRecord; 18 | beforeEach(async () => { 19 | user = await createFirebaseUser(); 20 | }); 21 | 22 | test('successfully creates a new customers', async () => { 23 | const collection = firestore.collection('customers'); 24 | 25 | const customer: DocumentData = await waitForDocumentToExistInCollection( 26 | collection, 27 | 'email', 28 | user.email 29 | ); 30 | 31 | const doc = collection.doc(customer.doc.id); 32 | 33 | expect(doc.id).toBeDefined(); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/customers/customerDataDeleted.test.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import { DocumentData } from '@google-cloud/firestore'; 3 | import setupEmulator from './../../helpers/setupEmulator'; 4 | import { findCustomer } from './../../helpers/stripeApi/customers'; 5 | import { 6 | repeat, 7 | waitForDocumentToExistWithField, 8 | waitForDocumentToExistInCollection, 9 | createFirebaseUser, 10 | } from './../../helpers/utils'; 11 | import { UserRecord } from 'firebase-functions/v1/auth'; 12 | 13 | admin.initializeApp({ projectId: 'demo-project' }); 14 | setupEmulator(); 15 | 16 | const firestore = admin.firestore(); 17 | 18 | describe('customerDataDeleted', () => { 19 | let user: UserRecord; 20 | beforeEach(async () => { 21 | user = await createFirebaseUser(); 22 | }); 23 | 24 | test('successfully deletes a stripe customer', async () => { 25 | const collection = firestore.collection('customers'); 26 | 27 | const customer: DocumentData = await waitForDocumentToExistInCollection( 28 | collection, 29 | 'email', 30 | user.email 31 | ); 32 | 33 | const doc = collection.doc(customer.doc.id); 34 | const userDoc = await waitForDocumentToExistWithField(doc, 'stripeId'); 35 | 36 | await admin.auth().deleteUser(customer.doc.id); 37 | 38 | const check = ($) => $?.deleted; 39 | const toRun = () => findCustomer(userDoc.data().stripeId); 40 | await repeat(toRun, check, 5, 2000); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/portalLinks/createPortalLink.test.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import { DocumentData } from '@google-cloud/firestore'; 3 | import fft from 'firebase-functions-test'; 4 | import * as cloudFunctions from '../../../src'; 5 | import setupEmulator from '../../helpers/setupEmulator'; 6 | 7 | import { 8 | createFirebaseUser, 9 | waitForDocumentToExistInCollection, 10 | waitForDocumentToExistWithField, 11 | } from '../../helpers/utils'; 12 | import { UserRecord } from 'firebase-functions/v1/auth'; 13 | 14 | const testEnv = fft({ projectId: 'demo-project' }); 15 | const createPortalLink = testEnv.wrap(cloudFunctions.createPortalLink); 16 | setupEmulator(); 17 | 18 | const firestore = admin.firestore(); 19 | 20 | function request(uid: string, returnUrl: string) { 21 | return createPortalLink( 22 | { returnUrl }, 23 | { 24 | auth: { 25 | uid, 26 | token: 'test', 27 | }, 28 | } 29 | ); 30 | } 31 | 32 | describe('createPortalLink', () => { 33 | let user: UserRecord; 34 | beforeEach(async () => { 35 | user = await createFirebaseUser(); 36 | }); 37 | 38 | afterEach(async () => { 39 | await admin.auth().deleteUser(user.uid); 40 | }); 41 | 42 | test('successfully creates a new portal link', async () => { 43 | const collection = firestore.collection('customers'); 44 | 45 | const customer: DocumentData = await waitForDocumentToExistInCollection( 46 | collection, 47 | 'email', 48 | user.email 49 | ); 50 | 51 | const doc = collection.doc(customer.doc.id); 52 | const customerDoc = await waitForDocumentToExistWithField(doc, 'stripeId'); 53 | 54 | const returnUrl = 'http://test.com'; 55 | const result = await request(customerDoc.id, returnUrl); 56 | 57 | expect(result.object).toBe('billing_portal.session'); 58 | expect(result.customer).toBe(customerDoc.data().stripeId); 59 | expect(result.livemode).toBe(false); 60 | expect(result.return_url).toBe(returnUrl); 61 | expect(result.url).toBeDefined(); 62 | }); 63 | }); 64 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/unit/handlers/webhook-events.test.ts: -------------------------------------------------------------------------------- 1 | import * as logs from '../../../../src/logs'; 2 | import { handleWebhookEvents } from '../../../../src/handlers/webhook-events'; 3 | import * as httpMocks from 'node-mocks-http'; 4 | 5 | // Firebase functions will add rawBody to the request object before it reaches the handler 6 | declare module 'express' { 7 | interface Request { 8 | rawBody: Buffer; 9 | } 10 | } 11 | 12 | jest.mock('../../../../src/logs', () => ({ 13 | startWebhookEventProcessing: jest.fn(), 14 | webhookHandlerError: jest.fn(), 15 | webhookHandlerSucceeded: jest.fn(), 16 | badWebhookSecret: jest.fn(), 17 | })); 18 | 19 | jest.mock('../../../../src/config', () => ({ 20 | stripeWebhookSecret: 'test-webhook-secret', 21 | customersCollectionPath: 'customers', 22 | stripe: { 23 | webhooks: { 24 | constructEvent: jest.fn(), 25 | }, 26 | paymentIntents: { 27 | retrieve: jest.fn(), 28 | }, 29 | }, 30 | eventChannel: null, 31 | })); 32 | 33 | jest.mock('firebase-admin', () => ({ 34 | initializeApp: jest.fn(), 35 | firestore: jest.fn(() => { 36 | throw new Error('Firestore operation failed'); 37 | }), 38 | })); 39 | 40 | describe('Webhook Events Handler', () => { 41 | beforeEach(() => { 42 | jest.clearAllMocks(); 43 | 44 | const config = require('../../../../src/config'); 45 | config.stripe.webhooks.constructEvent.mockReturnValue({ 46 | id: 'evt_123', 47 | type: 'product.created', 48 | data: { 49 | object: { id: 'prod_123' }, 50 | }, 51 | }); 52 | }); 53 | 54 | it('should return 500 status when webhook handler fails', async () => { 55 | const mockRequest = httpMocks.createRequest({ 56 | rawBody: Buffer.from('test-body'), 57 | headers: { 58 | 'stripe-signature': 'test-signature', 59 | }, 60 | }); 61 | 62 | const mockResponse = httpMocks.createResponse(); 63 | 64 | await handleWebhookEvents(mockRequest, mockResponse); 65 | 66 | expect(logs.webhookHandlerError).toHaveBeenCalledWith( 67 | expect.any(Error), 68 | 'evt_123', 69 | 'product.created' 70 | ); 71 | 72 | expect(mockResponse.statusCode).toBe(500); 73 | 74 | const responseData = JSON.parse(mockResponse._getData()); 75 | expect(responseData).toEqual({ 76 | error: 'Webhook handler failed. View function logs in Firebase.', 77 | }); 78 | }); 79 | }); 80 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/webhookevents/handleWebhookEvents.test.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import { DocumentData } from '@google-cloud/firestore'; 3 | import { Product } from '../../../src/interfaces'; 4 | import setupEmulator from '../../helpers/setupEmulator'; 5 | 6 | import { 7 | createRandomProduct, 8 | updateProduct, 9 | } from '../../helpers/setupProducts'; 10 | import { 11 | waitForDocumentToExistInCollection, 12 | waitForDocumentUpdate, 13 | } from '../../helpers/utils'; 14 | 15 | admin.initializeApp({ projectId: 'demo-project' }); 16 | setupEmulator(); 17 | 18 | const firestore = admin.firestore(); 19 | 20 | describe('webhook events', () => { 21 | describe('products', () => { 22 | let product: Product; 23 | 24 | /** 25 | * Skipping tests for now, these work locally but never on CI 26 | * Could be an environmental issue 27 | * TODO: Fix this 28 | */ 29 | beforeEach(async () => { 30 | product = await createRandomProduct(); 31 | }); 32 | xtest('successfully creates a new product', async () => { 33 | const collection = firestore.collection('products'); 34 | const productDoc: DocumentData = await waitForDocumentToExistInCollection( 35 | collection, 36 | 'name', 37 | product.name 38 | ); 39 | 40 | expect(productDoc.doc.data().name).toBe(product.name); 41 | }); 42 | 43 | xtest('successfully updates an existing product', async () => { 44 | const updatedProduct: Product = await updateProduct(product.id, { 45 | name: `updated_${product.name}`, 46 | }); 47 | 48 | const doc = firestore.collection('products').doc(product.id); 49 | 50 | const updated = await waitForDocumentUpdate( 51 | doc, 52 | 'name', 53 | `updated_${product.name}` 54 | ); 55 | 56 | expect(updated.data().name).toBe(updatedProduct.name); 57 | }); 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/__tests__/tests/webhookevents/subscriptions.test.ts: -------------------------------------------------------------------------------- 1 | import * as admin from 'firebase-admin'; 2 | import { DocumentData } from '@google-cloud/firestore'; 3 | import { Subscription } from '../../../src/interfaces'; 4 | import setupEmulator from '../../helpers/setupEmulator'; 5 | 6 | import { createRandomSubscription } from '../../helpers/stripeApi/subscriptions'; 7 | import { 8 | createFirebaseUser, 9 | waitForDocumentToExistInCollection, 10 | waitForDocumentToExistWithField, 11 | } from '../../helpers/utils'; 12 | import { UserRecord } from 'firebase-functions/v1/auth'; 13 | 14 | admin.initializeApp({ projectId: 'demo-project' }); 15 | setupEmulator(); 16 | 17 | const firestore = admin.firestore(); 18 | 19 | describe('subscription webhook events', () => { 20 | let user: UserRecord; 21 | 22 | beforeEach(async () => { 23 | user = await createFirebaseUser(); 24 | }); 25 | 26 | afterEach(async () => { 27 | await admin.auth().deleteUser(user.uid); 28 | }); 29 | 30 | describe('successfully creates a subscription', () => { 31 | // TODO: Fix this test 32 | test.skip('successfully creates a new subscription', async () => { 33 | const collection = firestore.collection('customers'); 34 | 35 | const customer: DocumentData = await waitForDocumentToExistInCollection( 36 | collection, 37 | 'email', 38 | user.email 39 | ); 40 | 41 | const doc = collection.doc(customer.doc.id); 42 | const customerDoc = await waitForDocumentToExistWithField( 43 | doc, 44 | 'stripeId' 45 | ); 46 | 47 | const { stripeId } = customerDoc.data(); 48 | 49 | const stripeSubscription: Subscription = await createRandomSubscription( 50 | stripeId 51 | ); 52 | 53 | const subscriptionCollection = firestore 54 | .collection('customers') 55 | .doc(user.uid) 56 | .collection('payments'); 57 | 58 | const subscriptionDoc: DocumentData = 59 | await waitForDocumentToExistInCollection( 60 | subscriptionCollection, 61 | 'invoice', 62 | stripeSubscription.latest_invoice 63 | ); 64 | 65 | const { invoice } = subscriptionDoc.doc.data(); 66 | 67 | expect(invoice).toBeDefined(); 68 | }, 20000); 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/jest.config.js: -------------------------------------------------------------------------------- 1 | const packageJson = require('./package.json'); 2 | 3 | module.exports = { 4 | displayName: packageJson.name, 5 | testEnvironment: 'node', 6 | rootDir: './', 7 | transform: { 8 | '^.+\\.ts$': [ 9 | 'ts-jest', 10 | { 11 | tsconfig: '/tsconfig.json', 12 | }, 13 | ], 14 | }, 15 | globalSetup: '/__tests__/jest.global-setup.ts', 16 | globalTeardown: '/__tests__/jest.global-teardown.ts', 17 | testMatch: 18 | process.env.INTEGRATION_TEST === 'true' 19 | ? ['**/__tests__/tests/**/*.test.ts'] 20 | : ['**/__tests__/tests/unit/**/*.test.ts'], 21 | testTimeout: 120000, 22 | collectCoverage: true, 23 | collectCoverageFrom: [ 24 | '**/*.{ts,tsx}', 25 | '!**/node_modules/**', 26 | '!**/test-data/**', 27 | ], 28 | moduleNameMapper: { 29 | 'firebase-admin/eventarc': 30 | '/node_modules/firebase-admin/lib/eventarc', 31 | 'firebase-admin/auth': '/node_modules/firebase-admin/lib/auth', 32 | 'firebase-admin/app': '/node_modules/firebase-admin/lib/app', 33 | 'firebase-admin/database': 34 | '/node_modules/firebase-admin/lib/database', 35 | 'firebase-admin/firestore': 36 | '/node_modules/firebase-admin/lib/firestore', 37 | 'firebase-admin/functions': 38 | '/node_modules/firebase-admin/lib/functions', 39 | 'firebase-functions/v2': '/node_modules/firebase-functions/lib/v2', 40 | 'firebase-admin/extensions': 41 | '/node_modules/firebase-admin/lib/extensions', 42 | }, 43 | }; 44 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firestore-stripe-payments", 3 | "engines": { 4 | "node": "20" 5 | }, 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "prepare": "npm run build", 9 | "clean": "rimraf lib", 10 | "build": "tsc -p tsconfig.build.json", 11 | "build:watch": "tsc -p tsconfig.build.json --watch", 12 | "compile": "tsc", 13 | "generate-readme": "firebase ext:info .. --markdown > ../README.md", 14 | "test": "cd ../_emulator && firebase emulators:exec -P demo-project \"INTEGRATION_TEST=true jest --config=../functions/jest.config.js\"", 15 | "test:unit": "jest --config=jest.config.js", 16 | "start:emulator": "cd ../_emulator && firebase emulators:start -P demo-project", 17 | "exec:emulator": "cd ../_emulator && firebase emulators:exec \"../runTests.sh\" -P demo-project", 18 | "exec:emulator:watch": "cd ../_emulator && firebase emulators:exec \"../runTestsWatch.sh\" -P demo-project", 19 | "setup:webhooks": "ts-node ./__tests__/helpers/setupProxy.ts", 20 | "publish-new-version": "firebase ext:dev:upload invertase/firestore-stripe-payments --repo=https://github.com/invertase/stripe-firebase-extensions --root=firestore-stripe-payments --ref=master --project invertase-firebase-extensions" 21 | }, 22 | "author": "Stripe (https://stripe.com/)", 23 | "license": "Apache-2.0", 24 | "dependencies": { 25 | "firebase-admin": "^13.4.0", 26 | "firebase-functions": "^6.3.2", 27 | "stripe": "11.15.0", 28 | "typescript": "^4.9.5" 29 | }, 30 | "devDependencies": { 31 | "@faker-js/faker": "^6.0.0", 32 | "@types/express": "^4.17.13", 33 | "@types/jest": "^29.5.14", 34 | "dotenv": "^16.5.0", 35 | "envfile": "^6.17.0", 36 | "firebase-functions-test": "^3.4.1", 37 | "jest": "^29.7.0", 38 | "mocked-env": "^1.3.5", 39 | "node-mocks-http": "^1.17.2", 40 | "playwright": "^1.52.0", 41 | "rimraf": "^6.0.1", 42 | "ts-jest": "^29.3.4", 43 | "ts-node": "^10.9.2" 44 | }, 45 | "prettier": { 46 | "singleQuote": true, 47 | "printWidth": 80 48 | }, 49 | "private": true 50 | } 51 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/src/config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Stripe, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { getEventarc } from 'firebase-admin/eventarc'; 18 | import Stripe from 'stripe'; 19 | 20 | export interface ExtensionConfig { 21 | stripeSecretKey: string; 22 | stripeWebhookSecret?: string; 23 | productsCollectionPath: string; 24 | customersCollectionPath: string; 25 | stripeConfigCollectionPath?: string; 26 | syncUsersOnCreate: boolean; 27 | autoDeleteUsers: boolean; 28 | minCheckoutInstances: number; 29 | } 30 | 31 | const config: ExtensionConfig = { 32 | stripeSecretKey: process.env.STRIPE_API_KEY as string, 33 | stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET, 34 | productsCollectionPath: process.env.PRODUCTS_COLLECTION as string, 35 | customersCollectionPath: process.env.CUSTOMERS_COLLECTION as string, 36 | stripeConfigCollectionPath: process.env.STRIPE_CONFIG_COLLECTION, 37 | syncUsersOnCreate: process.env.SYNC_USERS_ON_CREATE === 'Sync', 38 | autoDeleteUsers: process.env.DELETE_STRIPE_CUSTOMERS === 'Auto delete', 39 | minCheckoutInstances: 40 | Number(process.env.CREATE_CHECKOUT_SESSION_MIN_INSTANCES) ?? 0, 41 | }; 42 | 43 | export const apiVersion = '2022-11-15'; 44 | 45 | export const stripe = new Stripe(config.stripeSecretKey, { 46 | apiVersion, 47 | // Register extension as a Stripe plugin 48 | // https://stripe.com/docs/building-plugins#setappinfo 49 | appInfo: { 50 | name: 'Firebase Invertase firestore-stripe-payments', 51 | version: '0.3.5', 52 | }, 53 | }); 54 | 55 | export const eventChannel = 56 | process.env.EVENTARC_CHANNEL && 57 | getEventarc().channel(process.env.EVENTARC_CHANNEL, { 58 | allowedEventTypes: process.env.EXT_SELECTED_EVENTS, 59 | }); 60 | 61 | export default config; 62 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "exclude": ["node_modules", "__tests__"] 7 | } 8 | -------------------------------------------------------------------------------- /firestore-stripe-payments/functions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "lib": ["ES2020"], 5 | "module": "commonjs", 6 | "noImplicitReturns": true, 7 | "esModuleInterop": true, 8 | "sourceMap": false, 9 | "outDir": "lib", 10 | "skipLibCheck": true, 11 | "strictNullChecks": true, 12 | "types": ["node", "jest"], 13 | "typeRoots": ["./node_modules/@types"] 14 | }, 15 | "compileOnSave": true, 16 | "include": ["src", "./__tests__"], 17 | "exclude": ["node_modules"] 18 | } 19 | -------------------------------------------------------------------------------- /firestore-stripe-payments/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/invertase/stripe-firebase-extensions/28e05458b1406f9eb7797d5317ac6e1c525a3aa2/firestore-stripe-payments/icon.png -------------------------------------------------------------------------------- /firestore-stripe-payments/runTests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Wait for Firebase emulator to be fully initialized 4 | HOST="localhost" 5 | PORT=5001 6 | counter=0 7 | max_attempts=30 8 | 9 | echo "Waiting for Firebase emulator to be ready..." 10 | 11 | while [[ $counter -lt $max_attempts ]]; do 12 | nc -z $HOST $PORT 13 | result=$? 14 | if [[ $result -eq 0 ]]; then 15 | echo "Firebase emulator on $HOST:$PORT is up!" 16 | break 17 | fi 18 | echo "Waiting for Firebase emulator on $HOST:$PORT... Attempt $((counter+1))/$max_attempts" 19 | sleep 1 20 | ((counter++)) 21 | done 22 | 23 | if [[ $counter -eq $max_attempts ]]; then 24 | echo "Firebase emulator on $HOST:$PORT did not start within $max_attempts attempts." 25 | exit 1 26 | fi 27 | 28 | # Once Firebase emulator is confirmed running, install and start cloudflared 29 | echo "Installing and starting cloudflared..." 30 | sudo cloudflared service install $CLOUDFLARE_SECRET 31 | 32 | # Introduce a delay to ensure cloudflared is properly initialized 33 | echo "Waiting for cloudflared to initialize..." 34 | sleep 60 # 1 minute delay. Adjust this value if needed. 35 | 36 | # Step 2: Run tests 37 | cd ../functions 38 | jest --coverage -------------------------------------------------------------------------------- /firestore-stripe-payments/runTestsWatch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | cd ../functions 3 | jest --watchAll -------------------------------------------------------------------------------- /firestore-stripe-subscriptions/README.md: -------------------------------------------------------------------------------- 1 | # This Extension Has Moved 2 | 3 | **firestore-stripe-subscriptions** is now **firestore-stripe-payments**, available **[here](https://github.com/stripe/stripe-firebase-extensions/tree/next/firestore-stripe-payments)** 4 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | firestore-debug.log 2 | lib 3 | node_modules 4 | temp 5 | invertase-firestore-stripe-payments-0.0.8.tgz -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/NOTICE.txt: -------------------------------------------------------------------------------- 1 | Firestore Stripe Payments Web SDK 2 | Copyright 2021 Stripe, Inc. 3 | 4 | This product includes software developed at 5 | Google Firebase (https://firebase.google.com/). 6 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | firebase-debug.log* 8 | firebase-debug.*.log* 9 | 10 | # Firebase cache 11 | .firebase/ 12 | 13 | # Firebase config 14 | 15 | # Uncomment this if you'd like others to create their own Firebase project. 16 | # For a team working on the same Firebase project(s), it is recommended to leave 17 | # it commented so all members can deploy to the same project(s) in .firebaserc. 18 | # .firebaserc 19 | 20 | # Runtime data 21 | pids 22 | *.pid 23 | *.seed 24 | *.pid.lock 25 | 26 | # Directory for instrumented libs generated by jscoverage/JSCover 27 | lib-cov 28 | 29 | # Coverage directory used by tools like istanbul 30 | coverage 31 | 32 | # nyc test coverage 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 36 | .grunt 37 | 38 | # Bower dependency directory (https://bower.io/) 39 | bower_components 40 | 41 | # node-waf configuration 42 | .lock-wscript 43 | 44 | # Compiled binary addons (http://nodejs.org/api/addons.html) 45 | build/Release 46 | 47 | # Dependency directories 48 | node_modules/ 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Optional REPL history 57 | .node_repl_history 58 | 59 | # Output of 'npm pack' 60 | *.tgz 61 | 62 | # Yarn Integrity file 63 | .yarn-integrity 64 | 65 | # dotenv environment variables file 66 | .env 67 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/extensions/firestore-stripe-payments.env.local: -------------------------------------------------------------------------------- 1 | LOCATION=us-central1 2 | PROJECT_ID=demo-project 3 | PRODUCTS_COLLECTION=products 4 | CUSTOMERS_COLLECTION=customers 5 | SYNC_USERS_ON_CREATE=Sync 6 | DELETE_STRIPE_CUSTOMERS=Auto delete -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/extensions/firestore-stripe-payments.secret.local.example: -------------------------------------------------------------------------------- 1 | STRIPE_API_KEY= 2 | STRIPE_WEBHOOK_SECRET= 3 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensions": { 3 | "firestore-stripe-payments": "../../firestore-stripe-payments" 4 | }, 5 | "emulators": { 6 | "hub": { 7 | "port": 4000 8 | }, 9 | "firestore": { 10 | "port": 8080 11 | }, 12 | "auth": { 13 | "port": 9099 14 | }, 15 | "ui": { 16 | "enabled": true 17 | }, 18 | "functions": { 19 | "port": 5001 20 | } 21 | }, 22 | "firestore": { 23 | "rules": "firestore.rules", 24 | "indexes": "firestore.indexes.json" 25 | }, 26 | "functions": [ 27 | { 28 | "source": "functions", 29 | "codebase": "default", 30 | "ignore": [ 31 | "node_modules", 32 | ".git", 33 | "firebase-debug.log", 34 | "firebase-debug.*.log" 35 | ] 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/firestore.rules: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service cloud.firestore { 3 | match /databases/{database}/documents { 4 | match /{document=**} { 5 | allow read, write: if true; 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/functions/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/functions/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Import function triggers from their respective submodules: 3 | * 4 | * const {onCall} = require("firebase-functions/v2/https"); 5 | * const {onDocumentWritten} = require("firebase-functions/v2/firestore"); 6 | * 7 | * See a full list of supported triggers at https://firebase.google.com/docs/functions 8 | */ 9 | 10 | // Create and deploy your first functions 11 | // https://firebase.google.com/docs/functions/get-started 12 | 13 | // exports.helloWorld = onRequest((request, response) => { 14 | // logger.info("Hello logs!", {structuredData: true}); 15 | // response.send("Hello from Firebase!"); 16 | // }); 17 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/_emulator/functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "description": "Cloud Functions for Firebase", 4 | "scripts": { 5 | "serve": "firebase emulators:start --only functions", 6 | "shell": "firebase functions:shell", 7 | "start": "npm run shell", 8 | "deploy": "firebase deploy --only functions", 9 | "logs": "firebase functions:log" 10 | }, 11 | "engines": { 12 | "node": "20" 13 | }, 14 | "main": "index.js", 15 | "dependencies": { 16 | "firebase-admin": "^11.8.0", 17 | "firebase-functions": "^4.3.1" 18 | }, 19 | "devDependencies": { 20 | "firebase-functions-test": "^3.1.0" 21 | }, 22 | "private": true 23 | } 24 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | firebase-config.js 3 | invertase-firestore-stripe-payments.tgz -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/cjs/README.md: -------------------------------------------------------------------------------- 1 | # CommonJS Example 2 | 3 | This example demonstrates how to use the Firestore Stripe Payments SDK with CommonJS and Webpack. 4 | 5 | ## Setup 6 | 7 | 0. Ensure the web SDK is packed, or install a published version >= v0.0.8 8 | 9 | 1. Copy `src/firebase-config.example.js` to `src/firebase-config.js` and fill in your Firebase configuration: 10 | ```bash 11 | cp src/firebase-config.example.js src/firebase-config.js 12 | ``` 13 | 14 | 2. Install dependencies: 15 | ```bash 16 | npm install 17 | ``` 18 | 19 | 3. Run the development server: 20 | ```bash 21 | npm run dev 22 | ``` 23 | 24 | 4. Open http://localhost:3002 in your browser 25 | 26 | ## Building for Production 27 | 28 | ```bash 29 | npm run build 30 | ``` 31 | 32 | This will create optimized files in the `dist` directory. -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/cjs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Firestore Stripe Payments - CommonJS Example 7 | 75 | 76 | 77 |
78 |
79 |

Loading products...

80 |
81 |
82 | 83 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/cjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firestore-stripe-payments-cjs-example", 3 | "version": "1.0.0", 4 | "description": "CommonJS example for firestore-stripe-payments SDK", 5 | "main": "src/main.js", 6 | "scripts": { 7 | "preinstall": "npm i ./invertase-firestore-stripe-payments.tgz", 8 | "dev": "webpack serve --mode development", 9 | "build": "webpack --mode production" 10 | }, 11 | "dependencies": { 12 | "@invertase/firestore-stripe-payments": "file:invertase-firestore-stripe-payments.tgz", 13 | "firebase": "^11.0.0" 14 | }, 15 | "devDependencies": { 16 | "dotenv": "^16.0.0", 17 | "html-webpack-plugin": "^5.5.0", 18 | "webpack": "^5.89.0", 19 | "webpack-cli": "^6.0.1", 20 | "webpack-dev-server": "^5.2.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/cjs/src/firebase-config.example.js: -------------------------------------------------------------------------------- 1 | exports.firebaseConfig = { 2 | apiKey: "YOUR_API_KEY", 3 | authDomain: "YOUR_PROJECT_ID.firebaseapp.com", 4 | databaseURL: "https://YOUR_PROJECT_ID-default-rtdb.firebaseio.com", 5 | projectId: "YOUR_PROJECT_ID", 6 | storageBucket: "YOUR_PROJECT_ID.appspot.com", 7 | messagingSenderId: "YOUR_MESSAGING_SENDER_ID", 8 | appId: "YOUR_APP_ID", 9 | measurementId: "YOUR_MEASUREMENT_ID", 10 | }; 11 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/cjs/src/main.js: -------------------------------------------------------------------------------- 1 | const { initializeApp } = require("firebase/app"); 2 | const { 3 | getProducts, 4 | getStripePayments, 5 | } = require("@invertase/firestore-stripe-payments"); 6 | // Firebase config 7 | const { firebaseConfig } = require("./firebase-config.js"); 8 | 9 | // Initialize Firebase 10 | const app = initializeApp(firebaseConfig); 11 | 12 | // Initialize Stripe Payments 13 | const stripePayments = getStripePayments(app, { 14 | customersCollection: "customers", 15 | productsCollection: "products", 16 | }); 17 | 18 | async function loadProducts() { 19 | try { 20 | const products = await getProducts(stripePayments); 21 | 22 | const productsList = 23 | products.length > 0 24 | ? products 25 | .map( 26 | (product) => ` 27 |
28 |

${product.name}

29 | ${product.description ? `

${product.description}

` : ""} 30 | ${product.active ? 'Active' : ""} 31 |
32 | ` 33 | ) 34 | .join("") 35 | : '

No products found.

'; 36 | 37 | document.getElementById("app").innerHTML = ` 38 |
39 |

Stripe Products

40 |
41 | ${productsList} 42 |
43 |
44 | `; 45 | } catch (error) { 46 | console.error("Error loading products:", error); 47 | 48 | document.getElementById("app").innerHTML = ` 49 |
50 |

Error

51 |

Failed to load products: ${error.message}

52 |
53 | `; 54 | } 55 | } 56 | 57 | // Load products when page is ready 58 | if (document.readyState === "loading") { 59 | document.addEventListener("DOMContentLoaded", loadProducts); 60 | } else { 61 | loadProducts(); 62 | } 63 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/cjs/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const webpack = require("webpack"); 3 | const dotenv = require("dotenv"); 4 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 5 | 6 | // Load environment variables 7 | dotenv.config(); 8 | 9 | module.exports = { 10 | mode: "development", 11 | entry: "./src/main.js", 12 | output: { 13 | filename: "bundle.js", 14 | path: path.resolve(__dirname, "dist"), 15 | clean: true, 16 | }, 17 | devServer: { 18 | static: "./dist", 19 | port: 3002, 20 | hot: true, 21 | }, 22 | plugins: [ 23 | new webpack.DefinePlugin({ 24 | "process.env": JSON.stringify(process.env), 25 | }), 26 | new HtmlWebpackPlugin({ 27 | template: "./index.html", 28 | }), 29 | ], 30 | }; 31 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm-with-subscriptions/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Firestore Stripe Payments - ESM Example 7 | 75 | 76 | 77 |
78 |
79 |

Loading products...

80 |
81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm-with-subscriptions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firestore-stripe-payments-esm-example", 3 | "version": "1.0.0", 4 | "description": "ESM example for firestore-stripe-payments SDK with Vite", 5 | "type": "module", 6 | "scripts": { 7 | "preinstall": "npm i ./invertase-firestore-stripe-payments.tgz", 8 | "dev": "vite", 9 | "build": "vite build", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@invertase/firestore-stripe-payments": "file:invertase-firestore-stripe-payments.tgz", 14 | "firebase": "^11.0.0" 15 | }, 16 | "devDependencies": { 17 | "vite": "^6.3.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm-with-subscriptions/src/firestore-config.example.js: -------------------------------------------------------------------------------- 1 | export const firebaseConfig = { 2 | apiKey: "YOUR_API_KEY", 3 | authDomain: "YOUR_PROJECT_ID.firebaseapp.com", 4 | databaseURL: "https://YOUR_PROJECT_ID-default-rtdb.firebaseio.com", 5 | projectId: "YOUR_PROJECT_ID", 6 | storageBucket: "YOUR_PROJECT_ID.appspot.com", 7 | messagingSenderId: "YOUR_MESSAGING_SENDER_ID", 8 | appId: "YOUR_APP_ID", 9 | measurementId: "YOUR_MEASUREMENT_ID", 10 | }; 11 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm-with-subscriptions/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | 3 | export default defineConfig({ 4 | server: { 5 | port: 3001, 6 | open: true, 7 | }, 8 | build: { 9 | outDir: "dist", 10 | sourcemap: true, 11 | }, 12 | resolve: { 13 | alias: { 14 | "@": "/src", 15 | }, 16 | }, 17 | }); 18 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm/README.md: -------------------------------------------------------------------------------- 1 | # ESM Example with Vite 2 | 3 | This example demonstrates how to use the Firestore Stripe Payments SDK with ES modules and Vite. 4 | 5 | ## Setup 6 | 7 | 0. Ensure the web SDK is packed, or install a published version >= v0.0.8 8 | 9 | 1. Copy `src/firebase-config.example.js` to `src/firebase-config.js` and fill in your Firebase configuration: 10 | ```bash 11 | cp src/firebase-config.example.js src/firebase-config.js 12 | ``` 13 | 14 | 2. Install dependencies: 15 | ```bash 16 | npm install 17 | ``` 18 | 19 | 3. Run the development server: 20 | ```bash 21 | npm run dev 22 | ``` 23 | 24 | 4. Open http://localhost:3001 in your browser (Vite will automatically open it) 25 | 26 | ## Building for Production 27 | 28 | ```bash 29 | npm run build 30 | ``` 31 | 32 | This will create optimized files in the `dist` directory. 33 | 34 | To preview the production build locally: 35 | 36 | ```bash 37 | npm run preview 38 | ``` 39 | 40 | ## Key Differences from CommonJS Example 41 | 42 | 1. **Module Type**: Uses `"type": "module"` in package.json 43 | 2. **Import Syntax**: Uses ES6 `import` statements instead of `require()` 44 | 3. **Export Syntax**: Uses ES6 `export` instead of `module.exports` 45 | 4. **Build Tool**: Uses Vite instead of Webpack for faster development 46 | 5. **Configuration**: Simpler configuration with Vite's sensible defaults 47 | 48 | ## Development Tips 49 | 50 | - Vite provides instant server start and lightning-fast HMR 51 | - No need for complex Webpack configuration 52 | - Built-in TypeScript support (just rename files to `.ts`) 53 | - Automatic dependency pre-bundling for faster page loads 54 | 55 | ## Troubleshooting 56 | 57 | If you encounter issues: 58 | 59 | 1. Make sure you're using Node.js 14+ (required for ESM support) 60 | 2. Ensure the `.tgz` file is in the correct location before installing 61 | 3. Check that your Firebase config is correctly set up 62 | 4. Verify that Firebase products are properly configured in your Firebase project 63 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Firestore Stripe Payments - ESM Example 7 | 75 | 76 | 77 |
78 |
79 |

Loading products...

80 |
81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "firestore-stripe-payments-esm-example", 3 | "version": "1.0.0", 4 | "description": "ESM example for firestore-stripe-payments SDK with Vite", 5 | "type": "module", 6 | "scripts": { 7 | "preinstall": "npm i ./invertase-firestore-stripe-payments.tgz", 8 | "dev": "vite", 9 | "build": "vite build", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@invertase/firestore-stripe-payments": "file:invertase-firestore-stripe-payments.tgz", 14 | "firebase": "^11.0.0" 15 | }, 16 | "devDependencies": { 17 | "vite": "^6.3.5" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm/src/firestore-config.example.js: -------------------------------------------------------------------------------- 1 | export const firebaseConfig = { 2 | apiKey: "YOUR_API_KEY", 3 | authDomain: "YOUR_PROJECT_ID.firebaseapp.com", 4 | databaseURL: "https://YOUR_PROJECT_ID-default-rtdb.firebaseio.com", 5 | projectId: "YOUR_PROJECT_ID", 6 | storageBucket: "YOUR_PROJECT_ID.appspot.com", 7 | messagingSenderId: "YOUR_MESSAGING_SENDER_ID", 8 | appId: "YOUR_APP_ID", 9 | measurementId: "YOUR_MEASUREMENT_ID", 10 | }; 11 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm/src/main.js: -------------------------------------------------------------------------------- 1 | import { initializeApp } from "firebase/app"; 2 | import { 3 | getProducts, 4 | getStripePayments, 5 | } from "@invertase/firestore-stripe-payments"; 6 | import { firebaseConfig } from "./firebase-config.js"; 7 | 8 | const app = initializeApp(firebaseConfig); 9 | 10 | const stripePayments = getStripePayments(app, { 11 | customersCollection: "customers", 12 | productsCollection: "products", 13 | }); 14 | 15 | async function loadProducts() { 16 | try { 17 | const products = await getProducts(stripePayments); 18 | 19 | const productsList = 20 | products.length > 0 21 | ? products 22 | .map( 23 | (product) => ` 24 |
25 |

${product.name}

26 | ${product.description ? `

${product.description}

` : ""} 27 | ${product.active ? 'Active' : ""} 28 |
29 | ` 30 | ) 31 | .join("") 32 | : '

No products found.

'; 33 | 34 | document.getElementById("app").innerHTML = ` 35 |
36 |

Stripe Products

37 |
38 | ${productsList} 39 |
40 |
41 | `; 42 | } catch (error) { 43 | console.error("Error loading products:", error); 44 | 45 | document.getElementById("app").innerHTML = ` 46 |
47 |

Error

48 |

Failed to load products: ${error.message}

49 |
50 | `; 51 | } 52 | } 53 | 54 | if (document.readyState === "loading") { 55 | document.addEventListener("DOMContentLoaded", loadProducts); 56 | } else { 57 | loadProducts(); 58 | } 59 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/examples/esm/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | 3 | export default defineConfig({ 4 | server: { 5 | port: 3001, 6 | open: true, 7 | }, 8 | build: { 9 | outDir: "dist", 10 | sourcemap: true, 11 | }, 12 | resolve: { 13 | alias: { 14 | "@": "/src", 15 | }, 16 | }, 17 | }); 18 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonlineitemparams.description.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonLineItemParams](./firestore-stripe-payments.commonlineitemparams.md) > [description](./firestore-stripe-payments.commonlineitemparams.description.md) 4 | 5 | ## CommonLineItemParams.description property 6 | 7 | The description for the line item, to be displayed on the Checkout page. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | description?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonlineitemparams.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonLineItemParams](./firestore-stripe-payments.commonlineitemparams.md) 4 | 5 | ## CommonLineItemParams interface 6 | 7 | Parameters common across all line item types. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface CommonLineItemParams 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [description?](./firestore-stripe-payments.commonlineitemparams.description.md) | string | (Optional) The description for the line item, to be displayed on the Checkout page. | 20 | | [quantity?](./firestore-stripe-payments.commonlineitemparams.quantity.md) | number | (Optional) The quantity of the line item being purchased. | 21 | 22 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonlineitemparams.quantity.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonLineItemParams](./firestore-stripe-payments.commonlineitemparams.md) > [quantity](./firestore-stripe-payments.commonlineitemparams.quantity.md) 4 | 5 | ## CommonLineItemParams.quantity property 6 | 7 | The quantity of the line item being purchased. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | quantity?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.allow_promotion_codes.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [allow\_promotion\_codes](./firestore-stripe-payments.commonsessioncreateparams.allow_promotion_codes.md) 4 | 5 | ## CommonSessionCreateParams.allow\_promotion\_codes property 6 | 7 | Enables user redeemable promotion codes. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | allow_promotion_codes?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.automatic_tax.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [automatic\_tax](./firestore-stripe-payments.commonsessioncreateparams.automatic_tax.md) 4 | 5 | ## CommonSessionCreateParams.automatic\_tax property 6 | 7 | Set to true to enable automatic taxes. Defaults to false. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | automatic_tax?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.cancel_url.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [cancel\_url](./firestore-stripe-payments.commonsessioncreateparams.cancel_url.md) 4 | 5 | ## CommonSessionCreateParams.cancel\_url property 6 | 7 | The URL the customer will be directed to if they decide to cancel payment and return to your website. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | cancel_url?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.client_reference_id.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [client\_reference\_id](./firestore-stripe-payments.commonsessioncreateparams.client_reference_id.md) 4 | 5 | ## CommonSessionCreateParams.client\_reference\_id property 6 | 7 | A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | client_reference_id?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.metadata.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [metadata](./firestore-stripe-payments.commonsessioncreateparams.metadata.md) 4 | 5 | ## CommonSessionCreateParams.metadata property 6 | 7 | Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | metadata?: { 13 | [key: string]: any; 14 | }; 15 | ``` 16 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.mode.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [mode](./firestore-stripe-payments.commonsessioncreateparams.mode.md) 4 | 5 | ## CommonSessionCreateParams.mode property 6 | 7 | The mode of the Checkout Session. If not specified defaults to `subscription`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | mode?: "subscription" | "payment"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.payment_method_types.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [payment\_method\_types](./firestore-stripe-payments.commonsessioncreateparams.payment_method_types.md) 4 | 5 | ## CommonSessionCreateParams.payment\_method\_types property 6 | 7 | A list of the types of payment methods (e.g., `card`) this Checkout Session can accept. Defaults to `["card"]`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | payment_method_types?: PaymentMethodType[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.promotion_code.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [promotion\_code](./firestore-stripe-payments.commonsessioncreateparams.promotion_code.md) 4 | 5 | ## CommonSessionCreateParams.promotion\_code property 6 | 7 | The promotion code to apply to this Session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | promotion_code?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.success_url.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [success\_url](./firestore-stripe-payments.commonsessioncreateparams.success_url.md) 4 | 5 | ## CommonSessionCreateParams.success\_url property 6 | 7 | The URL to which Stripe should send customers when payment or setup is complete. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | success_url?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.tax_id_collection.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [tax\_id\_collection](./firestore-stripe-payments.commonsessioncreateparams.tax_id_collection.md) 4 | 5 | ## CommonSessionCreateParams.tax\_id\_collection property 6 | 7 | Controls tax ID collection settings for the session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | tax_id_collection?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.commonsessioncreateparams.trial_from_plan.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) > [trial\_from\_plan](./firestore-stripe-payments.commonsessioncreateparams.trial_from_plan.md) 4 | 5 | ## CommonSessionCreateParams.trial\_from\_plan property 6 | 7 | Indicates if a plan’s `trial_period_days` should be applied to the subscription. Defaults to `true`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | trial_from_plan?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.create_session_timeout_millis.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CREATE\_SESSION\_TIMEOUT\_MILLIS](./firestore-stripe-payments.create_session_timeout_millis.md) 4 | 5 | ## CREATE\_SESSION\_TIMEOUT\_MILLIS variable 6 | 7 | Signature: 8 | 9 | ```typescript 10 | CREATE_SESSION_TIMEOUT_MILLIS: number 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.createcheckoutsession.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [createCheckoutSession](./firestore-stripe-payments.createcheckoutsession.md) 4 | 5 | ## createCheckoutSession() function 6 | 7 | Creates a new Stripe checkout session with the given parameters. Returned session contains a session ID and a session URL that can be used to redirect the user to complete the checkout. User must be currently signed in with Firebase Auth to call this API. If a timeout occurs while waiting for the session to be created and acknowledged by Stripe, rejects with a `deadline-exceeded` error. Default timeout duration is [CREATE\_SESSION\_TIMEOUT\_MILLIS](./firestore-stripe-payments.create_session_timeout_millis.md). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function createCheckoutSession(payments: StripePayments, params: SessionCreateParams, options?: CreateCheckoutSessionOptions): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | params | [SessionCreateParams](./firestore-stripe-payments.sessioncreateparams.md) | Parameters of the checkout session. | 21 | | options | [CreateCheckoutSessionOptions](./firestore-stripe-payments.createcheckoutsessionoptions.md) | Optional settings to customize the behavior. | 22 | 23 | Returns: 24 | 25 | Promise<[Session](./firestore-stripe-payments.session.md)> 26 | 27 | Resolves with the created Stripe Session object. 28 | 29 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.createcheckoutsessionoptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CreateCheckoutSessionOptions](./firestore-stripe-payments.createcheckoutsessionoptions.md) 4 | 5 | ## CreateCheckoutSessionOptions interface 6 | 7 | Optional settings for the [createCheckoutSession()](./firestore-stripe-payments.createcheckoutsession.md) function. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface CreateCheckoutSessionOptions 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [timeoutMillis?](./firestore-stripe-payments.createcheckoutsessionoptions.timeoutmillis.md) | number | (Optional) Time to wait (in milliseconds) until the session is created and acknowledged by Stripe. If not specified, defaults to [CREATE\_SESSION\_TIMEOUT\_MILLIS](./firestore-stripe-payments.create_session_timeout_millis.md). | 20 | 21 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.createcheckoutsessionoptions.timeoutmillis.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [CreateCheckoutSessionOptions](./firestore-stripe-payments.createcheckoutsessionoptions.md) > [timeoutMillis](./firestore-stripe-payments.createcheckoutsessionoptions.timeoutmillis.md) 4 | 5 | ## CreateCheckoutSessionOptions.timeoutMillis property 6 | 7 | Time to wait (in milliseconds) until the session is created and acknowledged by Stripe. If not specified, defaults to [CREATE\_SESSION\_TIMEOUT\_MILLIS](./firestore-stripe-payments.create_session_timeout_millis.md). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | timeoutMillis?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getcurrentusersubscription.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getCurrentUserSubscription](./firestore-stripe-payments.getcurrentusersubscription.md) 4 | 5 | ## getCurrentUserSubscription() function 6 | 7 | Retrieves an existing Stripe subscription for the currently signed in user from the database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getCurrentUserSubscription(payments: StripePayments, subscriptionId: string): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | subscriptionId | string | ID of the subscription to retrieve. | 21 | 22 | Returns: 23 | 24 | Promise<[Subscription](./firestore-stripe-payments.subscription.md)> 25 | 26 | Resolves with a Subscription object if found. Rejects if the specified subscription ID does not exist, or if the user is not signed in. 27 | 28 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getcurrentusersubscriptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getCurrentUserSubscriptions](./firestore-stripe-payments.getcurrentusersubscriptions.md) 4 | 5 | ## getCurrentUserSubscriptions() function 6 | 7 | Retrieves existing Stripe subscriptions for the currently signed in user from the database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getCurrentUserSubscriptions(payments: StripePayments, options?: GetSubscriptionsOptions): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | options | [GetSubscriptionsOptions](./firestore-stripe-payments.getsubscriptionsoptions.md) | A set of options to customize the behavior. | 21 | 22 | Returns: 23 | 24 | Promise<[Subscription](./firestore-stripe-payments.subscription.md)\[\]> 25 | 26 | Resolves with an array of Stripe subscriptions. May be empty. 27 | 28 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getprice.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getPrice](./firestore-stripe-payments.getprice.md) 4 | 5 | ## getPrice() function 6 | 7 | Retrieves a Stripe price from the database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getPrice(payments: StripePayments, productId: string, priceId: string): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | productId | string | ID of the product to which the price belongs. | 21 | | priceId | string | ID of the price to retrieve. | 22 | 23 | Returns: 24 | 25 | Promise<[Price](./firestore-stripe-payments.price.md)> 26 | 27 | Resolves with a Stripe Price object if found. Rejects if the specified product ID or the price ID does not exist. 28 | 29 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getprices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getPrices](./firestore-stripe-payments.getprices.md) 4 | 5 | ## getPrices() function 6 | 7 | Retrieves all Stripe prices associated with the specified product. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getPrices(payments: StripePayments, productId: string): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | productId | string | ID of the product to which the prices belong. | 21 | 22 | Returns: 23 | 24 | Promise<[Price](./firestore-stripe-payments.price.md)\[\]> 25 | 26 | Resolves with an array of Stripe Price objects. Rejects if the specified product ID does not exist. If the product exists, but doesn't have any prices, resolves with the empty array. 27 | 28 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproduct.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getProduct](./firestore-stripe-payments.getproduct.md) 4 | 5 | ## getProduct() function 6 | 7 | Retrieves a Stripe product from the database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getProduct(payments: StripePayments, productId: string, options?: GetProductOptions): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | productId | string | ID of the product to retrieve. | 21 | | options | [GetProductOptions](./firestore-stripe-payments.getproductoptions.md) | A set of options to customize the behavior. | 22 | 23 | Returns: 24 | 25 | Promise<[Product](./firestore-stripe-payments.product.md)> 26 | 27 | Resolves with a Stripe Product object if found. Rejects if the specified product ID does not exist. 28 | 29 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductoptions.includeprices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductOptions](./firestore-stripe-payments.getproductoptions.md) > [includePrices](./firestore-stripe-payments.getproductoptions.includeprices.md) 4 | 5 | ## GetProductOptions.includePrices property 6 | 7 | Set to `true` to retrieve the prices along with a product. If not set, the product is returned with no prices (i.e. [Product.prices](./firestore-stripe-payments.product.prices.md) field will be empty). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | includePrices?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductoptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductOptions](./firestore-stripe-payments.getproductoptions.md) 4 | 5 | ## GetProductOptions interface 6 | 7 | Optional parameters for the [getProduct()](./firestore-stripe-payments.getproduct.md) function. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface GetProductOptions 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [includePrices?](./firestore-stripe-payments.getproductoptions.includeprices.md) | boolean | (Optional) Set to true to retrieve the prices along with a product. If not set, the product is returned with no prices (i.e. [Product.prices](./firestore-stripe-payments.product.prices.md) field will be empty). | 20 | 21 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproducts.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getProducts](./firestore-stripe-payments.getproducts.md) 4 | 5 | ## getProducts() function 6 | 7 | Retrieves a Stripe product from the database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getProducts(payments: StripePayments, options?: GetProductsOptions): Promise; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 20 | | options | [GetProductsOptions](./firestore-stripe-payments.getproductsoptions.md) | A set of options to customize the behavior. | 21 | 22 | Returns: 23 | 24 | Promise<[Product](./firestore-stripe-payments.product.md)\[\]> 25 | 26 | Resolves with an array of Stripe Product objects. May be empty. 27 | 28 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductsoptions.activeonly.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductsOptions](./firestore-stripe-payments.getproductsoptions.md) > [activeOnly](./firestore-stripe-payments.getproductsoptions.activeonly.md) 4 | 5 | ## GetProductsOptions.activeOnly property 6 | 7 | Set to `true` to retrieve only the currently active set of Stripe products. If not set, returns all available products. When set, the effect is same as if called with the filter `["active", "==", true]`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | activeOnly?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductsoptions.includeprices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductsOptions](./firestore-stripe-payments.getproductsoptions.md) > [includePrices](./firestore-stripe-payments.getproductsoptions.includeprices.md) 4 | 5 | ## GetProductsOptions.includePrices property 6 | 7 | Set to `true` to retrieve the prices along with a product. If not set, the product is returned with no prices (i.e. [Product.prices](./firestore-stripe-payments.product.prices.md) field will be empty). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | includePrices?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductsoptions.limit.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductsOptions](./firestore-stripe-payments.getproductsoptions.md) > [limit](./firestore-stripe-payments.getproductsoptions.limit.md) 4 | 5 | ## GetProductsOptions.limit property 6 | 7 | Maximum number of products to return. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | limit?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductsoptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductsOptions](./firestore-stripe-payments.getproductsoptions.md) 4 | 5 | ## GetProductsOptions interface 6 | 7 | Optional parameters for the [getProducts()](./firestore-stripe-payments.getproducts.md) function. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface GetProductsOptions 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [activeOnly?](./firestore-stripe-payments.getproductsoptions.activeonly.md) | boolean | (Optional) Set to true to retrieve only the currently active set of Stripe products. If not set, returns all available products. When set, the effect is same as if called with the filter ["active", "==", true]. | 20 | | [includePrices?](./firestore-stripe-payments.getproductsoptions.includeprices.md) | boolean | (Optional) Set to true to retrieve the prices along with a product. If not set, the product is returned with no prices (i.e. [Product.prices](./firestore-stripe-payments.product.prices.md) field will be empty). | 21 | | [limit?](./firestore-stripe-payments.getproductsoptions.limit.md) | number | (Optional) Maximum number of products to return. | 22 | | [where?](./firestore-stripe-payments.getproductsoptions.where.md) | [WhereFilter](./firestore-stripe-payments.wherefilter.md)\[\] | (Optional) An array of optoinal filters that will be applied when querying the products from the app database. | 23 | 24 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getproductsoptions.where.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetProductsOptions](./firestore-stripe-payments.getproductsoptions.md) > [where](./firestore-stripe-payments.getproductsoptions.where.md) 4 | 5 | ## GetProductsOptions.where property 6 | 7 | An array of optoinal filters that will be applied when querying the products from the app database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | where?: WhereFilter[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getstripepayments.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [getStripePayments](./firestore-stripe-payments.getstripepayments.md) 4 | 5 | ## getStripePayments() function 6 | 7 | Serves as the main entry point to this library. Initializes the client SDK, and returns a handle object that can be passed into other APIs. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare function getStripePayments(app: FirebaseApp, options: StripePaymentsOptions): StripePayments; 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | app | FirebaseApp | A FirebaseApp instance initialized by the Firebase JS SDK. | 20 | | options | [StripePaymentsOptions](./firestore-stripe-payments.stripepaymentsoptions.md) | Configuration options for the SDK. | 21 | 22 | Returns: 23 | 24 | [StripePayments](./firestore-stripe-payments.stripepayments.md) 25 | 26 | An instance of the StripePayments class. 27 | 28 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getsubscriptionsoptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetSubscriptionsOptions](./firestore-stripe-payments.getsubscriptionsoptions.md) 4 | 5 | ## GetSubscriptionsOptions interface 6 | 7 | Optional parameters for the [getCurrentUserSubscriptions()](./firestore-stripe-payments.getcurrentusersubscriptions.md) function. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface GetSubscriptionsOptions 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [status?](./firestore-stripe-payments.getsubscriptionsoptions.status.md) | [SubscriptionStatus](./firestore-stripe-payments.subscriptionstatus.md) \| [SubscriptionStatus](./firestore-stripe-payments.subscriptionstatus.md)\[\] | (Optional) Specify one or more subscription status values to retrieve. When set only the subscriptions with the given status are returned. | 20 | 21 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.getsubscriptionsoptions.status.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [GetSubscriptionsOptions](./firestore-stripe-payments.getsubscriptionsoptions.md) > [status](./firestore-stripe-payments.getsubscriptionsoptions.status.md) 4 | 5 | ## GetSubscriptionsOptions.status property 6 | 7 | Specify one or more subscription status values to retrieve. When set only the subscriptions with the given status are returned. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | status?: SubscriptionStatus | SubscriptionStatus[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.amount.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) > [amount](./firestore-stripe-payments.lineitem.amount.md) 4 | 5 | ## LineItem.amount property 6 | 7 | The amount to be collected per unit of the line item. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | amount?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.currency.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) > [currency](./firestore-stripe-payments.lineitem.currency.md) 4 | 5 | ## LineItem.currency property 6 | 7 | Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | currency?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.description.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) > [description](./firestore-stripe-payments.lineitem.description.md) 4 | 5 | ## LineItem.description property 6 | 7 | The description for the line item, to be displayed on the Checkout page. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | description?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) 4 | 5 | ## LineItem interface 6 | 7 | Interface of a Stripe line item associated with a checkout session. A line item represents an individual item purchased using the session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface LineItem 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [amount?](./firestore-stripe-payments.lineitem.amount.md) | number | (Optional) The amount to be collected per unit of the line item. | 20 | | [currency?](./firestore-stripe-payments.lineitem.currency.md) | string | (Optional) Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). | 21 | | [description?](./firestore-stripe-payments.lineitem.description.md) | string | (Optional) The description for the line item, to be displayed on the Checkout page. | 22 | | [name?](./firestore-stripe-payments.lineitem.name.md) | string | (Optional) The name for the item to be displayed on the Checkout page. | 23 | | [price?](./firestore-stripe-payments.lineitem.price.md) | string | (Optional) The ID of the Stripe price. | 24 | | [quantity?](./firestore-stripe-payments.lineitem.quantity.md) | number | (Optional) The quantity of the line item being purchased. | 25 | 26 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.name.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) > [name](./firestore-stripe-payments.lineitem.name.md) 4 | 5 | ## LineItem.name property 6 | 7 | The name for the item to be displayed on the Checkout page. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | name?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.price.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) > [price](./firestore-stripe-payments.lineitem.price.md) 4 | 5 | ## LineItem.price property 6 | 7 | The ID of the Stripe price. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | price?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitem.quantity.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItem](./firestore-stripe-payments.lineitem.md) > [quantity](./firestore-stripe-payments.lineitem.quantity.md) 4 | 5 | ## LineItem.quantity property 6 | 7 | The quantity of the line item being purchased. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | quantity?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitemparams.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItemParams](./firestore-stripe-payments.lineitemparams.md) 4 | 5 | ## LineItemParams type 6 | 7 | Parameters for creating a new line item. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type LineItemParams = PriceIdLineItemParams; 13 | ``` 14 | References: [PriceIdLineItemParams](./firestore-stripe-payments.priceidlineitemparams.md) 15 | 16 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitemsessioncreateparams.line_items.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItemSessionCreateParams](./firestore-stripe-payments.lineitemsessioncreateparams.md) > [line\_items](./firestore-stripe-payments.lineitemsessioncreateparams.line_items.md) 4 | 5 | ## LineItemSessionCreateParams.line\_items property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | line_items: LineItemParams[]; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.lineitemsessioncreateparams.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [LineItemSessionCreateParams](./firestore-stripe-payments.lineitemsessioncreateparams.md) 4 | 5 | ## LineItemSessionCreateParams interface 6 | 7 | Parameters for createing a session with one or more line items. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface LineItemSessionCreateParams extends CommonSessionCreateParams 13 | ``` 14 | Extends: [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) 15 | 16 | ## Properties 17 | 18 | | Property | Type | Description | 19 | | --- | --- | --- | 20 | | [line\_items](./firestore-stripe-payments.lineitemsessioncreateparams.line_items.md) | [LineItemParams](./firestore-stripe-payments.lineitemparams.md)\[\] | | 21 | 22 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.oncurrentusersubscriptionupdate.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [onCurrentUserSubscriptionUpdate](./firestore-stripe-payments.oncurrentusersubscriptionupdate.md) 4 | 5 | ## onCurrentUserSubscriptionUpdate() function 6 | 7 | Registers a listener to receive subscription update events for the currently signed in user. If the user is not signed in throws an `unauthenticated` error, and no listener is registered. 8 | 9 | Upon successful registration, the `onUpdate` callback will fire once with the current state of all the subscriptions. From then onwards, each update to a subscription will fire the `onUpdate` callback with the latest state of the subscriptions. 10 | 11 | Signature: 12 | 13 | ```typescript 14 | export declare function onCurrentUserSubscriptionUpdate(payments: StripePayments, onUpdate: (snapshot: SubscriptionSnapshot) => void, onError?: (error: StripePaymentsError) => void): () => void; 15 | ``` 16 | 17 | ## Parameters 18 | 19 | | Parameter | Type | Description | 20 | | --- | --- | --- | 21 | | payments | [StripePayments](./firestore-stripe-payments.stripepayments.md) | A valid [StripePayments](./firestore-stripe-payments.stripepayments.md) object. | 22 | | onUpdate | (snapshot: [SubscriptionSnapshot](./firestore-stripe-payments.subscriptionsnapshot.md)) => void | A callback that will fire whenever the current user's subscriptions are updated. | 23 | | onError | (error: [StripePaymentsError](./firestore-stripe-payments.stripepaymentserror.md)) => void | A callback that will fire whenever an error occurs while listening to subscription updates. | 24 | 25 | Returns: 26 | 27 | () => void 28 | 29 | A function that can be called to cancel and unregister the listener. 30 | 31 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.paymentmethodtype.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [PaymentMethodType](./firestore-stripe-payments.paymentmethodtype.md) 4 | 5 | ## PaymentMethodType type 6 | 7 | Supported payment methods. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type PaymentMethodType = "card" | "acss_debit" | "afterpay_clearpay" | "alipay" | "bacs_debit" | "bancontact" | "boleto" | "eps" | "fpx" | "giropay" | "grabpay" | "ideal" | "klarna" | "oxxo" | "p24" | "sepa_debit" | "sofort" | "wechat_pay"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.active.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [active](./firestore-stripe-payments.price.active.md) 4 | 5 | ## Price.active property 6 | 7 | Whether the price can be used for new purchases. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly active: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.currency.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [currency](./firestore-stripe-payments.price.currency.md) 4 | 5 | ## Price.currency property 6 | 7 | Three-letter ISO currency code. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly currency: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.description.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [description](./firestore-stripe-payments.price.description.md) 4 | 5 | ## Price.description property 6 | 7 | A brief description of the price. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly description: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.id.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [id](./firestore-stripe-payments.price.id.md) 4 | 5 | ## Price.id property 6 | 7 | Unique Stripe price ID. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly id: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.interval.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [interval](./firestore-stripe-payments.price.interval.md) 4 | 5 | ## Price.interval property 6 | 7 | The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly interval: "day" | "month" | "week" | "year" | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.interval_count.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [interval\_count](./firestore-stripe-payments.price.interval_count.md) 4 | 5 | ## Price.interval\_count property 6 | 7 | The number of intervals (specified in the [Price.interval](./firestore-stripe-payments.price.interval.md) attribute) between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly interval_count: number | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) 4 | 5 | ## Price interface 6 | 7 | Interface of a Stripe Price object stored in the app database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface Price 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [active](./firestore-stripe-payments.price.active.md) | boolean | Whether the price can be used for new purchases. | 20 | | [currency](./firestore-stripe-payments.price.currency.md) | string | Three-letter ISO currency code. | 21 | | [description](./firestore-stripe-payments.price.description.md) | string \| null | A brief description of the price. | 22 | | [id](./firestore-stripe-payments.price.id.md) | string | Unique Stripe price ID. | 23 | | [interval\_count](./firestore-stripe-payments.price.interval_count.md) | number \| null | The number of intervals (specified in the [Price.interval](./firestore-stripe-payments.price.interval.md) attribute) between subscription billings. For example, interval=month and interval_count=3 bills every 3 months. | 24 | | [interval](./firestore-stripe-payments.price.interval.md) | "day" \| "month" \| "week" \| "year" \| null | The frequency at which a subscription is billed. One of day, week, month or year. | 25 | | [product](./firestore-stripe-payments.price.product.md) | string | ID of the Stripe product to which this price is related. | 26 | | [trial\_period\_days](./firestore-stripe-payments.price.trial_period_days.md) | number \| null | Default number of trial days when subscribing a customer to this price using [trial\_from\_plan](https://stripe.com/docs/api#create_subscription-trial_from_plan). | 27 | | [type](./firestore-stripe-payments.price.type.md) | "one\_time" \| "recurring" | One of one_time or recurring depending on whether the price is for a one-time purchase or a recurring (subscription) purchase. | 28 | | [unit\_amount](./firestore-stripe-payments.price.unit_amount.md) | number \| null | The unit amount in cents to be charged, represented as a whole integer if possible. | 29 | 30 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.product.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [product](./firestore-stripe-payments.price.product.md) 4 | 5 | ## Price.product property 6 | 7 | ID of the Stripe product to which this price is related. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly product: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.trial_period_days.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [trial\_period\_days](./firestore-stripe-payments.price.trial_period_days.md) 4 | 5 | ## Price.trial\_period\_days property 6 | 7 | Default number of trial days when subscribing a customer to this price using [trial\_from\_plan](https://stripe.com/docs/api#create_subscription-trial_from_plan). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly trial_period_days: number | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.type.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [type](./firestore-stripe-payments.price.type.md) 4 | 5 | ## Price.type property 6 | 7 | One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly type: "one_time" | "recurring"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.price.unit_amount.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Price](./firestore-stripe-payments.price.md) > [unit\_amount](./firestore-stripe-payments.price.unit_amount.md) 4 | 5 | ## Price.unit\_amount property 6 | 7 | The unit amount in cents to be charged, represented as a whole integer if possible. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly unit_amount: number | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.priceidlineitemparams.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [PriceIdLineItemParams](./firestore-stripe-payments.priceidlineitemparams.md) 4 | 5 | ## PriceIdLineItemParams interface 6 | 7 | Parameters for createing a line item with a Stripe price ID. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface PriceIdLineItemParams extends CommonLineItemParams 13 | ``` 14 | Extends: [CommonLineItemParams](./firestore-stripe-payments.commonlineitemparams.md) 15 | 16 | ## Properties 17 | 18 | | Property | Type | Description | 19 | | --- | --- | --- | 20 | | [price](./firestore-stripe-payments.priceidlineitemparams.price.md) | string | The ID of the Stripe price. | 21 | 22 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.priceidlineitemparams.price.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [PriceIdLineItemParams](./firestore-stripe-payments.priceidlineitemparams.md) > [price](./firestore-stripe-payments.priceidlineitemparams.price.md) 4 | 5 | ## PriceIdLineItemParams.price property 6 | 7 | The ID of the Stripe price. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | price: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.priceidsessioncreateparams.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [PriceIdSessionCreateParams](./firestore-stripe-payments.priceidsessioncreateparams.md) 4 | 5 | ## PriceIdSessionCreateParams interface 6 | 7 | Parameters for createing a session with a Stripe price ID. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface PriceIdSessionCreateParams extends CommonSessionCreateParams 13 | ``` 14 | Extends: [CommonSessionCreateParams](./firestore-stripe-payments.commonsessioncreateparams.md) 15 | 16 | ## Properties 17 | 18 | | Property | Type | Description | 19 | | --- | --- | --- | 20 | | [price](./firestore-stripe-payments.priceidsessioncreateparams.price.md) | string | The ID of the Stripe price. | 21 | | [quantity?](./firestore-stripe-payments.priceidsessioncreateparams.quantity.md) | number | (Optional) The quantity of the item being purchased. Defaults to 1. | 22 | 23 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.priceidsessioncreateparams.price.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [PriceIdSessionCreateParams](./firestore-stripe-payments.priceidsessioncreateparams.md) > [price](./firestore-stripe-payments.priceidsessioncreateparams.price.md) 4 | 5 | ## PriceIdSessionCreateParams.price property 6 | 7 | The ID of the Stripe price. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | price: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.priceidsessioncreateparams.quantity.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [PriceIdSessionCreateParams](./firestore-stripe-payments.priceidsessioncreateparams.md) > [quantity](./firestore-stripe-payments.priceidsessioncreateparams.quantity.md) 4 | 5 | ## PriceIdSessionCreateParams.quantity property 6 | 7 | The quantity of the item being purchased. Defaults to 1. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | quantity?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.active.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [active](./firestore-stripe-payments.product.active.md) 4 | 5 | ## Product.active property 6 | 7 | Whether the product is currently available for purchase. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly active: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.description.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [description](./firestore-stripe-payments.product.description.md) 4 | 5 | ## Product.description property 6 | 7 | The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly description: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.id.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [id](./firestore-stripe-payments.product.id.md) 4 | 5 | ## Product.id property 6 | 7 | Unique Stripe product ID. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly id: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.images.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [images](./firestore-stripe-payments.product.images.md) 4 | 5 | ## Product.images property 6 | 7 | A list of up to 8 URLs of images for this product, meant to be displayable to the customer. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly images: string[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) 4 | 5 | ## Product interface 6 | 7 | Interface of a Stripe Product stored in the app database. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface Product 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [active](./firestore-stripe-payments.product.active.md) | boolean | Whether the product is currently available for purchase. | 20 | | [description](./firestore-stripe-payments.product.description.md) | string \| null | The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. | 21 | | [id](./firestore-stripe-payments.product.id.md) | string | Unique Stripe product ID. | 22 | | [images](./firestore-stripe-payments.product.images.md) | string\[\] | A list of up to 8 URLs of images for this product, meant to be displayable to the customer. | 23 | | [metadata](./firestore-stripe-payments.product.metadata.md) | { \[key: string\]: string \| number \| null; } | A collection of additional product metadata. | 24 | | [name](./firestore-stripe-payments.product.name.md) | string | The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. | 25 | | [prices](./firestore-stripe-payments.product.prices.md) | [Price](./firestore-stripe-payments.price.md)\[\] | A list of Prices for this billing product. Only populated if explicitly requested during retrieval. | 26 | | [role](./firestore-stripe-payments.product.role.md) | string \| null | The Firebase role that will be assigned to the user if they are subscribed to this plan. | 27 | 28 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.metadata.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [metadata](./firestore-stripe-payments.product.metadata.md) 4 | 5 | ## Product.metadata property 6 | 7 | A collection of additional product metadata. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly metadata: { 13 | [key: string]: string | number | null; 14 | }; 15 | ``` 16 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.name.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [name](./firestore-stripe-payments.product.name.md) 4 | 5 | ## Product.name property 6 | 7 | The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly name: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.prices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [prices](./firestore-stripe-payments.product.prices.md) 4 | 5 | ## Product.prices property 6 | 7 | A list of Prices for this billing product. Only populated if explicitly requested during retrieval. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly prices: Price[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.product.role.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Product](./firestore-stripe-payments.product.md) > [role](./firestore-stripe-payments.product.role.md) 4 | 5 | ## Product.role property 6 | 7 | The Firebase role that will be assigned to the user if they are subscribed to this plan. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly role: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.allow_promotion_codes.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [allow\_promotion\_codes](./firestore-stripe-payments.session.allow_promotion_codes.md) 4 | 5 | ## Session.allow\_promotion\_codes property 6 | 7 | Enables user redeemable promotion codes. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly allow_promotion_codes?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.automatic_tax.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [automatic\_tax](./firestore-stripe-payments.session.automatic_tax.md) 4 | 5 | ## Session.automatic\_tax property 6 | 7 | Indicates whether automatic tax is enabled for the session 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly automatic_tax?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.cancel_url.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [cancel\_url](./firestore-stripe-payments.session.cancel_url.md) 4 | 5 | ## Session.cancel\_url property 6 | 7 | The URL the customer will be directed to if they decide to cancel payment and return to your website. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly cancel_url: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.client_reference_id.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [client\_reference\_id](./firestore-stripe-payments.session.client_reference_id.md) 4 | 5 | ## Session.client\_reference\_id property 6 | 7 | A unique string to reference the Checkout Session. This can be a customer ID, a cart ID, or similar, and can be used to reconcile the session with your internal systems. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly client_reference_id?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.created_at.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [created\_at](./firestore-stripe-payments.session.created_at.md) 4 | 5 | ## Session.created\_at property 6 | 7 | Time when the session was created as a UTC timestamp. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly created_at: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.id.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [id](./firestore-stripe-payments.session.id.md) 4 | 5 | ## Session.id property 6 | 7 | Unique identifier for the session. Used to pass to `redirectToCheckout()` in Stripe.js. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly id: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.line_items.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [line\_items](./firestore-stripe-payments.session.line_items.md) 4 | 5 | ## Session.line\_items property 6 | 7 | The array of line items purchased with this session. A session is guaranteed to contain either [Session.line\_items](./firestore-stripe-payments.session.line_items.md) or [Session.price](./firestore-stripe-payments.session.price.md). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly line_items?: LineItem[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.metadata.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [metadata](./firestore-stripe-payments.session.metadata.md) 4 | 5 | ## Session.metadata property 6 | 7 | Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly metadata?: { 13 | [key: string]: any; 14 | }; 15 | ``` 16 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.mode.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [mode](./firestore-stripe-payments.session.mode.md) 4 | 5 | ## Session.mode property 6 | 7 | The mode of the Checkout Session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly mode: "subscription" | "payment"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.payment_method_types.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [payment\_method\_types](./firestore-stripe-payments.session.payment_method_types.md) 4 | 5 | ## Session.payment\_method\_types property 6 | 7 | A list of the types of payment methods (e.g., `card`) this Checkout Session can accept. Defaults to `["card"]`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly payment_method_types?: PaymentMethodType[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.price.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [price](./firestore-stripe-payments.session.price.md) 4 | 5 | ## Session.price property 6 | 7 | The ID of the Stripe price object purchased with this session. A session is guaranteed to contain either [Session.line\_items](./firestore-stripe-payments.session.line_items.md) or [Session.price](./firestore-stripe-payments.session.price.md). 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly price?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.promotion_code.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [promotion\_code](./firestore-stripe-payments.session.promotion_code.md) 4 | 5 | ## Session.promotion\_code property 6 | 7 | The promotion code to apply to this Session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly promotion_code?: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.quantity.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [quantity](./firestore-stripe-payments.session.quantity.md) 4 | 5 | ## Session.quantity property 6 | 7 | The quantity of item purchased. Defaults to 1. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly quantity?: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.success_url.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [success\_url](./firestore-stripe-payments.session.success_url.md) 4 | 5 | ## Session.success\_url property 6 | 7 | The URL to which Stripe should send customers when payment or setup is complete. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly success_url: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.tax_id_collection.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [tax\_id\_collection](./firestore-stripe-payments.session.tax_id_collection.md) 4 | 5 | ## Session.tax\_id\_collection property 6 | 7 | Controls tax ID collection settings for the session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly tax_id_collection?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.trial_from_plan.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [trial\_from\_plan](./firestore-stripe-payments.session.trial_from_plan.md) 4 | 5 | ## Session.trial\_from\_plan property 6 | 7 | Indicates if a plan’s `trial_period_days` should be applied to the subscription. Defaults to `true`. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly trial_from_plan?: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.session.url.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Session](./firestore-stripe-payments.session.md) > [url](./firestore-stripe-payments.session.url.md) 4 | 5 | ## Session.url property 6 | 7 | The URL to the Checkout Session. Redirect the user to this URL to complete the payment. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly url: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.sessioncreateparams.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SessionCreateParams](./firestore-stripe-payments.sessioncreateparams.md) 4 | 5 | ## SessionCreateParams type 6 | 7 | Parameters for creating a new session. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type SessionCreateParams = LineItemSessionCreateParams | PriceIdSessionCreateParams; 13 | ``` 14 | References: [LineItemSessionCreateParams](./firestore-stripe-payments.lineitemsessioncreateparams.md), [PriceIdSessionCreateParams](./firestore-stripe-payments.priceidsessioncreateparams.md) 15 | 16 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepayments.app.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePayments](./firestore-stripe-payments.stripepayments.md) > [app](./firestore-stripe-payments.stripepayments.app.md) 4 | 5 | ## StripePayments.app property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | readonly app: FirebaseApp; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepayments.customerscollection.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePayments](./firestore-stripe-payments.stripepayments.md) > [customersCollection](./firestore-stripe-payments.stripepayments.customerscollection.md) 4 | 5 | ## StripePayments.customersCollection property 6 | 7 | Name of the customers collection as configured in the extension. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | get customersCollection(): string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepayments.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePayments](./firestore-stripe-payments.stripepayments.md) 4 | 5 | ## StripePayments class 6 | 7 | Holds the configuration and other state information of the SDK. An instance of this class must be passed to almost all the other APIs of this library. Do not directly call the constructor. Use the [getStripePayments()](./firestore-stripe-payments.getstripepayments.md) function to obtain an instance. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare class StripePayments 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Modifiers | Type | Description | 18 | | --- | --- | --- | --- | 19 | | [app](./firestore-stripe-payments.stripepayments.app.md) | | FirebaseApp | | 20 | | [customersCollection](./firestore-stripe-payments.stripepayments.customerscollection.md) | | string | Name of the customers collection as configured in the extension. | 21 | | [productsCollection](./firestore-stripe-payments.stripepayments.productscollection.md) | | string | Name of the products collection as configured in the extension. | 22 | 23 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepayments.productscollection.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePayments](./firestore-stripe-payments.stripepayments.md) > [productsCollection](./firestore-stripe-payments.stripepayments.productscollection.md) 4 | 5 | ## StripePayments.productsCollection property 6 | 7 | Name of the products collection as configured in the extension. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | get productsCollection(): string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentserror._constructor_.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsError](./firestore-stripe-payments.stripepaymentserror.md) > [(constructor)](./firestore-stripe-payments.stripepaymentserror._constructor_.md) 4 | 5 | ## StripePaymentsError.(constructor) 6 | 7 | Constructs a new instance of the `StripePaymentsError` class 8 | 9 | Signature: 10 | 11 | ```typescript 12 | constructor(code: StripePaymentsErrorCode, message: string, cause?: any); 13 | ``` 14 | 15 | ## Parameters 16 | 17 | | Parameter | Type | Description | 18 | | --- | --- | --- | 19 | | code | [StripePaymentsErrorCode](./firestore-stripe-payments.stripepaymentserrorcode.md) | | 20 | | message | string | | 21 | | cause | any | | 22 | 23 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentserror.cause.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsError](./firestore-stripe-payments.stripepaymentserror.md) > [cause](./firestore-stripe-payments.stripepaymentserror.cause.md) 4 | 5 | ## StripePaymentsError.cause property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | readonly cause?: any; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentserror.code.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsError](./firestore-stripe-payments.stripepaymentserror.md) > [code](./firestore-stripe-payments.stripepaymentserror.code.md) 4 | 5 | ## StripePaymentsError.code property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | readonly code: StripePaymentsErrorCode; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentserror.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsError](./firestore-stripe-payments.stripepaymentserror.md) 4 | 5 | ## StripePaymentsError class 6 | 7 | An error thrown by this SDK. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare class StripePaymentsError extends Error 13 | ``` 14 | Extends: Error 15 | 16 | ## Constructors 17 | 18 | | Constructor | Modifiers | Description | 19 | | --- | --- | --- | 20 | | [(constructor)(code, message, cause)](./firestore-stripe-payments.stripepaymentserror._constructor_.md) | | Constructs a new instance of the StripePaymentsError class | 21 | 22 | ## Properties 23 | 24 | | Property | Modifiers | Type | Description | 25 | | --- | --- | --- | --- | 26 | | [cause?](./firestore-stripe-payments.stripepaymentserror.cause.md) | | any | (Optional) | 27 | | [code](./firestore-stripe-payments.stripepaymentserror.code.md) | | [StripePaymentsErrorCode](./firestore-stripe-payments.stripepaymentserrorcode.md) | | 28 | | [message](./firestore-stripe-payments.stripepaymentserror.message.md) | | string | | 29 | 30 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentserror.message.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsError](./firestore-stripe-payments.stripepaymentserror.md) > [message](./firestore-stripe-payments.stripepaymentserror.message.md) 4 | 5 | ## StripePaymentsError.message property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | readonly message: string; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentserrorcode.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsErrorCode](./firestore-stripe-payments.stripepaymentserrorcode.md) 4 | 5 | ## StripePaymentsErrorCode type 6 | 7 | Union of possible error codes. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type StripePaymentsErrorCode = "deadline-exceeded" | "not-found" | "permission-denied" | "unauthenticated" | "internal"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentsoptions.customerscollection.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsOptions](./firestore-stripe-payments.stripepaymentsoptions.md) > [customersCollection](./firestore-stripe-payments.stripepaymentsoptions.customerscollection.md) 4 | 5 | ## StripePaymentsOptions.customersCollection property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | customersCollection: string; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentsoptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsOptions](./firestore-stripe-payments.stripepaymentsoptions.md) 4 | 5 | ## StripePaymentsOptions interface 6 | 7 | Configuration options that indicate how the Stripe payments extension has been set up. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface StripePaymentsOptions 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [customersCollection](./firestore-stripe-payments.stripepaymentsoptions.customerscollection.md) | string | | 20 | | [productsCollection](./firestore-stripe-payments.stripepaymentsoptions.productscollection.md) | string | | 21 | 22 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.stripepaymentsoptions.productscollection.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [StripePaymentsOptions](./firestore-stripe-payments.stripepaymentsoptions.md) > [productsCollection](./firestore-stripe-payments.stripepaymentsoptions.productscollection.md) 4 | 5 | ## StripePaymentsOptions.productsCollection property 6 | 7 | Signature: 8 | 9 | ```typescript 10 | productsCollection: string; 11 | ``` 12 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.cancel_at.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [cancel\_at](./firestore-stripe-payments.subscription.cancel_at.md) 4 | 5 | ## Subscription.cancel\_at property 6 | 7 | A future date in UTC format at which the subscription will automatically get canceled. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly cancel_at: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.cancel_at_period_end.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [cancel\_at\_period\_end](./firestore-stripe-payments.subscription.cancel_at_period_end.md) 4 | 5 | ## Subscription.cancel\_at\_period\_end property 6 | 7 | If `true`, the subscription has been canceled by the user and will be deleted at the end of the billing period. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly cancel_at_period_end: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.canceled_at.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [canceled\_at](./firestore-stripe-payments.subscription.canceled_at.md) 4 | 5 | ## Subscription.canceled\_at property 6 | 7 | If the subscription has been canceled, the date of that cancellation as a UTC timestamp. If the subscription was canceled with [Subscription.cancel\_at\_period\_end](./firestore-stripe-payments.subscription.cancel_at_period_end.md), this field will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly canceled_at: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.created.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [created](./firestore-stripe-payments.subscription.created.md) 4 | 5 | ## Subscription.created property 6 | 7 | The date when the subscription was created as a UTC timestamp. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly created: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.current_period_end.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [current\_period\_end](./firestore-stripe-payments.subscription.current_period_end.md) 4 | 5 | ## Subscription.current\_period\_end property 6 | 7 | End of the current period that the subscription has been invoiced for as a UTC timestamp. At the end of the period, a new invoice will be created. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly current_period_end: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.current_period_start.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [current\_period\_start](./firestore-stripe-payments.subscription.current_period_start.md) 4 | 5 | ## Subscription.current\_period\_start property 6 | 7 | Start of the current period that the subscription has been invoiced for as a UTC timestamp. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly current_period_start: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.ended_at.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [ended\_at](./firestore-stripe-payments.subscription.ended_at.md) 4 | 5 | ## Subscription.ended\_at property 6 | 7 | If the subscription has ended, the date the subscription ended as a UTC timestamp. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly ended_at: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.id.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [id](./firestore-stripe-payments.subscription.id.md) 4 | 5 | ## Subscription.id property 6 | 7 | Unique Stripe subscription ID. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly id: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.metadata.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [metadata](./firestore-stripe-payments.subscription.metadata.md) 4 | 5 | ## Subscription.metadata property 6 | 7 | Set of extra key-value pairs attached to the subscription object. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly metadata: { 13 | [name: string]: string; 14 | }; 15 | ``` 16 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.price.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [price](./firestore-stripe-payments.subscription.price.md) 4 | 5 | ## Subscription.price property 6 | 7 | Stripe price ID associated with this subscription. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly price: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.prices.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [prices](./firestore-stripe-payments.subscription.prices.md) 4 | 5 | ## Subscription.prices property 6 | 7 | Array of product ID and price ID pairs. If multiple recurring prices were provided to the checkout session (e.g. via `lineItems`) this array holds all recurring prices for this subscription. The first element of this array always corresponds to the [Subscription.price](./firestore-stripe-payments.subscription.price.md) and [Subscription.product](./firestore-stripe-payments.subscription.product.md) fields on the subscription. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly prices: Array<{ 13 | product: string; 14 | price: string; 15 | }>; 16 | ``` 17 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.product.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [product](./firestore-stripe-payments.subscription.product.md) 4 | 5 | ## Subscription.product property 6 | 7 | Stripe product ID associated with this subscription. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly product: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.quantity.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [quantity](./firestore-stripe-payments.subscription.quantity.md) 4 | 5 | ## Subscription.quantity property 6 | 7 | Quantity of items purchased with this subscription. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly quantity: number | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.role.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [role](./firestore-stripe-payments.subscription.role.md) 4 | 5 | ## Subscription.role property 6 | 7 | The Firebae role that can be assigned to the user with this subscription. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly role: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.status.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [status](./firestore-stripe-payments.subscription.status.md) 4 | 5 | ## Subscription.status property 6 | 7 | The status of the subscription object 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly status: SubscriptionStatus; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.stripe_link.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [stripe\_link](./firestore-stripe-payments.subscription.stripe_link.md) 4 | 5 | ## Subscription.stripe\_link property 6 | 7 | A link to the subscription in the Stripe dashboard. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly stripe_link: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.trial_end.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [trial\_end](./firestore-stripe-payments.subscription.trial_end.md) 4 | 5 | ## Subscription.trial\_end property 6 | 7 | If the subscription has a trial, the end date of that trial as a UTC timestamp. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly trial_end: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.trial_start.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [trial\_start](./firestore-stripe-payments.subscription.trial_start.md) 4 | 5 | ## Subscription.trial\_start property 6 | 7 | If the subscription has a trial, the start date of that trial as a UTC timestamp. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly trial_start: string | null; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscription.uid.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [Subscription](./firestore-stripe-payments.subscription.md) > [uid](./firestore-stripe-payments.subscription.uid.md) 4 | 5 | ## Subscription.uid property 6 | 7 | Firebase Auth UID of the user that created the subscription. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | readonly uid: string; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionchangetype.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionChangeType](./firestore-stripe-payments.subscriptionchangetype.md) 4 | 5 | ## SubscriptionChangeType type 6 | 7 | Different types of changes that may occur on a subscription object. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type SubscriptionChangeType = "added" | "modified" | "removed"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionsnapshot.changes.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionSnapshot](./firestore-stripe-payments.subscriptionsnapshot.md) > [changes](./firestore-stripe-payments.subscriptionsnapshot.changes.md) 4 | 5 | ## SubscriptionSnapshot.changes property 6 | 7 | The list of changes in the subscriptions since the last snapshot. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | changes: Array<{ 13 | type: SubscriptionChangeType; 14 | subscription: Subscription; 15 | }>; 16 | ``` 17 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionsnapshot.empty.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionSnapshot](./firestore-stripe-payments.subscriptionsnapshot.md) > [empty](./firestore-stripe-payments.subscriptionsnapshot.empty.md) 4 | 5 | ## SubscriptionSnapshot.empty property 6 | 7 | True if there are no subscriptions available. False whenever at least one subscription is present. When True, the `subscriptions` array is empty, and the `size` is 0. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | empty: boolean; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionsnapshot.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionSnapshot](./firestore-stripe-payments.subscriptionsnapshot.md) 4 | 5 | ## SubscriptionSnapshot interface 6 | 7 | Represents the current state of a set of subscriptions owned by a user. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export interface SubscriptionSnapshot 13 | ``` 14 | 15 | ## Properties 16 | 17 | | Property | Type | Description | 18 | | --- | --- | --- | 19 | | [changes](./firestore-stripe-payments.subscriptionsnapshot.changes.md) | Array<{ type: [SubscriptionChangeType](./firestore-stripe-payments.subscriptionchangetype.md); subscription: [Subscription](./firestore-stripe-payments.subscription.md); }> | The list of changes in the subscriptions since the last snapshot. | 20 | | [empty](./firestore-stripe-payments.subscriptionsnapshot.empty.md) | boolean | True if there are no subscriptions available. False whenever at least one subscription is present. When True, the subscriptions array is empty, and the size is 0. | 21 | | [size](./firestore-stripe-payments.subscriptionsnapshot.size.md) | number | Number of currently available subscriptions. This is same as the length of the subscriptions array in the snapshot. | 22 | | [subscriptions](./firestore-stripe-payments.subscriptionsnapshot.subscriptions.md) | [Subscription](./firestore-stripe-payments.subscription.md)\[\] | A list of all currently available subscriptions ordered by the subscription ID. Empty if no subscriptions are available. | 23 | 24 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionsnapshot.size.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionSnapshot](./firestore-stripe-payments.subscriptionsnapshot.md) > [size](./firestore-stripe-payments.subscriptionsnapshot.size.md) 4 | 5 | ## SubscriptionSnapshot.size property 6 | 7 | Number of currently available subscriptions. This is same as the length of the `subscriptions` array in the snapshot. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | size: number; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionsnapshot.subscriptions.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionSnapshot](./firestore-stripe-payments.subscriptionsnapshot.md) > [subscriptions](./firestore-stripe-payments.subscriptionsnapshot.subscriptions.md) 4 | 5 | ## SubscriptionSnapshot.subscriptions property 6 | 7 | A list of all currently available subscriptions ordered by the subscription ID. Empty if no subscriptions are available. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | subscriptions: Subscription[]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.subscriptionstatus.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [SubscriptionStatus](./firestore-stripe-payments.subscriptionstatus.md) 4 | 5 | ## SubscriptionStatus type 6 | 7 | Possible states a subscription can be in. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type SubscriptionStatus = "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "trialing" | "unpaid"; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/firestore-stripe-payments.wherefilter.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) > [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) > [WhereFilter](./firestore-stripe-payments.wherefilter.md) 4 | 5 | ## WhereFilter type 6 | 7 | A filter constraint that can be applied to database queries. Consists of a field name (in Firestore dotted notation), a Firestore filter operator, and a value. 8 | 9 | Signature: 10 | 11 | ```typescript 12 | export declare type WhereFilter = [string, WhereFilterOp, any]; 13 | ``` 14 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/markdown/index.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [Home](./index.md) 4 | 5 | ## API Reference 6 | 7 | ## Packages 8 | 9 | | Package | Description | 10 | | --- | --- | 11 | | [@invertase/firestore-stripe-payments](./firestore-stripe-payments.md) | | 12 | 13 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/pack-for-examples.js: -------------------------------------------------------------------------------- 1 | const { execSync } = require("child_process"); 2 | const fs = require("fs"); 3 | const path = require("path"); 4 | 5 | execSync("npm run build", { stdio: "inherit" }); 6 | const filename = execSync("npm pack").toString().trim(); 7 | 8 | const targetName = "invertase-firestore-stripe-payments.tgz"; 9 | fs.copyFileSync(filename, path.join("examples/cjs", targetName)); 10 | fs.copyFileSync(filename, path.join("examples/esm", targetName)); 11 | fs.copyFileSync( 12 | filename, 13 | path.join("examples/esm-with-subscriptions", targetName) 14 | ); 15 | 16 | fs.unlinkSync(filename); 17 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@invertase/firestore-stripe-payments", 3 | "version": "0.0.8", 4 | "description": "Client SDK for the firestore-stripe-payments Firebase Extension", 5 | "main": "./lib/index.cjs", 6 | "module": "./lib/index.mjs", 7 | "types": "./lib/index.d.ts", 8 | "exports": { 9 | ".": { 10 | "types": "./lib/index.d.ts", 11 | "import": "./lib/index.mjs", 12 | "require": "./lib/index.cjs" 13 | } 14 | }, 15 | "scripts": { 16 | "build": "npm run clean && tsup", 17 | "build:watch": "tsup --watch", 18 | "pack-for-examples": "node pack-for-examples.js", 19 | "dev": "tsup --watch", 20 | "clean": "rimraf lib", 21 | "api-documenter": "api-documenter markdown --input-folder temp --output-folder markdown", 22 | "api-extractor": "api-extractor run --verbose", 23 | "api-extractor:local": "npm run build && api-extractor run --local --verbose", 24 | "test": "cd _emulator && firebase emulators:exec --project=demo-project \"cd .. && vitest run\"" 25 | }, 26 | "keywords": [ 27 | "firebase", 28 | "payments", 29 | "subscriptions", 30 | "stripe", 31 | "typescript", 32 | "sdk" 33 | ], 34 | "author": "Stripe (https://stripe.com/)", 35 | "contributors": [ 36 | "Firebase (https://firebase.google.com/)" 37 | ], 38 | "license": "Apache-2.0", 39 | "files": [ 40 | "lib/", 41 | "LICENSE", 42 | "NOTICE.txt", 43 | "README.md" 44 | ], 45 | "peerDependencies": { 46 | "firebase": "^9.0.0 || ^10.0.0 || ^11.0.0" 47 | }, 48 | "devDependencies": { 49 | "@microsoft/api-documenter": "^7.13.65", 50 | "@microsoft/api-extractor": "^7.18.17", 51 | "@vitest/coverage-v8": "^3.1.4", 52 | "firebase": "^11.8.1", 53 | "jsdom": "^26.1.0", 54 | "rimraf": "^6.0.1", 55 | "ts-node": "^10.2.1", 56 | "tsup": "^8.5.0", 57 | "typescript": "^5.8.3", 58 | "vitest": "^3.1.4" 59 | } 60 | } -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/src/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { 18 | StripePayments, 19 | StripePaymentsError, 20 | StripePaymentsErrorCode, 21 | StripePaymentsOptions, 22 | getStripePayments, 23 | } from "./init"; 24 | 25 | export { 26 | CREATE_SESSION_TIMEOUT_MILLIS, 27 | createCheckoutSession, 28 | CreateCheckoutSessionOptions, 29 | CommonLineItemParams, 30 | CommonSessionCreateParams, 31 | LineItem, 32 | LineItemParams, 33 | LineItemSessionCreateParams, 34 | PaymentMethodType, 35 | PriceIdLineItemParams, 36 | PriceIdSessionCreateParams, 37 | Session, 38 | SessionCreateParams, 39 | } from "./session"; 40 | 41 | export { 42 | GetPaymentsOptions, 43 | Payment, 44 | PaymentChangeType, 45 | PaymentSnapshot, 46 | PaymentStatus, 47 | getCurrentUserPayment, 48 | getCurrentUserPayments, 49 | onCurrentUserPaymentUpdate, 50 | } from "./payment"; 51 | 52 | export { 53 | GetProductOptions, 54 | GetProductsOptions, 55 | Price, 56 | Product, 57 | WhereFilter, 58 | WhereFilterOp, 59 | getPrice, 60 | getPrices, 61 | getProduct, 62 | getProducts, 63 | } from "./product"; 64 | 65 | export { 66 | getCurrentUserSubscription, 67 | getCurrentUserSubscriptions, 68 | onCurrentUserSubscriptionUpdate, 69 | GetSubscriptionsOptions, 70 | Subscription, 71 | SubscriptionChangeType, 72 | SubscriptionSnapshot, 73 | SubscriptionStatus, 74 | } from "./subscription"; 75 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/src/user.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { FirebaseApp } from "firebase/app"; 18 | import { Auth, getAuth } from "firebase/auth"; 19 | import { StripePayments, StripePaymentsError } from "./init"; 20 | 21 | /** 22 | * Internal API for retrieving the currently signed in user. Rejects with "unauthenticated" if 23 | * the user is not signed in. Exposed for internal use. 24 | * 25 | * @internal 26 | */ 27 | export function getCurrentUser(payments: StripePayments): Promise { 28 | try { 29 | const uid: string = getCurrentUserSync(payments); 30 | return Promise.resolve(uid); 31 | } catch (err: unknown) { 32 | return Promise.reject(err); 33 | } 34 | } 35 | 36 | /** 37 | * Internal API for retrieving the currently signed in user. Throws "unauthenticated" if 38 | * the user is not signed in. Exposed for internal use. 39 | * 40 | * @internal 41 | */ 42 | export function getCurrentUserSync(payments: StripePayments): string { 43 | const dao: UserDAO = getOrInitUserDAO(payments); 44 | return dao.getCurrentUser(); 45 | } 46 | 47 | /** 48 | * Internal interface for introspecting the current user's login session. Exposed for testing. 49 | * 50 | * @internal 51 | */ 52 | export interface UserDAO { 53 | getCurrentUser(): string; 54 | } 55 | 56 | class FirebaseAuthUserDAO implements UserDAO { 57 | private readonly auth: Auth; 58 | 59 | constructor(app: FirebaseApp) { 60 | this.auth = getAuth(app); 61 | } 62 | 63 | public getCurrentUser(): string { 64 | const currentUser: string | undefined = this.auth.currentUser?.uid; 65 | if (!currentUser) { 66 | throw new StripePaymentsError( 67 | "unauthenticated", 68 | "Failed to determine currently signed in user. User not signed in." 69 | ); 70 | } 71 | 72 | return currentUser; 73 | } 74 | } 75 | 76 | const USER_DAO_KEY = "user-dao" as const; 77 | 78 | function getOrInitUserDAO(payments: StripePayments): UserDAO { 79 | let dao: UserDAO | null = payments.getComponent(USER_DAO_KEY); 80 | if (!dao) { 81 | dao = new FirebaseAuthUserDAO(payments.app); 82 | setUserDAO(payments, dao); 83 | } 84 | 85 | return dao; 86 | } 87 | 88 | /** 89 | * Internal API for registering a {@link UserDAO} instance with {@link StripePayments}. 90 | * Exported for testing. 91 | * 92 | * @internal 93 | */ 94 | export function setUserDAO(payments: StripePayments, dao: UserDAO): void { 95 | payments.setComponent(USER_DAO_KEY, dao); 96 | } 97 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/src/utils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export function checkNonEmptyString(arg: unknown, message?: string): void { 18 | if (typeof arg !== "string" || arg === "") { 19 | throw new Error(message ?? "arg must be a non-empty string."); 20 | } 21 | } 22 | 23 | export function checkPositiveNumber(arg: unknown, message?: string): void { 24 | if (typeof arg !== "number" || isNaN(arg) || arg <= 0) { 25 | throw new Error(message ?? "arg must be positive number."); 26 | } 27 | } 28 | 29 | export function checkNonEmptyArray(arg: unknown, message?: string): void { 30 | if (!Array.isArray(arg) || arg.length === 0) { 31 | throw new Error(message ?? "arg must be a non-empty array."); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/test/setup.ts: -------------------------------------------------------------------------------- 1 | // Mock window.location 2 | Object.defineProperty(window, "location", { 3 | value: { 4 | href: "http://localhost", 5 | origin: "http://localhost", 6 | pathname: "/", 7 | }, 8 | writable: true, 9 | }); 10 | 11 | // Mock any other browser APIs needed for the tests 12 | global.window = window; 13 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "**/*.spec.ts", "**/*.test.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES6", 4 | "moduleResolution": "node", 5 | "strict": true, 6 | "preserveConstEnums": true, 7 | "sourceMap": true, 8 | "inlineSources": true, 9 | "declaration": true, 10 | "declarationMap": true, 11 | "skipLibCheck": true, 12 | "target": "ES6", 13 | "outDir": "lib", 14 | "forceConsistentCasingInFileNames": true, 15 | "stripInternal": true 16 | }, 17 | "include": ["src/*.ts", "test/*.ts"], 18 | "exclude": ["node_modules"] 19 | } 20 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "tsup"; 2 | import { version } from "./package.json"; 3 | 4 | export default defineConfig({ 5 | entry: ["src/index.ts"], 6 | format: ["cjs", "esm"], 7 | dts: true, 8 | sourcemap: true, 9 | clean: true, 10 | external: ["firebase", "firebase/app", "firebase/auth", "firebase/firestore"], 11 | noExternal: [], 12 | minify: false, 13 | splitting: false, 14 | treeshake: true, 15 | target: "es2020", 16 | outDir: "lib", 17 | outExtension({ format }) { 18 | return { 19 | js: format === "cjs" ? ".cjs" : ".mjs", 20 | }; 21 | }, 22 | esbuildOptions(options) { 23 | // Ensure Firebase imports stay as external imports 24 | options.platform = "neutral"; 25 | // Replace __VERSION__ with actual version 26 | options.define = { 27 | __VERSION__: JSON.stringify(version), 28 | }; 29 | }, 30 | }); 31 | -------------------------------------------------------------------------------- /firestore-stripe-web-sdk/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vitest/config"; 2 | 3 | export default defineConfig({ 4 | test: { 5 | environment: "jsdom", 6 | globals: true, 7 | setupFiles: ["./test/setup.ts"], 8 | include: ["**/*.spec.ts"], 9 | coverage: { 10 | provider: "v8", 11 | reporter: ["text", "json", "html"], 12 | }, 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "*", 4 | "firestore-stripe-invoices/functions", 5 | "firestore-stripe-payments/functions" 6 | ], 7 | "version": "0.0.0" 8 | } 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stripe-firebase-extensions", 3 | "version": "1.0.0", 4 | "description": "Repository of Firebase extensions built by Stripe.", 5 | "private": true, 6 | "scripts": { 7 | "format": "prettier --write \"**/*.{js,md,yml,ts,json,yaml}\"", 8 | "lint": "prettier --list-different \"**/*.{js,md,yml,ts,json,yaml}\"", 9 | "clean": "lerna run --parallel clean", 10 | "build": "lerna run --parallel build", 11 | "postinstall": "lerna bootstrap --no-ci && npm run clean && npm run build", 12 | "generate-readmes": "lerna run --parallel generate-readme", 13 | "dev": "cd $npm_config_ext/ && firebase ext:dev:emulators:start --test-params=../.env --project=$npm_config_project", 14 | "dev:invoices": "npm run dev --ext=firestore-stripe-invoices --project=stripe-subs-ext", 15 | "dev:subs": "npm run dev --ext=firestore-stripe-payments --project=stripe-subs-ext", 16 | "ext:install": "npm run build && firebase ext:install ./$npm_config_ext/ --params=.env --project=$npm_config_project", 17 | "ext:update": "npm run build && firebase ext:update $npm_config_ext ./$npm_config_ext/ --project=$npm_config_project", 18 | "ext:uninstall": "firebase ext:uninstall $npm_config_ext --project=$npm_config_project", 19 | "test": "lerna run test --stream --concurrency 1" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/stripe/stripe-firebase-extensions.git" 24 | }, 25 | "author": "Stripe (https://stripe.com/)", 26 | "license": "Apache-2.0", 27 | "bugs": { 28 | "url": "https://github.com/stripe/stripe-firebase-extensions/issues" 29 | }, 30 | "devDependencies": { 31 | "lerna": "^3.4.3", 32 | "prettier": "^2.4.1" 33 | }, 34 | "dependencies": { 35 | "rimraf": "^3.0.2" 36 | } 37 | } 38 | --------------------------------------------------------------------------------