reactjs - 从 Gatsby React 中的脚本通过 Stripe API 创建新的 SKU
问题描述
我想通过条带 API 创建一个新的 SKU。但是,Stripe API 似乎不支持 Gatsby:https ://stripe.com/docs/api/skus/create?lang=node - “最接近”的东西是 Node.js --- 这不是甚至接近盖茨比。
我尝试过处理和粘贴代码的 Node.js 版本,但我相信它会破坏 Gatsby 编译过程,因为它使用的是 Node.js 语法——这在我的 React/Gatsby 语法中是不允许的。
var stripe = require("stripe")("sk_secret_key");
stripe.skus.create({
product: '200',
attributes: {size: 'Medium', gender: 'Unisex'},
price: 1500,
currency: 'usd',
inventory: {type: 'finite', quantity: 500}
}, function(err, sku) {
// asynchronously called
});
这根本不编译。
在 Stripe 中创建 SKU 是否与 Gatsby 100% 不兼容?还是有更好的方法来解决这个问题?
解决方案
推荐阅读
- r - 在 R 的数据框中,Column1 的值是 Column2 的最小值
- javascript - TypeError:无法读取未定义的属性(在 P5js / p5.play.js 中)
- javascript - 如何模块化这个反应状态容器?
- kubernetes - 在 k8s 中运行的 Fluentbit 中为主机值附加 2 个字段
- c - scanf() 函数的一些问题
- git - git rebase 并重置对源分支的提交
- python - 在pygame中垂直向下打印for循环中的项目?
- python - 使用两个列表如何使用第二个列表作为参考计算一个列表中两个元素之间的最低价格?
- reactjs - 反应按钮 onClick
- asp.net - HTTP 404:切换电脑后找不到资源