node.js - 如何实现 Stripe 的 per-request 认证?
问题描述
我有一个无服务器应用程序(AWS Serverless、 NodeJS),我正在尝试在我的项目中使用 Stripe 的按请求身份验证来创建客户和支付意图。文档参考:https ://stripe.com/docs/api/authentication
当我使用全局身份验证时,它可以工作:
const stripe = require('stripe')('sk_test_key');
const customer = await stripe.customers.create(
{
name,
email,
}
);
但是在每个请求的身份验证中,它会失败并显示消息Cannot read property "create" of undefined.
const stripe = require('stripe');
const customer = await stripe.customers.create(
{
name,
email,
},
{
api_key:
"sk_test_key",
}
);
任何意见将是有益的。另外,我发现了这个问题,但也没有运气。
解决方案
推荐阅读
- ios - ios 12 PWA 网络推送通知。它有效吗?
- php - 如何让 Outlook 日历事件与 PHP 日历同步
- python - 将键:值对拆分为字典中的两对的最佳方法-python
- java - 更新 Android Studio 3.2 并显示 gradle 项目同步失败
- javascript - 如果值为空,则隐藏 div (javascript)
- java - AutoClose HttpURLConnection 与 JAVA 中的 DB 连接(使用 try-with-resource)相同
- java - Java List 创建一个大小有限的二级列表
- cassandra - 在 cassandra 中读取延迟统计信息
- javascript - django 2.0 中 /blog/ 的 NoReverseMatch
- c++11 - 如何将值附加到犰狳矩阵?