javascript - 调用 Stripe API 但没有采取任何行动
问题描述
我有一个问题stripe.customers.create
。我的意图是使用 currentUser 的电子邮件地址创建一个 Stripe 客户,然后使用返回的customer.id
.
stripe.customers.create
返回一个承诺,但在then
orcatch
语句中没有触发任何内容。没有创建 Stripe 客户,看起来 Stripe API 调用甚至没有发送到 Stripe。
stripe.customers.create({
email: state.getters.currentUser.email
})
.then(customer => {
console.log("promise resolved");
console.log(`customer.id: ${customer.id}`);
if (customer.email === state.getters.currentUser.email) {
state.dispatch("updateUserProperty", {
customerId: customer.id
});
}
})
.catch(err => {
console.log("promise error");
console.error(err);
});
我也尝试过这种语法,但没有运气:
async () => {
const params: Stripe.CustomerCreateParams = {
email: state.getters.currentUser.email
};
const customer: Stripe.Customer = await stripe.customers.create(params);
console.log(customer.id);
};
我正在使用https://github.com/stripe/stripe-node并且没有抛出错误或警告。state.getters.currentUser.email
确实有想要的价值。
我在这里想念什么?谢谢您的帮助。
解决方案
该库必须在节点环境中使用,vue 或客户端不能使用该库
推荐阅读
- python - 无法在 ipython 项目上使用 matplotlib.pyplot 显示图像
- image-processing - Three.js 中的 Inter_area 纹理 minFilter 是否像 opencv 中一样?
- java - java - 如何使用Java Swing手动控制哪个线程进入临界区?
- javascript - 对如何标记此内容感到困惑
- android - Android 清除 Back Stack 上的一些 Activity
- php - PHP月年日选择下拉列表在中间件laravel中生成日期格式
- python - 熊猫数据框添加数据框python
- android - 是否必须在 android 的主线程之外的房间中编写查询?
- python - 我想根据用户输入更新海龟
- android - 按下时升级到 dart 2.2.1 在图标按钮和凸起按钮中不起作用