Stripe Checkout 付款成功后不执行附加功能

问题描述 投票:0回答:0

我正在尝试在使用我的条纹帐户成功付款后执行其他功能,但它在这里不起作用是代码

我没有收到警报消息,它只是在完成后重定向到 successURL

这是我的js代码

var stripe = Stripe(
  "pk_test_51Mh3laDjXZ0tQLnuuSyCeBbnlZZyLCcnE2egXZigkcoirfwsBX97MkubHfX0s9SJEekZH5C5oW05eouKFLyFpMQT0004cI7ArY"
);

document.getElementById("checkout").addEventListener("click", function() {
  stripe.redirectToCheckout({
    lineItems: [
      {
        price: "price_1Mh6d4DjXZ0tQLnurDuvk36i",
        quantity: 1
      }
    ],
    mode: "payment",
    successUrl: "http://127.0.0.1:5500/public/payment.html",
    cancelUrl: "http://127.0.0.1:5500/cancel"
  }).then(function(result) {
    // Handle any errors during checkout
    if (result.error) {
      console.log(result.error.message);
    } else {
      console.log("Payment succeeded");
      myCustomFunction();
    }
  });
});

// Define your custom function here
function myCustomFunction() {
  console.log("Payment successful!");
  alert("Payment successful!");
}
javascript stripe-payments payment gateway
© www.soinside.com 2019 - 2024. All rights reserved.