Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Sean Voss

    (@seanvoss)

    Hey Andy,

    Obvious question, does your key contain whitespace? Is there by-chance a space character on either end of your test key?

    That being said I’ll make a build tomorrow for you that contains a whitespace stripping function from the front and the end of your keys, perhaps that will help if you aren’t able to figure it out on your own.

    Stay tuned, Cheers.

    Sean

    Thread Starter AndyMacKay

    (@andymackay)

    Hi Sean,

    I dug into the code a little. My rendered checkout page looks like this

    <div id=”stripe_pub_key” class=”hidden” style=”display:none” data-publishablekey=”<?=$this->publishable_key ?>”> </div>

    Which would explain why the Stripe.setPublishableKey function is getting an invalid value.

    Don’t know if it’s something weird with my page or with this build of the plugin but will let you know if I get any further.

    Thanks for your quick response

    Thread Starter AndyMacKay

    (@andymackay)

    So I can see $this->publishable_key should be returning a value from the woocommerce_Striper_settings table dependant on whether it is test mode or not.

    Managed to tweak line 10 of payment.php to read, this seems to have fixed my issue.

    <?php echo $this->publishable_key; ?>

    Thanks for your hard work in building this plugin.

    Plugin Author Sean Voss

    (@seanvoss)

    Hey Andy,

    So <?= I always thought was just shorthand for the printing the output.

    I’m making the change you mention but I’m curious if you understand why that fixed your problem?

    Cheers,

    Sean

    Thread Starter AndyMacKay

    (@andymackay)

    Hi Sean,

    I’ve never seen that syntax before, so just thought it was error. With the version of PHP I am using, it simple rendered into the html as a string data=”<?= this should have been the value” and hence the javascript did not work.

    Cheers

    Andy

    binaryitsystems

    (@binaryitsystems)

    I have the same issue. I think it has to do with a strict mode in PHP, at any rate, changing it from shorthand to <?php echo … ?> resolved that particular error for me – since you can’t know for sure if user’s php installs support/allow shorthand, should probably do it the slightly longer way.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Your key is invalid because it contains whitespace.’ is closed to new replies.