我想知道在我的javascript中隐藏条纹键是否重要。
事实上,在我的Symfony网站上,我在javascript里放了一个密钥,让用户可以支付他们的订单。这就是我是怎么做到的:
</footer>
</body>
<script src="https://kit.fontawesome.com/47f28c9d14.js" crossorigin="anonymous"></script>
<script type="text/javascript">
var stripe = Stripe("pk_live_....");
var checkoutButton = document.getElementById("checkout-button");
checkoutButton.addEventListener("click", function () {
fetch("/orders/create-session/154154154", {method: "POST"})
.then(function (response) { return response.json(); })
.then(function (session) { if (session.error == 'order')
{ window.location.replace('/orders'); } else { return stripe.redirectToCheckout({sessionId: session.id}); } })
.then(function (result) { if (result.error) { alert(result.error.message); } })
.catch(function(error) { console.error("Error:", error); }); });
</script>
</html>
但如果你打开控制台,并检查源代码,你可以看到我的条纹键...
谢谢
1条答案
按热度按时间9vw9lbht1#
是的,您可以在客户端应用程序中使用Stripe“publishable”密钥。
更多信息:https://stripe.com/docs/keys?locale=en-GB