Php 为条带签出创建模式成功通知

Php 为条带签出创建模式成功通知,php,jquery,stripe-payments,Php,Jquery,Stripe Payments,我正在努力使条带签出的成功比写着“感谢您的提交”的div更好一些。我期待添加一个模式,将有这个感谢你的消息。但我是PHP新手,我一直在破坏stripe标记。我不知道该怎么办。我见过使用AJAX的自定义提交按钮,但不确定是否需要。提前谢谢 这是我的HTML: <?php if (isset($_POST['cart_errors'])) : ?> <div class="thank-you"><?=$_POST['cart_errors']?></

我正在努力使条带签出的成功比写着“感谢您的提交”的
div更好一些。我期待添加一个模式,将有这个感谢你的消息。但我是PHP新手,我一直在破坏stripe标记。我不知道该怎么办。我见过使用AJAX的自定义提交按钮,但不确定是否需要。提前谢谢

这是我的HTML:

<?php if (isset($_POST['cart_errors'])) : ?>
    <div class="thank-you"><?=$_POST['cart_errors']?></div>
<?php endif // errors ?>
$cart_stripe_secret_key = get_option("cart_stripe_secret_key");
Stripe::setApiKey($cart_stripe_secret_key);

$token = $_POST['stripeToken'];

try
{
    $charge = Stripe_Charge::create(array(
    "amount" => $totalCharge*100, // amount in cents, again
    "currency" => "usd",
    "card" => $token,
    "description" => $_POST['surgecart_email']
));
}
catch(Stripe_CardError $e)
{
    $_POST['cart_errors'] = "Whoops! There was a problem with your card. Try again?";
return FALSE;
}

$_POST['cart_errors'] = "Thank you for your order!";

我强烈建议使用stripecheckout,它使用modal和ajax地址查找。要成功返回,可以使用引导模式

在成功完成事务后重定向到的任何页面中,都包含模式代码,但如果在正确的情况下回显“activate modal”js,则将自动弹出代码保留在php中。大概是这样的:

<?php
 if($stripe_response()){

  echo "<script type='text/javascript'>
          $(window).load(function(){
          $('#myModal').modal({
              show: true});
                });
         </script>"; 

}
?>

如果您想在不重新加载整个页面的情况下提交表单,则需要使用AJAX。您也可以使用PRG模式,结果将显示在模式中
<?php
 if($stripe_response()){

  echo "<script type='text/javascript'>
          $(window).load(function(){
          $('#myModal').modal({
              show: true});
                });
         </script>"; 

}
?>