javascript - Stripe.js 未正确加载

标签 javascript stripe-payments

我正在将 Stripe 加载到我的付款页面中,如下所示:

<script src="https://js.stripe.com/v3/"></script>

这在我的本地测试环境中完美运行,但在生产中,出现以下控制台错误:
Uncaught Error: It looks like Stripe.js was not loaded correctly
    at new e (controller-84824401a25a5595fc578f767b4d5c27.js:1)
    at controller-84824401a25a5595fc578f767b4d5c27.js:1
    at Object.bnjt (controller-84824401a25a5595fc578f767b4d5c27.js:1)
    at t (shared-d3604a85e14ef273096e09821a0e4c2a.js:1)
    at Object.3 (controller-84824401a25a5595fc578f767b4d5c27.js:1)
    at t (shared-d3604a85e14ef273096e09821a0e4c2a.js:1)
    at window.webpackJsonp (shared-d3604a85e14ef273096e09821a0e4c2a.js:1)
    at controller-84824401a25a5595fc578f767b4d5c27.js:1

我无法弄清楚可能导致错误的原因。我在生产中使用HTTPS,可以看到JS文件源下载成功。有小费吗?

最佳答案

解决了@NathanCasebolt 的建议。 SO mods 删除了他原来的答案:

“For me, the resolution to this error was as simple as spell-checking my variables. In my backend server code, one of my variables was wrongly capitalized. Since the misspelled variable was part of the function that retrieves my publishable key, the key returned from the server as null. This, in turn, disrupted creation of the Stripe object and threw this error. If I were you, I'd check to make sure (1) that the publishable key on your frontend matches the publishable key in your dashboard, and (2) that you're not doing anything that might disrupt serving this key to Stripe.”

The StackOverflow mods felt this didn’t answer the question and required too much clarification. So, to clarify, the problem for me was this line:

var stripe = Stripe(‘{PUBLISHABLE_KEY}’);

I set things up to retrieve my publishable keys from my server, to give me more flexibility in switching between test keys and live keys. Since my one of my server variables was wrong, I was providing Stripe with a bad key (no key, really), and that’s what threw the error. This is why I suggest you check the publishable key you’re using to create the Stripe object, to make sure that the one you’re using to create the object is there, and that it matches the publishable key you have on your Stripe dashboard."



就我而言,这正是我做错的:在初始化 Stripe 时提供了一个空的可发布 key 。最终,一个非常简单的错误加剧了 Stripe 迟钝的错误信息。

关于javascript - Stripe.js 未正确加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48297274/

相关文章:

javascript - 具有圆锥形渐变的圆

stripe-payments - 如何获取 Stripe 发票的计费周期?

payment-gateway - Stripe - 如何使用免费计划处理订阅且注册时无需信用卡

stripe-payments - 通过卡片详细信息防止多次 Stripe 试验

javascript - 使用 stripe API 从 stripe token 获取费用金额

java - 我需要自己的服务器才能使用 Stripe API 吗?

javascript - 从带有子字段的平面列表构造层次结构树?

javascript - 将 <td> 列除以输入值

javascript - 从列表中删除项目

javascript - 迭代所有其他 AJAX 对象