-
Notifications
You must be signed in to change notification settings - Fork 161
/
extension.yaml
309 lines (284 loc) · 13.1 KB
/
extension.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# Copyright 2020 Stripe, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: firestore-stripe-payments
version: 0.3.3
specVersion: v1beta
displayName: Run Payments with Stripe
description: Controls access to paid content by syncing your one-time and recurring payments with Firebase Authentication.
license: Apache-2.0
sourceUrl: https://github.com/stripe/stripe-firebase-extensions/tree/master/firestore-stripe-payments
releaseNotesUrl: https://github.com/stripe/stripe-firebase-extensions/tree/master/firestore-stripe-payments/CHANGELOG.md
author:
authorName: Stripe
url: https://stripe.com
contributors:
- authorName: Thorsten Schaeff
url: https://twitter.com/thorwebdev
- authorName: Firebase
url: https://firebase.google.com
billingRequired: true # this extension makes requests to a third party API (Stripe)
externalServices:
- name: Stripe
pricingUri: https://stripe.com/pricing
roles:
- role: firebaseauth.admin
reason: >-
Allows the extension to set custom claims for users.
- role: datastore.user
reason: >-
Allows the extension to store customers & subscriptions in Cloud Firestore.
resources:
- name: createCustomer
type: firebaseextensions.v1beta.function
description: >-
Creates a Stripe customer object when a new user signs up.
properties:
location: ${LOCATION}
runtime: nodejs14
eventTrigger:
eventType: providers/firebase.auth/eventTypes/user.create
resource: projects/${PROJECT_ID}
- name: createCheckoutSession
type: firebaseextensions.v1beta.function
description: >-
Creates a Checkout session to collect the customer's payment details.
properties:
location: ${LOCATION}
runtime: nodejs14
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.create
resource: projects/${PROJECT_ID}/databases/(default)/documents/${CUSTOMERS_COLLECTION}/{uid}/checkout_sessions/{id}
- name: createPortalLink
type: firebaseextensions.v1beta.function
description: >-
Creates links to the customer portal for the user to manage their payment & subscription details.
properties:
location: ${LOCATION}
runtime: nodejs14
httpsTrigger: {}
- name: handleWebhookEvents
type: firebaseextensions.v1beta.function
description: >-
Handles Stripe webhook events to keep subscription statuses in sync and update custom claims.
properties:
location: ${LOCATION}
runtime: nodejs14
httpsTrigger: {}
- name: onUserDeleted
type: firebaseextensions.v1beta.function
description: >-
Deletes the Stripe customer object and cancels all their subscriptions when the user is deleted in Firebase Authentication.
properties:
location: ${LOCATION}
runtime: nodejs14
eventTrigger:
eventType: providers/firebase.auth/eventTypes/user.delete
resource: projects/${PROJECT_ID}
- name: onCustomerDataDeleted
type: firebaseextensions.v1beta.function
description: >-
Deletes the Stripe customer object and cancels all their subscriptions when the customer doc in Cloud Firestore is deleted.
properties:
location: ${LOCATION}
runtime: nodejs14
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.delete
resource: projects/${PROJECT_ID}/databases/(default)/documents/${CUSTOMERS_COLLECTION}/{uid}
params:
- param: LOCATION
label: Cloud Functions deployment location
description: >-
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).
type: select
options:
- label: Iowa (us-central1)
value: us-central1
- label: South Carolina (us-east1)
value: us-east1
- label: Northern Virginia (us-east4)
value: us-east4
- label: Oregon (us-west1)
value: us-west1
- label: Los Angeles (us-west2)
value: us-west2
- label: Salt Lake City (us-west3)
value: us-west3
- label: Las Vegas (us-west4)
value: us-west4
- label: Warsaw (europe-central2)
value: europe-central2
- label: Belgium (europe-west1)
value: europe-west1
- label: London (europe-west2)
value: europe-west2
- label: Frankfurt (europe-west3)
value: europe-west3
- label: Zurich (europe-west6)
value: europe-west6
- label: Hong Kong (asia-east2)
value: asia-east2
- label: Tokyo (asia-northeast1)
value: asia-northeast1
- label: Osaka (asia-northeast2)
value: asia-northeast2
- label: Seoul (asia-northeast3)
value: asia-northeast3
- label: Mumbai (asia-south1)
value: asia-south1
- label: Jakarta (asia-southeast2)
value: asia-southeast2
- label: Montreal (northamerica-northeast1)
value: northamerica-northeast1
- label: Sao Paulo (southamerica-east1)
value: southamerica-east1
- label: Sydney (australia-southeast1)
value: australia-southeast1
default: us-central1
required: true
immutable: true
- param: PRODUCTS_COLLECTION
label: Products and pricing plans collection
description: >-
What is the path to the Cloud Firestore collection where the extension should store Stripe pricing plans?
default: products
validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
validationErrorMessage: Firestore collection paths must be an odd number of segments separated by slashes, e.g. "path/to/collection".
required: true
- param: CUSTOMERS_COLLECTION
label: Customer details and subscriptions collection
description: >-
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.
default: customers
validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
validationErrorMessage: Firestore collection paths must be an odd number of segments separated by slashes, e.g. "path/to/collection".
required: true
- param: STRIPE_CONFIG_COLLECTION
label: Stripe configuration collection
description: >-
What is the path to the Cloud Firestore collection where the extension should store Stripe configuration?
default: configuration
validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
validationErrorMessage: Firestore collection paths must be an odd number of segments separated by slashes, e.g. "path/to/collection".
required: false
- param: SYNC_USERS_ON_CREATE
label: Sync new users to Stripe customers and Cloud Firestore
description: >-
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.
type: select
options:
- label: 'Do not sync'
value: 'Do not sync'
- label: 'Sync'
value: 'Sync'
default: 'Do not sync'
required: true
- param: DELETE_STRIPE_CUSTOMERS
label: Automatically delete Stripe customer objects
description: >-
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.
type: select
options:
- label: 'Do not delete'
value: 'Do not delete'
- label: 'Auto delete'
value: 'Auto delete'
default: 'Do not delete'
required: true
- param: STRIPE_API_KEY
label: Stripe API key with restricted access
type: secret
description: >-
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.
example: rk_live_1234567890
required: true
- param: STRIPE_WEBHOOK_SECRET
label: Stripe webhook secret
type: secret
description: >-
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.
example: whsec_1234567890
required: false
- param: CREATE_CHECKOUT_SESSION_MIN_INSTANCES
label: Minimum instances for createCheckoutSession function
description: >-
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.
default: 0
required: true
events:
- type: com.stripe.v1.product.created
description: Occurs whenever a product is created.
- type: com.stripe.v1.product.updated
description: Occurs whenever a product is updated.
- type: com.stripe.v1.product.deleted
description: Occurs whenever a product is deleted.
- type: com.stripe.v1.price.created
description: Occurs whenever a price is created.
- type: com.stripe.v1.price.updated
description: Occurs whenever a price is updated.
- type: com.stripe.v1.price.deleted
description: Occurs whenever a price is deleted.
- type: com.stripe.v1.checkout.session.completed
description: Occurs when a Checkout Session has been successfully completed.
- type: com.stripe.v1.checkout.session.async_payment_succeeded
description: Occurs when a payment intent using a delayed payment method finally succeeds.
- type: com.stripe.v1.checkout.session.async_payment_failed
description: Occurs when a payment intent using a delayed payment method fails.
- type: com.stripe.v1.customer.subscription.created
description: Occurs whenever a customer is signed up for a new plan.
- type: com.stripe.v1.customer.subscription.updated
description: Occurs whenever a subscription changes (e.g., switching from one plan to another, or changing the status from trial to active).
- type: com.stripe.v1.customer.subscription.deleted
description: Occurs whenever a customer's subscription ends.
- type: com.stripe.v1.tax_rate.created
description: Occurs whenever a new tax rate is created.
- type: com.stripe.v1.tax_rate.updated
description: Occurs whenever a tax rate is updated.
- type: com.stripe.v1.invoice.paid
description: Occurs whenever an invoice payment attempt succeeds or an invoice is marked as paid out-of-band.
- type: com.stripe.v1.invoice.payment_succeeded
description: Occurs whenever an invoice payment attempt succeeds.
- type: com.stripe.v1.invoice.payment_failed
description: Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method.
- type: com.stripe.v1.invoice.upcoming
description: Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings.
- type: com.stripe.v1.invoice.marked_uncollectible
description: Occurs whenever an invoice is marked uncollectible.
- type: com.stripe.v1.invoice.payment_action_required
description: Occurs whenever an invoice payment attempt requires further user action to complete.
- type: com.stripe.v1.payment_intent.processing
description: Occurs when a PaymentIntent has started processing.
- type: com.stripe.v1.payment_intent.succeeded
description: Occurs when a PaymentIntent has successfully completed payment.
- type: com.stripe.v1.payment_intent.canceled
description: Occurs when a PaymentIntent is canceled.
- type: com.stripe.v1.payment_intent.payment_failed
description: Occurs when a PaymentIntent has failed the attempt to create a payment method or a payment.