繁体   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