首页 > 解决方案 > 如何实现 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",
    }
  );

任何意见将是有益的。另外,我发现了这个问题,但也没有运气。

标签: node.jsstripe-payments

解决方案


推荐阅读