簡體   English   中英

如何根據添加到條帶產品的數據,使用 api 將數據輸入 datoCMS

[英]How to input data into datoCMS with api based off of data added to stripe product

我有一個使用 DatoCMS 設置的 Gatsby 網站,因此當在 datoCMS 中進行更改並構建時,它會觸發 netlify 構建並更新所有內容。 我還使用條帶源 gatsby 插件在 graphQL 中提取產品,並在這些產品通過條帶產品更新觸發的 netlify webhook 更新時在 netlify 上重建站點。

我還希望將條帶產品放在 datoCMS 中,這樣我就可以添加更多細節圖片、文本,非常理想,而不是使用 gatsby tripe 源插件從條帶中提取數據。 我會以某種方式在 datoCMS 中使用條帶填充字段。 他們有一個內容管理 API,我可以在其中寫一個 function 來上傳這樣的圖像

client.uploadFile('http://i.giphy.com/NXOF5rlaSXdAc.gif')
  .then((image) => {
    return client.items.create({
      itemType: '7149',
      title: 'My first article!',
      content: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod.',
      coverImage: image
    })
  })
  .then(record => console.log(record));

However I would have to run this function as a netlify function at build time from the webhook being triggered by stripe with a new product, then somehow trigger this function, witht the correct stripe product infro, send it to DatoCMS, then once I am done在 dato 上編輯它應該能夠將我的其他內容添加到它生成的相同 model 中。

基本上我的問題是。 一旦 gatsby 的條帶源插件在構建時拉下最新數據並將該數據傳遞到 function 以發送到 dato,有沒有辦法觸發 netlify function 觸發? 另外我將如何在開發中測試它,因為 webhook 是用於 netlify 站點構建的,我可以創建一個 webhook 用於 localtesting 以觸發條帶嗎?

如果您需要更多解釋,請告訴我?

我不確定 Netlify 構建觸發器,但您可以使用 Stripe CLI 來幫助進行本地 Stripe webhook 測試

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM