njosefbeck / gatsby-source-stripe

Gatsby source plugin for building websites using Stripe as a data source
74 stars 17 forks source link

[question] how rebuild happens automatically when something changes in product information! #37

Closed iFlameing closed 5 years ago

iFlameing commented 5 years ago

Prerequisites

Description

I am trying to implement the retrigger the gatsby develop automatically whenever something changes in headless cms as this feature provided by gatsby-source-stripe. I found that when something changes in the product information on stripe website a webhook is retriggered and gatsby build initiated on the client side. But I didn't find the code which handles this trigger event in the source code. can anyone point out the code where we handle the webhook retrigger please!

njosefbeck commented 5 years ago

Hello!

Appreciate the question, though this is most likely something handled outside of our plugin. I can try to help you though. A couple thoughts:

1) Where do you have your Gatsby site hosted? If using Netlify (recommended), see this article for information about setting up incoming build webhooks. 2) If you're editing product and sku information in the Stripe dashboard, you'll need to use Stripe webhooks associated with the following events, probably: product.created, product.deleted, product.updated (and the same ones for sku). A full list is here and the Stripe documentation about setting up webhooks is here.

Hope this helps! Let me know if you have any questions.

iFlameing commented 5 years ago

@njosefbeck thanks for your help. Yes, my site is hosted with Netlify :)

njosefbeck commented 5 years ago

Okay, so with Netlify this should be rather simple!

  1. Go to Netlify and set up a Build Hook, as described in the article I linked above. Once you have your hook's URL...
  2. Go to https://dashboard.stripe.com/webhooks and click "Add Endpoint". Paste in the Netlify hook URL, and select all Events to send (search for Product and Sku and add all those).
  3. Test by changing a Product or Sku in your Stripe dashboard and see if your build gets triggered in Netlify.

I didn't read through the documentation too thoroughly, but that should be essentially what you need to do. Hope this helps! Let me know if it works for you.

iFlameing commented 5 years ago

@njosefbeck After reading the documentation and following your step as mention above I am able to set up. thank you very much for your help and time!

njosefbeck commented 5 years ago

My pleasure! Glad you got it working 👍