vue.js - VUE (Cli) 和带 Node js 的 Stripe
问题描述
VUE 中的 Stripe 存在以下问题:
(Stripe 是通过“npm Install Stripe”(stripe-node)安装的)
在我的组件中,我使用以下命令初始化 Stripe:
import Stripe from 'stripe
在方法中我有一个测试功能:
<template>
<v-btn
type="submit"
class="mt-3 success"
@click="test"
>
Test
</v-btn>
</template>
<script>
import { db } from "@/plugins/firebase"
import store from '@/store';
import Stripe from 'stripe'
export default {
name: "MMKonfiguration",
data(){
/* some other vars....*/
}
methods:{
async test(){
const stripe = new Stripe('SecretStripeKey_here')
const customer = await stripe.customers.create({
email: 'customer@example.com'
});
console.log(customer.id);
}
}
</script>
console.log(stripe)
给我一个成功的对象
然而,任何 Stripe 函数都不会被执行(在这种情况下是 stripe.customers.create),而且例如 stripe.products.retrieve 也不起作用
有谁知道任何建议?非常感谢
解决方案
该stripe-node
库是一个服务器端库,它并不打算在这样的客户端应用程序中运行。如果您在客户端应用程序中包含您的密钥,它可以被记录并且不再安全。您应该立即删除它并滚动您的密钥。
与支付详细信息收集相关的客户端方面应使用Stripe.js。您可以使用包中的loadStripe
帮助程序@stripe/stripe-js
以对模块友好的方式包含 Stripe.js。
推荐阅读
- twitter-bootstrap - tsbs/bootstrap 和模板引擎渲染的问题
- list - 如何将列表项分隔为单独的变量
- c# - 在 ASP.NET 页面上动态显示数据
- android - 房间中的总和和计数 - 别名没有这样的列
- jquery - 我在 laravel 5.3 中使用 twitter 引导程序,并且折叠功能在本地完美运行,但在实时服务器上却没有
- android - AndroidManifest 中的多个 ComponentDiscoveryService --> 合并冲突
- javascript - 在javascript中组合正则表达式
- azure - 具有持久功能的巨大 2 类队列操作计数
- c++ - 高斯模糊永远无法正常工作
- r - R中文件名列表中的矢量模式匹配和矢量替换