#b0otable

1 messages · Page 1 of 1 (latest)

timber trellisBOT
pastel anchor
#

Hi there!

tawny jetty
#

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

pastel anchor
tawny jetty
#

So currently my webhook is disabled, however the listen is picking up lots of events

#

ah, it just forwards everything unless defined via --events

pastel anchor
#

Yes exactly.

tawny jetty
#

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?

pastel anchor
#

Yes

tawny jetty
#

What would be the 'Stripe API key with restricted access' for the CLI

pastel anchor
#

What do you mean? What are you trying to do?

tawny jetty
#

It is a required field to integrate with the 'Run Payments with Stripe' official extension in Firebase

pastel anchor
tawny jetty
#

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

pastel anchor
#

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.

tawny jetty
#

Yeah, so in theory this should work

#

Takes a few min to deploy to test

#

Yep it works

pastel anchor
#

Great!

tawny jetty
#

Hmm... actually it 1/2 worked

pastel anchor
#

Do you need help?

tawny jetty
#

Yeah

#

Is there a way with the CLI for it to send updated product information

pastel anchor
#

Can you clarify what you mean?

tawny jetty
#

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

pastel anchor
tawny jetty
#

directly listing them won't trigger a webhook though

pastel anchor
#

That's true, but if you want to synchronize existing products/prices, then webhooks are not meant for that.

tawny jetty
#

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

pastel anchor
#

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

tawny jetty
#

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)

pastel anchor
tawny jetty
#
  • 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.
rich otter
#

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.updated event by making some kind of mutation on the object, which will trigger the extension's createProductRecord function.
tawny jetty
#

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

rich otter
#

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'

tawny jetty
#

maybe I could just add a metadata date property

rich otter
#

Unfortunately the extension doesn't have a way to sync your existing Stripe catalogue. It's somewhat unmaintained in its current state

tawny jetty
#

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

rich otter
tawny jetty
#

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'

rich otter
#

Is there a technical question I can help with?

tawny jetty
#

In order to trigger those updates it sounds like i would need to integrate with the full stripe api?

rich otter
#

How many Stripe objects are you working with?

tawny jetty
#

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

rich otter
#

If you want my honest opinion – I'd build your integration sans the extension

tawny jetty
#

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

rich otter
#

Not sure what you mean by 'scripting the CLI'

tawny jetty
#

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

rich otter
#

I wouldn't use the CLI with that. Just query the API directly for the JSON

tawny jetty
#

Is there issues having both @stripe/firestore-stripe-payments@0.0.6 and the normal API installed at the same time?

rich otter
#

By normal API I assume you mean our Node SDK?

tawny jetty
#

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

rich otter
tawny jetty
#

Well I just sent a message to the Developer Relations guy @ firebase

rich otter
#

Let me know if there's any Stripe specific tech Qs I can answer