#b0otable
1 messages · Page 1 of 1 (latest)
Hi there!
You would do something like this stripe listen -f http://localhost:3000/webhooks
And you can learn more about this here: https://stripe.com/docs/cli/listen
The part that was confusing was making sure it was forwarding webhooks from my test key, not my production key
When I do stripe config --list
it has both keys
By default it uses your test key, unless you explicitly set --live, as mentioned here https://stripe.com/docs/cli/listen#listen-live
So currently my webhook is disabled, however the listen is picking up lots of events
ah, it just forwards everything unless defined via --events
Yes exactly.
It says that the The webhook signing secret provided will not change between restarts to the listen command. Is that still true if you change which events to listen to?
Yes
What would be the 'Stripe API key with restricted access' for the CLI
What do you mean? What are you trying to do?
It is a required field to integrate with the 'Run Payments with Stripe' official extension in Firebase
Not familiar with the Firebase extension. But if you want to create a restricted API key, you can do so in the Stripe dashboard here https://dashboard.stripe.com/test/apikeys
Ah, when you listen with the CLI it automatically generates a CLI Restricted Key for your machine
I'm going to try to use my already created rk_test and see if that works
Seems like the Restricted Key -> Controls access to Stripe
whsec key controls access from stripe
An API key (restricted or not) is to make API calls to Stripe. The whsec key is to check on your backend that the webhook event your receive actually come from Stripe.
Yeah, so in theory this should work
Takes a few min to deploy to test
Yep it works
Great!
Hmm... actually it 1/2 worked
Do you need help?
Can you clarify what you mean?
Well I'm looking at how Stripe handles events:
if (relevantEvents.has(event.type)) {
logs.startWebhookEventProcessing(event.id, event.type);
try {
switch (event.type) {
case 'product.created':
case 'product.updated':
await createProductRecord(event.data.object as Stripe.Product);
break;
case 'price.created':
case 'price.updated':
await insertPriceRecord(event.data.object as Stripe.Price);
break;
case 'product.deleted':
await deleteProductOrPrice(event.data.object as Stripe.Product);
break;
case 'price.deleted':
await deleteProductOrPrice(event.data.object as Stripe.Price);
break;
This means that unless the webhook was listening when the product was created, it doesn't exist
there doesn't appear to be any synchronize support
At minimum it would be good to be able to send 'product created' and 'price created' events for all products/prices
At minimum it would be good to be able to send 'product created' and 'price created' events for all products/prices
You can't do that directly, but there are workarounds:
- For example by using this endpoint: https://stripe.com/docs/api/events/list, however it will only work for the last 30 days
- Or if you are only interested in products/prices, you can directly list all products/prices: https://stripe.com/docs/api/products/list and https://stripe.com/docs/api/prices/list
directly listing them won't trigger a webhook though
That's true, but if you want to synchronize existing products/prices, then webhooks are not meant for that.
That seems odd... how are you supposed to test.
For example, with the official Stripe 'Run Payments with Stripe' extension with Firebase.
It creates documents within the Firestore based on the code above.
When you restart an emulator, it wipes out all documents
Option 1:
Wipe Test Stripe Data
Rebuild products / prices
=> Would be a bit of a pain and not possible as Stripe doesn't support wiping data, even on their test enviornment
Option 2:
Initiate a script to synchronize the current test Stripe Environment
This seems absolutely essential for the test environment.
And honestly, unless you plan never to have a single error, also required for production environments
and not possible as Stripe doesn't support wiping data,
Yes you can at the bottom of this page: https://dashboard.stripe.com/test/developers
Initiate a script to synchronize the current test Stripe Environment
That seems like a good idea, that's why I suggested listing all existing products/price to sync them
Unless I can trigger the price & product created webhooks, this isn't really a viable solution
The extension is an officially supported extension built into firebase. I don't have access to the code to modify, I just was able to view it by going into GCP and looking at what it was doing (or viewing it on github)
If there was a way to iterate through all of the prices/products and have Stripe send via Webhook as 'updated', that would work (I think)
Again I'm not at all familiar with the Firebase extension. But in general you have a few option to sync your existing data:
- Use the list endpoints to list all objects that you want to sync
- Use https://stripe.com/docs/api/events/list to view all events from the last 30 days
- Or delete all your test data to start from scratch using https://dashboard.stripe.com/test/developers
- Use the list endpoints to list all objects that you want to sync
=> Unless this is sent via webhook, it will not rebuild the structure. The document structure was created by 'Stripe'. It is similar to what comes out of list, but not the same. - Use https://stripe.com/docs/api/events/list to view all events from the last 30 days
=> Does no help when products past 30 days... which is nearly all products for me. - Or delete all your test data to start from scratch using https://dashboard.stripe.com/test/developers
=> Even after you clear it out, you would need to trigger the webhook to have Stripe rebuild it in their structure.
Couple options:
- You'll need to build the Firestore documents manually using some kind of function that writes to the collection. e.g. list out the objects from our API, loop through them and make an API request to Firebase to write a document to the collection(s).
- Re-trigger a
product.updatedevent by making some kind of mutation on the object, which will trigger the extension'screateProductRecordfunction.
What would be the easiest way to trigger product.updated and price.updated
It seems if I just save the products on the dashboard it triggers a product update, but I actually have to change something for a price update
Maybe update a metadata key/value or something. There's only so many fields on those resources that are mutable once they've been 'used'
maybe I could just add a metadata date property
Unfortunately the extension doesn't have a way to sync your existing Stripe catalogue. It's somewhat unmaintained in its current state
somewhat is a massive massive understatement
It has been a hugely disappointing experience using it from start to now
I don't understand why it is advertised so much and one of the top extension focused on so often
when it really isn't usable for production
you want to build a quick youtube video on adding things... great, but if you need to actually use it for your company
You'd need to speak to Google/Firebase about that. It's not something we actively promote/push
I know this is likely out of your control but I honestly view that as a weak excuse.
Your company name is on it, your company made a deal with Firebase to have it centered, check boxed, and 'official'
Is there a technical question I can help with?
In order to trigger those updates it sounds like i would need to integrate with the full stripe api?
How many Stripe objects are you working with?
Currently there aren't many.
I have 3 products, each with two prices
I can manually update them for production
However for testing, trying to rebuild the stripe prices every single time would be a huge pain
Well, that's basically what the tests for the extension does: https://github.com/stripe/stripe-firebase-extensions/blob/next/firestore-stripe-payments/functions/__tests__/helpers/setupProducts.ts
If you want my honest opinion – I'd build your integration sans the extension
Yeah, would have been nice to know before spending all of this time.
do you have any examples of people scripting (e.g. with Python) the stripe cli
Not sure what you mean by 'scripting the CLI'
well one suggestion was using the stripe cli to list the products and prices and then rebuild the document structure
or at least I assumed you meant with the stripe cli
I wouldn't use the CLI with that. Just query the API directly for the JSON
Is there issues having both @stripe/firestore-stripe-payments@0.0.6 and the normal API installed at the same time?
By normal API I assume you mean our Node SDK?
Node SDK
Or is the Node SDK also not supported/maintained and I should use the regular API?
Please tell me honestly, I would rather have to rewrite only once
That is most definitely maintained: https://github.com/stripe/stripe-node
Well I just sent a message to the Developer Relations guy @ firebase
Let me know if there's any Stripe specific tech Qs I can answer