Closed (outdated)
Project:
Commerce Stripe
Version:
7.x-3.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
7 Apr 2016 at 11:44 UTC
Updated:
18 Aug 2025 at 18:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sdnvarmachintala commentedComment #3
torgospizzaThis means that, for some reason, your Stripe token is not being added to the DOM from your commerce_stripe.js file. Can you verify that a token is being returned, or is there some kind of error happening that is preventing a token value being returned and added to our runtime Javascript variables?
Comment #4
torgospizzaCan you try the latest dev and let me know if this problem persists?
Comment #5
dylf commentedThis appears to be fixed in the dev version.
Comment #6
torgospizzaGreat to hear!
Comment #7
dylf commentedScratch that tried it on my dev server and I'm still getting this error.
Comment #8
torgospizzaD'oh!
Do you have some step-by-step instructions to reproduce it? I'll try to do so myself, but as of right now, it seems to be an intermittent issue which makes it harder to troubleshoot.
Comment #9
fbailey commentedI'm working on the same project as dylanf, as it turns out it was an issue on our side. There was a form_alter hook that set the #access attribute to false, for the payment method element. So, the commerce_stripe.js couldn't find the payment method checkbox and never generated the token. Thanks again for the assistance!
Comment #10
torgospizzaGlad to hear you got it sorted. We use essentially the same code in our production environment so if this were a true problem I'm sure we would know by now :)
I'll keep this Postponed in case others such as the OP run into similar trouble and we can verify that it is a problem with the module itself.
Comment #11
nblandon commentedHello,
I am having this issue with my site at checkout after the clients put their card information. I tried putting all the info, generated a new API token from Stripe and nothing I keep getting "You have passed a blank string for 'card'. You should remove the 'card' parameter from your request or supply a non-blank value."
The last payment i received was yesterday and today 7 people tried making a payment and all of the payments were decline.
please help me fix this. the website is www.thetornadoopen.com
thank you for your assistance
Comment #12
torgospizza@nblandon: I checked out the site, and it looks like you're running WordPress, so I'm afraid we may not be of much help since this is an issue queue for the Commerce Stripe module in Drupal.
I can tell you that jQuery Payment threw an error "Cannot read property 'split' of undefined" when I attempted to enter a test card value. It also looks like you're loading stripe.js over a non-https socket which could potentially cause trouble. I'd start looking there, as Javascript errors in the rest of the stack can cause Stripe's scripts to not execute properly.
Comment #13
drupal_simply_amazing commentedGot same issue here. I try to use commerce stripe on commerce single page checkout and then I got this issue. This module is working on other payment gateway but having an issue on commerce stripe. I put my files here http://www.filedropper.com/spctest. The db is located on private folder or you can install the drupal first then restore the db using backup and migrate later.
Comment #14
drupal_simply_amazing commentedIts been fixed on my end. The problem is the commerce single page module change the id's of the checkout form. So the commerce stripe js cant find the right target.
Comment #15
somatics commentedWe are getting this error as well, rendering us unable to take payments from our customers. We don't have the Commerce Single Page module installed. We are not showing any JS errors in the console on Chrome developer tools.
Does anyone have an idea about what else might be making this happen other than the Single Page checkout? We're pretty much on hold as a retail site until we can get this solved.
Comment #16
torgospizza@somatics: What version of the module are you using? (And would you mind giving -dev a try?)
Comment #17
somatics commentedI'm using 7.x-1.2.
No, I don't mind trying Dev. Should I just take the current one from the project page?
Comment #18
torgospizzaYeah, give the current dev release a shot. I'm fairly certain this is fixed there, but if not, I'd love to get to work on a fix. I also hope to have a new dev version ready soon and can work that fix into it if need be.
Comment #19
Ivo.Radulovski commentedHi, I have the same issue with stable and dev 7.x-1.x:
tried latest stable and latest dev / tried stripe 1.17.1 and 1.18.0 -> same result.
any ideas? Here is the URL where it is happening: https://www.generation-yes.de/philips-pastamaker-mit-gratis-keksformen-u... --> press the big red button to get to the checkout form (Stripe is currently in test mode)
Comment #20
Ivo.Radulovski commentedNow tried also dev 7.x-2.x
Comment #21
Ivo.Radulovski commentedComment #22
torgospizza@Ivo: Taking a look at your site, it looks like you're using Shopify, not Drupal Commerce.
Also, when I visit the URL https://www.generation-yes.de/philips-pastamaker-mit-gratis-keksformen-u..., I get a 404 Not Found.
If you are actually using Commerce let us know and we'll try to help.
Comment #23
Ivo.Radulovski commentedhi, yes the owner switched to Shopify because they needed a fast solution to manage credit card payments...
Comment #24
Ivo.Radulovski commentedI could still activate the site on an other URL for debugging...
Comment #25
torgospizzaI'm unable to reproduce this so I'll set it as Postponed for now. Please re-open if you're able to consistently reproduce this. You might also try the latest 3.x-dev.
Comment #26
torgospizzaI'm now able to reproduce this; working on a fix.
Comment #27
torgospizzaThe issue seems to stem from the Stripe createToken handler not firing from commerce_stripe.js. In my local copy I had used
typeofincorrectly. The module currently checks for a NULL value, but I'm fairly certain that undefined and NULL are two different things in Javascript. (I recall some discussions on this matter, and there is a debate out there on how to best handle checking for NULL values.)Here is a patch which checks for a typeof 'undefined' variable that should solve this. Please give it a try.
Comment #29
torgospizzaAfter thinking about this more, I feel like this approach is the correct way to resolve this - therefore, I'm going to commit this to 3.x-dev and mark as Fixed.
If folks still receive this error after updating to the latest dev, please reopen this issue and I will reinvestigate.
Comment #31
lionguard commentedI just received this error on the newest 3.x-dev of the module -
Comment #32
torgospizza@lionguard: Can you tell me more about your setup?
- What API version are you using?
- Where in the Checkout process is your payment pane?
- Are you using a single page checkout or multistep?
- Does this happen with a new card number, a Card on File, etc.?
Are you getting any errors in your browser's console log? Please post any stemming from Commerce Stripe here, if you can.
Thanks!
Comment #33
lionguard commentedSure:
Stripe API Version: 3.23.0
Payment pane is final step of a multistep checkout
It happens with a new card number. Looking through order payment logs, appears to be happening on 100% of new orders - retrying results in success. Hence every order now has 1 failed transaction with that message, as well as 1 successful transaction immediately afterwards.
Not in front of my main computer now but can get you console log feedback tomorrow!
Thanks!
Comment #34
torgospizzaThanks, I appreciate the extra info.
Also, is this a live production site? If possible, would you be able to send me a URL? You can send it via the contact/email form if you prefer not to give it out. Since I can't reproduce this with my own site having a test case I can look at would be super handy :)
EDIT: Also, please verify you have cleared your caches, too, after updating to the latest dev. Since commerce_stripe.js has been updated, if you have any places where your JS files are being cached (or served via a CDN), be sure to clear that cached data. Otherwise it's possible your users are being served the old version of the file which was not using a correct checkfor
settings.stripe.fetched.Comment #35
lionguard commentedNo JS console log output unfortunately!
Will send you the details of the site to your contact form- while I have been clearing caches, one to note is I do have advagg installed - I did just try disabling though and ran through a test transaction and got the same issue so looks like that its not the cause...
Comment #36
torgospizzaThat was really helpful, thanks. As mentioned in my email reply I was able to reproduce it the first time but not subsequent times, which makes me think it's highly likely a combination of caching and the settings we're using to attach the JS - that is, we're using the default settings, which include preprocessing of the file (which is not ideal since this is not JS we want included on every page).
The attached patch sets
'defer' => TRUE, 'cache' => FALSE, 'preprocess' => FALSEin our $form['attached']['js'] array for the payment form (and the admin form). Please give it a shot, I have a feeling this will probably help. (And knowing what I know now about the Form API we probably should have been using these settings all along.)(Be sure to clear your css-js cache after applying the patch!)
Comment #37
torgospizzaComment #38
jamescook commentedusing 7.x-3.0-alpha1, applied patch at #36 but still getting the behaviour mentioned above.
* drush cc all
* service memcached restart
* The error "only" appears "the first time around" - i.e. if I click "Continue to next step" in the form with the error message the transaction continues and the Stripe "Checkout" is displayed as expected.
* I'm not entirely sure but I didn't get this error when using the test keys for stripe - error only appeared when I switched to live keys.
__
FYI - I'm using PaypalWPS and Prepaid and SOFORT Banking as alternative payment methods on this page - these methods have all been working for a year or more.
I am now trying to ADD stripe payments as an option.
Comment #39
jamescook commentedThis could be to do with setting "SOFORT Banking" to present itself as the default payment method...
Comment #40
torgospizza@jamescook: Thanks for the report. Do you get any JS errors in your browser's console? If so, can you paste them here?
Are you running any advanced JS aggregation modules (AdvAgg, etc.)? If so please let me know which ones and what the settings are.
I'm assuming your Payment pane is in the Review pane of Checkout, is that correct?
Also: you mentioned you were using Stripe Checkout. Is that what you're saying, that you're using the Checkout integration as opposed to Stripe JS?
Any more information you can provide about your setup - especially surrounding things that alter the default Javascript behaviors - would be super helpful.
I hadn't tested what happens with another payment method set as the default (or, top of the list of payment methods?) but I can give that a shot to see if that's a factor.
Comment #41
jamescook commentedNo time to debug today.
Working from memory.
1. no console messages last night
2. No advanced AdvAgg - but, heads up, I do load some js file into EVERY page rather than on the pages that need the js (this is because of jquery mobile transitioning pages without really "changing" pages). I did this also at least a year ago - and all other payment methods are still working fine...
3. Yes, using Stripe Checkout - the "checkout" option in the config.
4. I tried unsetting SOFORT Banking as the default - this appeared to do "something" - but in the end this seems to have been an illusion - closing down the browser (chrome) and retrying gave the old error again.
5. Unable to go live with Stripe - which is a shame.
6. yes it is the "/review" page
Looking at 2 above - for my setup it may be worth ensuring the "Stripe* js is loaded into EVERY page.
I'll check that in the next days.
Comment #42
torgospizzaThanks for the additional information! Please don't modify your "every JS on every page" settings just yet- it'd be better for us to isolate the problem and fix it in Commerce Stripe so that it helps you as well as others.
I'll dig in a bit more. Is this a site that's accessible over the web right now? If so, I'd love to know the URL - if possible, can you set it up as a testing site so that I can take a look myself? Since I can't reproduce this in my own setup right now, having a test case to play with will be hugely beneficial. If this is a local site, have you tested it on a live "sandbox" server on the web? I'm interested if it would behave differently there.
What are you using to alter where JS files are loaded? Is it a module?
Any additional information about your configuration will help me narrow down the cause.
Thanks!
Erik
Comment #43
jamescook commentedI've PMed a link to you.
As for the js loading - it was a long time ago and I have poor memory. (My code IS my memory :) ).
Not a module, some quick and dirty code of my own(!).
Basically I try to load all js on all pages so that it's there whether or not you only load in part of the DOM for a "page transition".
It's not always perfect but mostly it "works".
Also using #2373361 to provide icons.
Comment #44
jamescook commentedEverything does work with
7.x-3.x-dev
I was using the standard non-dev release... oops...
Thanks to torgospizza for his patience and help
Comment #45
torgospizzaGlad to hear it's working for you! Can you tell me if the above patch(es) showed any improvement? I still think the additions in that patch will be helpful for others in similar setups, since we can't always know what type of JS preprocessing or aggregation is happening on a site.
Thanks, and I'm happy to be of assistance.
Comment #46
jamescook commentedActually, sadly, it was a false positive;(
I didn't have time to check this over xmas, and it's hard to check because once it works, it works as you mentioned.
My hunch is the Submit button is not being overridden correctly for whatever reason the first time "Credit Card (Stripe)" is selected as the payment method. AFAICT the js is being loaded in dynamically correctly but maybe not "applied". AFAI understand the submit action should go to stripe and get a token. This is not taking place.
Will try to get some time over the weekend to look at this.
Comment #47
jamescook commentedFWIW this is what I've found so far:
When the credit card stripe option is selected initially - Drupal.behaviors.stripe.attach is not being called.
You basically only get (call stack):
The next time the page appears and you click on the option you correctly get:(hand copied):
So when the new settings are fetched via json 1st time around they are not being applied/attached...
The new correct behaviour for Stripe is not being added...
JSON does appear to be fetched "correctly" but not applied.
Perhaps cached or possible that setting of new settings from JSON not called or called after page is re-rendered... (just ideas...)
Probably unrelated but:
Line 191 in commerce_stripe.js
I wonder if tihs is right. page-admin... doesn't this mean you have to be logged in as admin or something?
Comment #48
jamescook commentedIt seems that commerce_stripe.js is not being loaded first time round which is why the behavior is not being attached.
I saw the issue at https://www.drupal.org/node/2832319 and wonder if that's the problem we're having.
Specifically in https://www.drupal.org/node/2832319#comment-11808755:
You say jquery > 1.7 should be used
Is 1.7.1 enough?...
Comment #49
jamescook commentedWell, I tried 1.8 via jquery_update but this didn't change the situation...
Comment #50
torgospizzaHi there,
I just tested on your site and it worked for me the first time. What browser are you using? I know Google Chrome has a tendency to cache things pretty severely. You might test using a different browser and/or user.
If you look at your order history you should see my test order in the Payment status. I haven't been to the site in some time but I was able to test with a test card (and get the error "Your card was declined. Your request was in live mode, but used a known test card") - which means at least that a token was created and submitted to Stripe. I didn't have to click on "Credit Card" since it was already selected. I entered the 4242 test card details, and then hit Submit.
At the moment I can't seem to reproduce the error, but if you're able to find 100% reproducible steps to get the error to appear every time, that would be exactly what we need to get this fixed.
No, the body class is generated by the path in this particular identifier. The page is /admin/commerce/order/[#id]/payment so it follows that one body class is .page-admin-commerce-order-payment.
In your browser console you can do a
console.log(Drupal.settings.stripe);to make sure that the script is has been loaded and fired. It should havefetched: trueas well as your live key and integration type. If you don't see all of those details then that means the JS is not being loaded in the first place. You could add a call toconsole.log('Stripe behavior attached');into commerce_stripe.js file when the JS is fired, just to check while we're debugging this.Which is what my patch in #36 was attempting to solve, by deferring it until after the page load event. After you updated to the latest 3.x-dev did you apply that patch? If not, give it a shot and see if it makes a difference.
And again, if there is a way for us to get steps to reproduce this error every time, paste them here. I can't seem to reproduce it on your site at this point.
Comment #51
jamescook commentedHallo torgospizza
Thanks for your continued help - email and tests.
I'm actually testing on another machine non-production machine which is reset every few hours to the current production state.
This means e.g. that jquery etc is reset from 1.8 to 1.7...
Production has the "old" state with jquery 1.7 etc. and "doesn't" work (I just did a complete "reload" with IE and again I get the "blank" error).
I'm not sure why the production machine seems to have worked in your case. Maybe commerce_stripe.js was somehow still in your browser cache...
The way I reproduce the error here is to:
This leads to the "blank" error.
When I check the network activity I can see that the json for the settings is being fetched, but no such fetch occurs for commerce_stripe.js. The script is also not shown in "Debugger/Sources" (Firefox debugger).
Comment #52
jamescook commented... back on the PROD machine (after some tests)
This workaround looks promising even if ugly:
I added these lines to template.php:
And modified the code of commerce_stripe.js:
This seems to work everytime...
(I left jquery at 1.7 because I'm not sure what else relies on this version (jquery mobile 1.3.2 perhaps)...)
Comment #55
graber commentedIn my case this was caused by the following line of code in commerce_stripe.js:
if ($("input[value*='commerce_stripe|']").is(':checked')) {The cause was that there was only one payment method and therefore the checkbox has been removed.
Hopefully this will help someone, proposed solution included - checking if the method selector is there.
Comment #56
rgnyldz commentedHi, I tried everything above with no luck. Still getting the
You have passed a blank string for 'card'error.I'm using Commerce Checkout AJAX Pages module to show the checkout process in a block via ajax. But it's also not working if I go to /checkout page manually and do the regular multistep checkout.
I'm using a Turkish master card, don't know if relative.
I also tried to disable all other payment methods but no luck. Always the same error message.
EDIT: It seems that the checkout ajax module uses ajax on the multistep also. So when I disable the ajax module everything works fine.
Now have to find a way to make it work via ajax because all of aour design is based on ajax checkout systems with animations.
Comment #57
tomtech commentedAutomatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.