#craig_30132

1 messages · Page 1 of 1 (latest)

graceful swiftBOT
zinc siren
#

Looks like whatever value you're passing to initialise Stripe.js isn't a pk_live_xxx key

#

I'm guessing it's an env var, so maybe it's not defined

gleaming cosmos
#

the test keys work correctly, how can there be an issue with the live keys?

zinc siren
#

I don't think there's an issue with the live key per se. The issue is with your code

#

Can you share the code where you initialise Stripe.js?

gleaming cosmos
#

here you go

<%@ page language="VB" autoeventwireup="false" inherits="StripeRedirect, App_Web_kwv1sj1a" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript" src="https://js.stripe.com/v3/"></script>

<script type="text/javascript">
           var stripe = Stripe('<%=m_strPublishedKey %>');

    stripe.redirectToCheckout({
        // 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: '<%=m_strSessionID %>'
    }).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`.
        if (window.location.href.toLowerCase().indexOf("localhost") != -1)
            console.log(result.error.message);
        else {
            window.location.href = "bkgNoSucc.aspx";
        }
    });
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<center><img src="images/loading_small.gif" alt="Connecting to Stripe..." /></center>
</div>
</form>
</body>
</html>

zinc siren
#

I'd guess <%=m_strPublishedKey %> isn't what you think it is then

gleaming cosmos
#

what do you mean?

zinc siren
#

The error implies to me that the <%=m_strPublishedKey %> variable is unset, or is not a valid API key format

#
Uncaught IntegrationError: Please call Stripe() with your publishable key. You used an empty string.
#

Maybe just try and hardcode it to confirm my suspicion

gleaming cosmos
#

We have the same code working for another customer website, its strange it doesn't work here?

#

nevertheless I will hard code

zinc siren
gleaming cosmos
#

is this the correct format to hardcode the key

<script type="text/javascript">
var stripe = stripe('%=pk_live_51L2z0kIHKteXV2c2xzATEllo3s6ES8zhKAR4D2IfBdYkKd6rFA2CFGbFVMhv04FmclEnYqeFJSbNYUzaSvwYn9X300wJcdgDvW>');
/* var stripe = Stripe('<%=m_strPublishedKey %>'); */

zinc siren
#

Not sure why you're including a %= prefix?

gleaming cosmos
#

now I get this error

StripeRedirect.aspx:12
Uncaught TypeError: stripe is not a function
at StripeRedirect.aspx:12:26

zinc siren
#

It's uppercase:

var stripe = Stripe('pk_live_xxx')
gleaming cosmos
#

like this ?

var stripe = Stripe('pk_live_xxx')

zinc siren
#

Yep!

gleaming cosmos
#

testing again

#

getting this error now

(index):1
Uncaught IntegrationError: stripe.redirectToCheckout: You must provide one of lineItems, items, or sessionId.
at ga ((index):1:340289)
at ba ((index):1:340578)
at ka ((index):1:341486)
at Sa ((index):1:341600)
at (index):1:385216
at e.redirectToCheckout ((index):1:386887)
at StripeRedirect.aspx:15:16

zinc siren
#

Then based on your code above, <%=m_strSessionID %> is likely undefined

#

Seems like you have some kind of injection issue if all those variables are undefined

gleaming cosmos
#

ok, I'll check internally, thankyou