• 0

Why is script running after form submission?


Question

I have a checkout form that requires an e-mail address and allows users to choose between paying with PayPal and paying with credit card (Stripe). When the user chooses Stripe, the Stripe script runs and a pop-up opens to collect cc info. However, the script also runs after the PayPal button is submitted! The PayPal button works fine when I comment out the Stripe script. How do I keep the browser from executing the Stripe script after the PayPal button is clicked?

<form action="checkout.php" method="post">

        <table width="100%"><tr><td>

        <input type="text" name="email" title="enter your email" size="25" placeholder="enter your email address"/><input name="PayPal_submit" type="Submit" value="Pay with PayPal" /></form>

        <script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button" data-key="[redacted]" data-amount="<?php echo $cost; ?>" data-description="<?php echo $desc; ?>"></script>

        </td></tr></table>
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

My guess is that the stripe javascript is attaching itself to the form submit event. If that's the case, try creating 1 form for paypal and another for stripe and see if that works.

Link to comment
Share on other sites

This topic is now closed to further replies.