Redirecting to Stripe

Im not sure if someone can assist here. I am following a basic example at

I have created the HTML and added the code as below including the Javascript as required

<!DOCTYPE html>
<script src=""></script>
<html xmlns="">
<head runat="server">

    <form id="form1" runat="server">
        <button onclick="checkout()">Check Out</button>

<script type="text/javascript">
    function checkout() {
        var stripe = Stripe('pk_test_KEY');
            // Make the id field from the Checkout Session creation API response
            // available to this file, so you can provide it as parameter here
            // instead of the {{CHECKOUT_SESSION_ID}} placeholder.
            sessionId: '123456789'
        }).then(function (result) {
            // If `redirectToCheckout` fails due to a browser or network
            // error, display the localized error message to your customer
            // using `result.error.message`.

When i click the button it doesnt redirect to the payment gateway page. What am i missing?

Your JS should be placed before the closing </body> tag. That might help.

I tried but it didnt make a difference

So… okay…when you did Step 1 in that page you linked, did it actually spit back ‘123456789’? Cause… i’m guessing it didnt. Or are you obfuscating that from us here?

And also the pk_test_KEY… you’re replacing that with pk_test_whateveryouusedinstep1 , right?

Yes - but it seems our IT were blocking some scripts from executing on the browser. So its now sorted. Thanks for your help guys.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.