Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It looks like Stripe.js is not being loaded from https://js.stripe.com. Stripe does not support serving Stripe.js from your own domain. mrgalaxy_stripe.js: 35 #25

Closed
stephentcannon opened this issue Jan 28, 2015 · 21 comments

Comments

@stephentcannon
Copy link

Error in console after upgrading package to latest.

Was working prior.

@chadokruse
Copy link

Just noticed this myself after upgrading a few minutes ago. The good news is it looks harmless:
https://botbot.me/freenode/stripe/2015-01-15/?page=1

As you probably are aware, this package downloads a direct copy of Stripe.js (https://js.stripe.com/v2/)...which apparently now conflicts with Stripe requirements. I recall seeing another Meteor package that just wrapped Stripe for Node.js, pulling the others from Stripe's servers. That's the path I'll likely go down, but interested in your thoughts @tyler-johnson.

@tyler-johnson
Copy link
Owner

Yes, I did notice a stripe.com reference when I was upgrading it yesterday. I wondered if they were now whitelisting which domains it works with. I guess since it only console.warn the message it is not actually stopping you from using it, however it is still annoying.

I will look into a workaround, possibly by going to Stripe directly. I'll have to check on how Meteor suggests doing that. In the meantime are there any other suggestions on how to fix this?

@chadokruse
Copy link

In the past I've used two different approaches, both with their pros and cons (there may be newer, less hacky approaches but I haven't looked in awhile).

  1. Wait-on-Lib package - requires iron-router
  2. Insert the script using the rendered callback - feels hacky. I do this to load Coinbase's button.js:
Template.altPaymentsCoinbase.rendered = function() {
  //Define where to insert the script
  var insertID = document.getElementById('js-coinbase');
  //Define the script itself
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.async = true; //Unsure if this is supported
  script.src = 'https://coinbase.com/assets/button.js';
  //Generate the script
  insertID.appendChild(script);
};

@tyler-johnson
Copy link
Owner

What about something like this answer on SO? http://stackoverflow.com/a/17506335

It seems simple enough to include an HTML file which references the Stripe script on their servers.

@chadokruse
Copy link

You know, that's definitely the simplest approach. The main value of this package imho (thank you btw!) is having Stripe for Node.js wrapped in a Meteor package. If the user doesn't mind having the Stripe scripts downloaded on all pages/routes, they can just include in head per the SO approach. If they want to limit it to specific pages/routes (my use case), they can use any one of the alternatives.

I may have time for a PR later this week to add the per-page options if you'd find it useful.

@choyweston
Copy link

+1 Thanks for looking into this. Does the NPM package have the same error?

@guilhermedecampo
Copy link

1+ =)

@tyler-johnson
Copy link
Owner

Okay this has been fixed with 26064fd. I considered this to be a "breaking change" so I've bumped the version to 2.0.0. Please let me know if anything is broken. :)

Thanks everyone!

@choyweston
Copy link

Awesome! Thanks!

@flean
Copy link

flean commented Feb 6, 2015

@tyler-johnson I'm still getting the error, besides updating do I have to do anything else?

@tyler-johnson
Copy link
Owner

You shouldn't need to. I recommend looking at the HTML source returned from the server. It should have a <script type="text/javascript" src="//js.stripe.com/v2/"></script> at the bottom of <head>.

Otherwise you might be loading off an old version? Or perhaps another package is doing something with the content?

@flean
Copy link

flean commented Feb 6, 2015

@tyler-johnson I did find that but the warning is still there, what I'm noticing is that it appears after <meta name="fragment" content="!"> not sure if that causes an issue. I use manuelschoebel:ms-seo for meta tags.

@dan335
Copy link

dan335 commented Feb 7, 2015

I'm still seeing the error after upgrading to 2.0.0. <script type="text/javascript" src="//js.stripe.com/v2/"></script> is in the

@molleman
Copy link

molleman commented Feb 8, 2015

I'm still seeing the error also and i just installed

@flean
Copy link

flean commented Feb 10, 2015

@tyler-johnson Any news on this issue? I see that I'm not the only one. Thanks

@tyler-johnson
Copy link
Owner

No news yet, but I'm going to reopen while I investigate.

@tyler-johnson tyler-johnson reopened this Feb 10, 2015
@dearlordylord
Copy link

To clarify things: I have <script type="text/javascript" src="//js.stripe.com/v2/"></script> in but this message still appear.

@justindra
Copy link

Hi,

I'm still getting the warning and also now receiving this error:

Uncaught ReferenceError: Stripe is not defined

And I do have the script loaded in the html

<script type="text/javascript" src="//js.stripe.com/v2/"></script>

@tyler-johnson
Copy link
Owner

Alright just pushed version 2.1.0. Please try to update and see if you are still having issues.

I'm still getting the error

Okay, so it seems that Stripe.js wants to be loaded directly from https not from http. So when trying to load the insecure version, Stripe sends a redirect, but that tricked the script into thinking it wasn't loaded there. Sort of odd, but I fixed it by forcing the https version in the script tag.

also now receiving this error:
Uncaught ReferenceError: Stripe is not defined

Stripe.js is now loaded after all other Meteor scripts, which means it isn't available immediately anymore. Instead, you'll have to wait till after the app has started before using the variable. I modified the Usage section in the read me to detail this.

Also, to keep everything consistent, I have moved Stripe Checkout to script tag in the <head> like Stripe.js. This means that it isn't available till startup either.

@justindra
Copy link

That worked awesomely! Thanks!

@lferro9000
Copy link

The error also happens with v3 when you don't pass the public token as instructed.

(for future reference)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests