Integration Stripe Angular,找不到名称 'Stripe'。您是说 'stripe' 吗?

Integration Stripe Angular, Cannot find name 'Stripe'. Did you mean 'stripe'?

我正在尝试将 Stripe 与重定向集成到我的应用程序中,我正在使用 Angular-typescript。

这是我目前在组件中的代码:

var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.onload = function() {
  console.log('Script loaded');
  var stripe = Stripe(MY_PUBLICK_KEY);
  return stripe.redirectToCheckout({ sessionId: SESSION_I_RETURNED_FROM_MY_BACKEND});
}
script.src = 'https://js.stripe.com/v3/';
head.appendChild(script);

但是我上面的代码出现如下错误运行:

Cannot find name 'Stripe'. Did you mean 'stripe'?

我已经按照下一个指南 https://stripe.com/docs/checkout/integration-builder

使用命令 npm install --save stripe 安装了软件包

有没有人在集成 Stripe 时遇到同样的问题?

谢谢!

stripe包对应stripe-node,a server-side library. For a client-side Angular application, you need Stripe.js.

Stripe 有一个可用的模块加载器帮助程序库:@stripe/stripe-js (link) 您可能还想查看社区制作的 ngx-stripe 库,但如果您主要使用 redirectToCheckout,则可以跳过此部分。