reactjs - 条纹创建付款意图承诺永远不会解决
问题描述
我注册了一个 Stripe 帐户,并按照一些简单的步骤来启动和运行 Node.js。我刚刚安装了软件包并使用我的测试密钥测试了支付意图:
const Stripe = require('stripe');
const handleStripe = async () => {
const stripe = Stripe(testKeyString);
console.log(“we make it here”);
try {
const paymentIntent = await stripe.paymentIntents.create({
amount: 1000,
currency: 'usd',
payment_method_types: ['card'],
receipt_email: 'jenny.rosen@example.com',
});
//we never make it here
console.log(paymentIntent);
}
catch(err){
//we never make it here either
console.log(err);
}
}
控制台记录“我们在这里成功”,但没有别的。承诺永远不会得到解决。
我怀疑这可能是条带 npm 包的错误。有人对为什么永远不会返回承诺有任何想法吗?
编辑:对不起,我在这里浪费了大家的时间。我正在关注文档 QuickStart,上面写着“安装客户端库”,我认为它是针对前端的。所以我认为这是一个非常愚蠢的错误,认为使用密钥从前端进行支付意图是一个好主意。刚开始使用 Stripe API,我的开端很糟糕。感谢您的评论和回答
谢谢
解决方案
如果你在没有 try/catch 的情况下运行它会发生什么?另外,如果您从该服务器尝试https://status.stripe.com/reachability会得到什么- 您确定可以访问 Stripe 的服务器吗?
推荐阅读
- json - pyspark:执行collect_list()时如何从列值中删除转义字符?
- excel - 在与活动表不同的工作簿中调用工作表:错误
- cocos2d-x - 游戏运行时闪退
- linux - Sed将绝对链接转换为markdown文件中的相对链接
- python - 多索引数据帧中数据的年份总和
- gnome - 从模式窗口访问密码管理器
- javascript - 用户单击通知时在同一窗口中打开页面
- r - 使用“method=circle”时,corrplot 不能与 ggplotly 一起正常工作
- java - Cucumber:许多功能的背景相同
- node.js - 无法将文件上传到私有 aws S3 存储桶