首页 > 解决方案 > 不重定向到条带结帐页面 node.js

问题描述

我有这个功能:

    app.post('/create-checkout-session', async (req, res) => {
   
    const priceId = req.body.PRICE_ID;
    console.log(priceId)

const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  payment_method_types: ['card'],
  line_items: [
    {
      price: priceId,
      // For metered billing, do not pass quantity
      quantity: 1,
    },
  ],
  // {CHECKOUT_SESSION_ID} is a string literal; do not change it!
  // the actual Session ID is returned in the query parameter when your customer
  // is redirected to the success page.
  success_url: 'http://localhost:6166/?session_id={CHECKOUT_SESSION_ID}',
  cancel_url: 'http://localhost:6166/test',
});

// Redirect to the URL returned on the Checkout Session.
// With express, you can redirect with:
//   res.redirect(303, session.url);

})

当我登录时priceId,它会记录它,所以我知道我的前端正在使用该功能,但是,它只是挂起,它不会重定向,也不会给我任何控制台错误。任何想法我做错了什么?

标签: javascriptnode.jsstripe-payments

解决方案


推荐阅读