Marketplace
>
createStripeSetupIntent
rainbow

createStripeSetupIntent

v
0.0.2
Latest Version
Likes
0
4
Installations
0
3
Views
0
4

Overview

Create a SetupIntent object to add a new user payment method.

Usage

### How this function works Use this HTTPS function to set up a payment method for future payments. The goal is to have payment credentials saved and optimized for future payments, which means that the payment method is configured correctly for any scenario. ### Requirements * You must have previous knowledge of **Firebase**. * You must have previous knowledge of **Firestore**. * You must have previous knowledge of **Stripe**. ### Function details This function resolves the Stripe customer from a Firestore collection, asuming the ID of each document is the Firebase user ID (i.e. `STRIPE_CUSTOMERS_COLLECTION_PATH/{uid}`), and the saved document is a Stripe customer object (See https://stripe.com/docs/api/customers/object). Once the customer is obtained, it is used to set up and save the customer's card in Stripe. See [The Setup Intents API](https://stripe.com/docs/payments/setup-intents) on Stripe docs for more info. To install this function you need to enter the values of the following environment variables: * **STRIPE_SECRET_KEY**: Your Stripe secret API key. See [https://stripe.com/docs/keys](https://stripe.com/docs/keys). * **STRIPE_CUSTOMERS_COLLECTION_PATH**: The collection path where the Stripe customers are stored. This function returns an object with a field "clientSecret" which can be used to complete payment setup from your frontend. Here is an example of how to call this function from your app with JavaScript: ```js // assuming `firebase` is an initialized Firebase app const createStripeSetupIntent = firebase.functions().httpsCallable('createStripeSetupIntent'); const intent = await createStripeSetupIntent(); // `intent` is { clientSecret: 'secret_key' } ```
Cost
FREE
Cost
Version
0.0.2
Language
JAVASCRIPT
Created At
Updated At
Workspace
rainbow
Tags
billing
stripe
payment
© 2022 Function Store