首页 > 解决方案 > 条纹创建付款意图承诺永远不会解决

问题描述

我注册了一个 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,我的开端很糟糕。感谢您的评论和回答

谢谢

标签: reactjsnpmstripe-paymentsstrip

解决方案


如果你在没有 try/catch 的情况下运行它会发生什么?另外,如果您从该服务器尝试https://status.stripe.com/reachability会得到什么- 您确定可以访问 Stripe 的服务器吗?


推荐阅读