如何实现Stripe的按请求身份验证?

时间:2020-10-02 08:46:59

标签: node.js stripe-payments

我有一个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,但那里也没有运气。

0 个答案:

没有答案
相关问题