我有一个serverless应用程序(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",
}
);
任何建议都会有所帮助。另外,我发现了this question,但那里也没有运气。