问题描述
我想使用 Stripe 支付,但在服务器端发现一些问题来检查支付是否成功。
我使用 nodejs 与 vue 集成,我的 nodejs 代码如下所示:
app.post("/create-checkout-session",async (req,res) => {
const {
amount,product,currency
} = req.body;
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],line_items: [
{
price_data: {
currency: currency,product_data: {
name: product,},unit_amount: amount,quantity: 1,],mode: "payment",success_url: "http://localhost:3000/successpayment",cancel_url: "http://localhost:3000/cancel",});
res.json({ id: session.id });
});
有没有办法在服务器端检查支付是否成功?在这里检查是否安全,或者一旦用户到达成功页面我就触发了数据库?