简体   繁体   English

如何根据添加到条带产品的数据,使用 api 将数据输入 datoCMS

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

I have a Gatsby Website that is setup with DatoCMS, so when a change is made in datoCMS and built, it triggers a netlify build and updates all the content.我有一个使用 DatoCMS 设置的 Gatsby 网站,因此当在 datoCMS 中进行更改并构建时,它会触发 netlify 构建并更新所有内容。 I am also using the stripe source gatsby plugin to pull in products in graphQL and rebuild the site on netlify when those products, are updated via a netlify webhook triggered by stripe product update.我还使用条带源 gatsby 插件在 graphQL 中提取产品,并在这些产品通过条带产品更新触发的 netlify webhook 更新时在 netlify 上重建站点。

I'd also like the stripe products to live in datoCMS, so I can add more details pictures, text so ideally, instead of using the gatsby tripe source plugin to pull in data from stripe.我还希望将条带产品放在 datoCMS 中,这样我就可以添加更多细节图片、文本,非常理想,而不是使用 gatsby tripe 源插件从条带中提取数据。 I would somehow have stripe populate fields in datoCMS.我会以某种方式在 datoCMS 中使用条带填充字段。 They have a content managment API, where I could write a function to upload say a image like so他们有一个内容管理 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 editing on dato it should be able to add my other content to the same model that it generated. 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 中。

Basically my question is.基本上我的问题是。 Is there a way to trigger a netlify function to fire once the stripe source plugin for gatsby has pulled down the latest data at build and pass that data into the function to send to dato?一旦 gatsby 的条带源插件在构建时拉下最新数据并将该数据传递到 function 以发送到 dato,有没有办法触发 netlify function 触发? Also how would I test this in development, because the webhook is for the netlify site build, can I create a webhook for localtesting for stripe to trigger?另外我将如何在开发中测试它,因为 webhook 是用于 netlify 站点构建的,我可以创建一个 webhook 用于 localtesting 以触发条带吗?

Let me know if you need more explanation?如果您需要更多解释,请告诉我?

I'm not sure about Netlify build triggers, but you can use Stripe CLI to help with local Stripe webhook testing .我不确定 Netlify 构建触发器,但您可以使用 Stripe CLI 来帮助进行本地 Stripe webhook 测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM