|
1 | 1 | # Run Payments with Stripe
|
2 | 2 |
|
3 |
| -**Author**: Trent Rand (**[https://trentrand.com](https://trentrand.com)**), Invertase (**[https://invertase.io](https://invertase.io)**) |
| 3 | +**Author**: Trent Rand (**[https://trentrand.com](https://trentrand.com)**) |
4 | 4 |
|
5 | 5 | **Description**: Controls access to paid content by syncing your one-time and recurring payments with Firebase Authentication.
|
6 | 6 |
|
| 7 | + |
| 8 | + |
7 | 9 | **Details**: Use this extension as a backend for your [Stripe](https://www.stripe.com/) payments.
|
8 | 10 |
|
9 | 11 | The extension supports multiple use cases:
|
@@ -81,44 +83,53 @@ To install this extension, your Firebase project must be on the Blaze (pay-as-yo
|
81 | 83 |
|
82 | 84 | Starting August 17 2020, you will be billed a small amount (typically less than $0.10) when you install or reconfigure this extension. See the [Cloud Functions for Firebase billing FAQ](https://firebase.google.com/support/faq#expandable-15) for a detailed explanation.
|
83 | 85 |
|
| 86 | + |
| 87 | + |
| 88 | + |
84 | 89 | **Configuration Parameters:**
|
85 | 90 |
|
86 |
| -- Cloud Functions deployment location: Where do you want to deploy the functions created for this extension? You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations). |
| 91 | +* Cloud Functions deployment location: Where do you want to deploy the functions created for this extension? You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations). |
| 92 | + |
| 93 | +* Products and pricing plans collection: What is the path to the Cloud Firestore collection where the extension should store Stripe pricing plans? |
87 | 94 |
|
88 |
| -- Products and pricing plans collection: What is the path to the Cloud Firestore collection where the extension should store Stripe pricing plans? |
| 95 | +* Customer details and subscriptions collection: What is the path to the Cloud Firestore collection where the extension should store Stripe customer details? This can be the location of an existing user collection, the extension will not overwrite your existing data but rather merge the Stripe data into your existing `uid` docs. |
89 | 96 |
|
90 |
| -- Customer details and subscriptions collection: What is the path to the Cloud Firestore collection where the extension should store Stripe customer details? This can be the location of an existing user collection, the extension will not overwrite your existing data but rather merge the Stripe data into your existing `uid` docs. |
| 97 | +* Stripe configuration collection: What is the path to the Cloud Firestore collection where the extension should store Stripe configuration? |
91 | 98 |
|
92 |
| -- Stripe configuration collection: What is the path to the Cloud Firestore collection where the extension should store Stripe configuration? |
| 99 | +* Sync new users to Stripe customers and Cloud Firestore: Do you want to automatically sync new users to customer objects in Stripe? If set to 'Sync', the extension will create a new customer object in Stripe and add a new doc to the customer collection in Firestore when a new user signs up via Firebase Authentication. If set to 'Do not sync' (default), the extension will create the customer object "on the fly" with the first checkout session creation. |
93 | 100 |
|
94 |
| -- Sync new users to Stripe customers and Cloud Firestore: Do you want to automatically sync new users to customer objects in Stripe? If set to 'Sync', the extension will create a new customer object in Stripe and add a new doc to the customer collection in Firestore when a new user signs up via Firebase Authentication. If set to 'Do not sync' (default), the extension will create the customer object "on the fly" with the first checkout session creation. |
| 101 | +* Automatically delete Stripe customer objects: Do you want to automatically delete customer objects in Stripe? When a user is deleted in Firebase Authentication or in Cloud Firestore and set to 'Auto delete' the extension will delete their customer object in Stripe which will immediately cancel all subscriptions for the user. |
95 | 102 |
|
96 |
| -- Automatically delete Stripe customer objects: Do you want to automatically delete customer objects in Stripe? When a user is deleted in Firebase Authentication or in Cloud Firestore and set to 'Auto delete' the extension will delete their customer object in Stripe which will immediately cancel all subscriptions for the user. |
| 103 | +* Stripe API key with restricted access: What is your Stripe API key? We recommend creating a new [restricted key](https://stripe.com/docs/keys#limit-access) with write access only for the "Customers", "Checkout Sessions" and "Customer portal" resources. And read-only access for the "Subscriptions" and "Prices" resources. |
97 | 104 |
|
98 |
| -- Stripe API key with restricted access: What is your Stripe API key? We recommend creating a new [restricted key](https://stripe.com/docs/keys#limit-access) with write access only for the "Customers", "Checkout Sessions" and "Customer portal" resources. And read-only access for the "Subscriptions" and "Prices" resources. |
| 105 | +* Stripe webhook secret: This is your signing secret for a Stripe-registered webhook. This webhook can only be registered after installation. Leave this value untouched during installation, then follow the postinstall instructions for registering your webhook and configuring this value. |
| 106 | + |
| 107 | +* Minimum instances for createCheckoutSession function: Set the minimum number of function instances that should be always be available to create Checkout Sessions. This number can be adjusted to reduce cold starts and increase the responsiveness of Checkout Session creation requests. Suggested values are 0 or 1. Please note this setting will likely incur billing costss, see the [Firebase documentation](https://firebase.google.com/docs/functions/manage-functions#reduce_the_number_of_cold_starts) for more information. |
99 | 108 |
|
100 |
| -- Stripe webhook secret: This is your signing secret for a Stripe-registered webhook. This webhook can only be registered after installation. Leave this value untouched during installation, then follow the postinstall instructions for registering your webhook and configuring this value. |
101 | 109 |
|
102 |
| -- Minimum instances for createCheckoutSession function: Set the minimum number of function instances that should be always be available to create Checkout Sessions. This number can be adjusted to reduce cold starts and increase the responsiveness of Checkout Session creation requests. Suggested values are 0 or 1. Please note this setting will likely incur billing costss, see the [Firebase documentation](https://firebase.google.com/docs/functions/manage-functions#reduce_the_number_of_cold_starts) for more information. |
103 | 110 |
|
104 | 111 | **Cloud Functions:**
|
105 | 112 |
|
106 |
| -- **createCustomer:** Creates a Stripe customer object when a new user signs up. |
| 113 | +* **createCustomer:** Creates a Stripe customer object when a new user signs up. |
| 114 | + |
| 115 | +* **createCheckoutSession:** Creates a Checkout session to collect the customer's payment details. |
| 116 | + |
| 117 | +* **createPortalLink:** Creates links to the customer portal for the user to manage their payment & subscription details. |
107 | 118 |
|
108 |
| -- **createCheckoutSession:** Creates a Checkout session to collect the customer's payment details. |
| 119 | +* **handleWebhookEvents:** Handles Stripe webhook events to keep subscription statuses in sync and update custom claims. |
109 | 120 |
|
110 |
| -- **createPortalLink:** Creates links to the customer portal for the user to manage their payment & subscription details. |
| 121 | +* **onUserDeleted:** Deletes the Stripe customer object and cancels all their subscriptions when the user is deleted in Firebase Authentication. |
111 | 122 |
|
112 |
| -- **handleWebhookEvents:** Handles Stripe webhook events to keep subscription statuses in sync and update custom claims. |
| 123 | +* **onCustomerDataDeleted:** Deletes the Stripe customer object and cancels all their subscriptions when the customer doc in Cloud Firestore is deleted. |
113 | 124 |
|
114 |
| -- **onUserDeleted:** Deletes the Stripe customer object and cancels all their subscriptions when the user is deleted in Firebase Authentication. |
115 | 125 |
|
116 |
| -- **onCustomerDataDeleted:** Deletes the Stripe customer object and cancels all their subscriptions when the customer doc in Cloud Firestore is deleted. |
117 | 126 |
|
118 | 127 | **Access Required**:
|
119 | 128 |
|
| 129 | + |
| 130 | + |
120 | 131 | This extension will operate with the following project IAM roles:
|
121 | 132 |
|
122 |
| -- firebaseauth.admin (Reason: Allows the extension to set custom claims for users.) |
| 133 | +* firebaseauth.admin (Reason: Allows the extension to set custom claims for users.) |
123 | 134 |
|
124 |
| -- datastore.user (Reason: Allows the extension to store customers & subscriptions in Cloud Firestore.) |
| 135 | +* datastore.user (Reason: Allows the extension to store customers & subscriptions in Cloud Firestore.) |
0 commit comments