Issue

Since the rc3 update, stripe.js is loaded on every page of the site. Loading stripe.js can help prevent fraud, but blindly loading it everywhere can lead to a violation of the GDPR (#20) and can greatly slow down sites (#4, #13, #20). Further, Stripe itself has stated it is not necessary to load stripe.js on every page (#10).

Proposed solution (patch 21)

Only load stripe.js where it is necessary (restore the rc2 behavior). Provide documentation to enable users who wish to opt-in to load stripe.js everywhere via hook_page_attachments.

Original post

Hi, since the last module update, a stripe file is loaded on all pages of the site.

Why is js.stripe.com on all pages of the site ?

Comments

zenimagine created an issue. See original summary.

torgospizza’s picture

Because according to the documentation:

To best leverage Stripe’s advanced fraud functionality, include this script on every page of your site, not just the checkout page. This allows Stripe to detect anomalous behavior that may be indicative of fraud as customers browse your website.

bojanz’s picture

Status: Active » Fixed

Thanks, torgosPizza.

zenimagine’s picture

It's very strange. My site is getting slow since the update. I do not understand why you have to activate it all over the site, now I have to change the "General Data Protection Regulation" because of Stripe and her script. What is the script? I imagine that it follows the behavior of visitors to the site and I do not trust. Can you add a setting to enable only on the payment page. The administrator had to have a choice. It's information that I do not want to share with Stripe (it's about private life).

zenimagine’s picture

Status: Fixed » Active
bojanz’s picture

I would be happy to make this configurable if Stripe can give us an indication that this is allowed. We just followed Stripe's recommendation here.

zenimagine’s picture

Ok thanks, so maybe this problem should be a feature request.

Add an option to enable "advanced fraud functionality".

zenimagine’s picture

The number of cookies since the update is impressive.

The scripts are also loaded on all pages of the administration.

I do not know what it took them to launch such an intrusive version. Yet private life is becoming more and more regulated

zenimagine’s picture

Title: Why is js.stripe.com on all pages of the site ? » Do not run cookies and script stripe on all pages (the RC3 version now tracks all users)
Category: Support request » Task
Priority: Normal » Major
zenimagine’s picture

@bojanz Here is Stripe answer in English and French (check translation) :

Bonjour,

Merci d'avoir pris le temps de contacter le support Stripe. Je m'appelle Romain et travaille pour le support francophone, je serai ravi de vous renseigner à ce propos.

Tout d'abord, permettez-moi de m'excuser pour le temps qu'il a fallu pour répondre à votre question. Nous avons récemment reçu un grand nombre de requêtes, ce qui a retardé notre temps de réponse standard.

Bien que je n’aime pas vous rediriger, il semble ici s’agir d’un problème d'intégration sur une page qui n’a pas été créée par Stripe. En effet, nous ne sommes pas en charge de l'intégration du plugin Stripe de Drupal 8, ce choix a été mis en place par leur équipe ingénieur.

Nous recommandons de charger Stripe.js sur chaque page pour réduire la fraude sur votre site internet, cependant, ce n'est absolument pas obligatoire : https://stripe.com/docs/stripe-js/reference#including-stripejs

Pour remédier au problème au plus vite, il vous faudra donc contacter l'équipe qui a créé l'intégration de votre page de paiement.

Pour plus de contexte, nous recevons les informations de paiement, les sécurisons et assurons les transactions qui nous sont envoyées depuis leur intégration. Cependant, nous ne sommes qu'en arrière-plan de leur intégration, celle-ci est développée de leur côté et nous n'avons donc accès qu'aux informations (sécurisées) de paiements.

Pour toutes questions concernant les problèmes d’intégration de leur plugin, je vous recommande donc de contacter directement le support ingénieur de Drupal 8, qui seront plus à même de vous aider. Vous pouvez les contacter depuis le lien ci-dessous :

https://www.drupal.org/support

J'espère que ces informations vous remettront sur la bonne voie. Si vous avez d'autres questions concernant Stripe, n'hésitez surtout pas à m’en faire part.

En vous souhaitant une très bonne journée,

Bien à vous,
Romain

************************************************************************

Hello,

Thank you for taking the time to contact Stripe Support. My name is Romain and I work for French speaking support, I will be happy to inform you about this.

First, allow me to apologize for the time it took to answer your question. We have recently received a large number of requests, which has delayed our standard response time.

Although I do not like to redirect you, it seems to be an integration problem on a page that was not created by Stripe. Indeed, we are not in charge of the integration of the Stripe plugin of Drupal 8, this choice was put in place by their engineering team.

We recommend loading Stripe.js on every page to reduce fraud on your website, however, this is not mandatory at all: https://stripe.com/docs/stripe-js/reference#including-stripejs

To remedy the problem as quickly as possible, you will need to contact the team that created the integration of your payment page.

For more context, we receive the payment information, secure it and insure the transactions sent to us since their integration. However, we are only in the background of their integration, it is developed on their side and we therefore have access to information (secure) payments.

For any questions regarding the integration problems of their plugin, I recommend you to contact directly the support engineer Drupal 8, who will be more able to help you. You can contact them from the link below:

https://www.drupal.org/support

I hope this information will get you back on track. If you have any other questions about Stripe, do not hesitate to let me know.

Wishing you a very good day,

Yours truly,
Roman

zenimagine’s picture

Status: Active » Needs work
valic’s picture

Definitely stripe JS is no requirement to be running through the entire Drupal.

With plain hook_page_attachments is loaded everywhere. No role / path restrictions.

Agree with @zenimagine to be restored to previous behavior as default one. People can opt-in with their implementations of hook_page_attachments to add it to more places

ptmkenny’s picture

I also strongly agree with @zenimagine and @valic. After upgrading to the release that loads on every page load, my site now slows down significantly because of the connection to Stripe.

zenimagine’s picture

Advanced security for online payment has absolutely no interest. I suggest that you send Stripe an e-mail to express your dissatisfaction with this absurd feature. That's what I did, but putting this is optional is totally disproportionate.

In 2019 there is the DPS2 (3D secure mandatory). The fraud rate in 2018 :

In 2018, the fraud rate reached 0.173%, ie 1 euro stolen for 578 euros in payments, against 0.010% for payments in stores.

valic’s picture

Not sure that mailing Stripe would benefit to get better solution :-)

Regarding security not correct statements.

  1. 3D applies only to Europe.
  2. If someone utilizing the Stripe Radar feature, it makes sense to load on more places.

We per example use other tools, not Radar.

You can now disable loading everywhere with your page_attachment, and adding trough form alter only payment method place.

But within commerce_stripe we could have on payment method configuration checkbox to turn it on on entire site, or just to have it on where Stripe is loaded

zenimagine’s picture

So I hate to test if someone offers a patch

valic’s picture

*correction, this setting should not be in payment gateway settings, but rather on separate config storage.

Otherwise, it would be needed to load payment methods on hook_page_attachments to get if is globally enabled or not.
And we don't want that :-)

I can add a patch if we know in which directions this JS thingy is going :-D

zenimagine’s picture

zenimagine’s picture

@valic If you have a patch, I can test it. For loading stripe.js rotten the performance of my site and I'm not talking about privacy issues.

This is a major problem, all sites that use this module must update their privacy policies.

dercheffe’s picture

I agree with @zenimage too. Loading stripe.js everywhere lacks site performance and gdpr compatibility. For every business in Europe gdpr has to be an important topic by law, although it's sometimes quite annoying from developer/site builder view.
IMO it should be possible to turn this feature on or off.

Perhaps it's also possible to define the urls where stripe.js can be loaded. I imagine here a textarea where the URLs can written down, perhaps even with wildcard support (comparable with block visibility in Drupal)

For example:
if the commerce shop is reachable at mydomain.com/shop then the defined URL could be /shop/*.

valic’s picture

StatusFileSize
new1.77 KB

Here is a patch, it just re-added libraries where it was before, without any hook_page_attachments implementation.

Don't see the point on working on some heavy logic where it should be or not, just where is required.
Each site is different, with different requirements.

If someone wish to have it on the entire site, they can add simple hook_page_attachments as it were.
This is more documentation part assume. Or how-to section for users who utilize Stripe Radar

/**
 * Implements hook_page_attachments().
 */
function my_module_page_attachments(array &$page) {
  $page['#attached']['library'][] = 'commerce_stripe/stripe';
}

or the can write logic for them based on routes or paths.

/**
 * Implements hook_page_attachments().
 */
function my_module_page_attachments(array &$page) {

 // Skip admin routes.
  if (Drupal::service('router.admin_context')->isAdminRoute()) {
    return;
  } 

  $page['#attached']['library'][] = 'commerce_stripe/stripe';
}
zenimagine’s picture

@valic Thank you so much. I just tested the patch and it works for me.

I got this error during the update :

ubuntu@www-example-com /var/www/www-example-com $ drush cr
[warning] include_once(/var/www/www-example-com/web/modules/contrib/commerce_stripe/commerce_stripe.module): failed to open stream: No such file or directory Extension.php:147
[warning] include_once(): Failed opening '/var/www/www-example-com/web/modules/contrib/commerce_stripe/commerce_stripe.module' for inclusion (include_path='/var/www/www-example-com/vendor/pear/archive_tar:/var/www/www-example-com/vendor/pear/console_getopt:/var/www/www-example-com/vendor/pear/pear-core-minimal/src:/var/www/www-example-com/vendor/pear/pear_exception:.:/usr/share/php') Extension.php:147
[success] Cache rebuild complete.
ubuntu@www-example-com /var/www/www-example-com $ drush cr
[success] Cache rebuild complete.

zenimagine’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 21: 3083393-21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

ptmkenny’s picture

Status: Needs work » Needs review

Setting back to "needs review" because the tests are marked as passing.

andrewbelcher’s picture

+1 for this. I think loading on every page should be opt in, and I think it it probably quite inappropriate to ever load on admin pages except when absolutely necessary.

ptmkenny’s picture

zenimagine’s picture

Hi, where is the update of the add-on to disable these cookies and script filth ?

It's been a year that my site is rotten by this module and I have to display the banner for cookies since this update.

torgospizza’s picture

@zenimagine: Did you test the patch? Did it work for you? If so, maybe it's time to mark this patch as RTBC?

zenimagine’s picture

I am not a developer so I cannot tell if the code is correct. But yes the patch does remove pollution from the module.

It's a payment gateway, I don't want to patch my production site.

ptmkenny’s picture

I can also confirm the patch works; I've been using it in production for about a year now.

One thing still to consider is whether to add an opt-in to load on every page as per #26, but given the way the current behavior significantly slows down sites, it would be great to get this patch in and then open a separate issue for adding some UI element to load stripe.js on every page.

zenimagine’s picture

StatusFileSize
new111.68 KB

Hi, when will the module be updated to get rid of its damn cookies that have been rotting the site for over a year ?

zenimagine’s picture

Version: 8.x-1.0-rc3 » 8.x-1.0-rc4
zenimagine’s picture

Version: 8.x-1.0-rc4 » 8.x-1.x-dev
johnpitcairn’s picture

Status: Needs review » Reviewed & tested by the community

The patch works by itself (marking RTBC on that basis), but collides with other more critical patches I need to use, so I can't test for edge-effects with my install.

I agree, this is not required by Stripe, is a considerable performance regression for the vast majority of sites, and a problem for cookie compliance.

UI opt-in for V3 global script attachment could be a follow-up.

@zenimagine, try something like this in a module or theme, it's what I'm using:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function MYMODULE_form_commerce_checkout_flow_alter(&$form, \Drupal\Core\form\FormStateInterface $form_state, $form_id) {
  // Attach the Stripe javascript only in checkout.
  // @see https://www.drupal.org/project/commerce_stripe/issues/3083393
  $form['#attached']['library'][] = 'commerce_stripe/stripe';
}

/**
 * Implements hook_page_attachments_alter().
 */
function MYMODULE_page_attachments_alter(array &$attachments) {
  // Remove the global Stripe javascript.
  // @see https://www.drupal.org/project/commerce_stripe/issues/3083393
  $libraries = &$attachments['#attached']['library'];
  if (($key = array_search('commerce_stripe/stripe', $libraries)) !== false) {
    unset($libraries[$key]);
  }
}
zenimagine’s picture

This very serious problem has not been resolved for almost 2 years. It is a shame for this module that I will be leaving for a payment gateway that is more respectful of my customers. The developers of this module should have welcomed having integrated these optional cokies (confirmed by the Stripe team). This is going to meet the GDPR and the privacy of its users. It's okay I'm leaving this crappy module.

The performances are absolutely abysmal. Why it takes a few minutes to rot this module and years to correct this problem which should be THE priority. Really I don't understand. Bye Bye Stripe for Drupal.

"Development version: 8.x-1.x-dev updated 30 Mar 2021 at 16:41 UTC" No effort for this SERIOUS problem. It's pitiful

zenimagine’s picture

Title: Do not run cookies and script stripe on all pages (the RC3 version now tracks all users) » Do not run cookies and script stripe on all pages (WAKE UP)
Priority: Major » Critical
johnpitcairn’s picture

Title: Do not run cookies and script stripe on all pages (WAKE UP) » Limit Stripe scripts and cookies to pages where they are required
Priority: Critical » Major

Wow. @zenimagine, I hear your frustration. I only just discovered the problem during our pre-launch testing, and I did offer you a solution that works without patching on production and is pretty straightforward to implement.

I think this module does have an issue with maintainership, nothing is getting committed in any reasonable timeframe, and maybe the maintainers need to coordinate better and offer a roadmap. If our charity continues to use Commerce Stripe (not at all guaranteed at present), I'll try to help move that along. Note I am not a maintainer.

zenimagine’s picture

@John Pitcairn This comment does not concern you. It concerns the team of this module, I contacted, a year ago, the Stripe team to ask them if cookies were required. He replied NO. What do the equis of this module do to correct this problem ??? It is incomprehensible. We are born in 2021 the cooies is the evil soutour in europe. We have to redo the very outrageous sRGPS because of the developers' choice. WHY ARE THERE NO UPDATES ??? Yes I am pissed off by this module, yes I am going to be fed up.

zenimagine’s picture

This module is a real crap. Sorry, there are no other words to describe the little respect developers have for their users. I contacted Stripe almost 2 years ago and I will give you the answer. Cookies are OPTIONAL, why are they embedded. Result, shitty performance, GDPR to redo, website that does not inspire confidence. Thanks to the Drupal Stripe module. Plenty of updates, but no solution. I launched a web agency with 50 clients, I devote 10% of my turnover to opensouce programs, Too bad you don't deserve this budget.

the wheel sheet: privacy first, mobile first, ...

johnpitcairn’s picture

I hear you. Your frustration is valid, but your outrage is not. Presumably you are charging your clients, and benefiting from the non-profit open-source work that has been done? One solution, assuming you do not want to learn how to develop and support this module, would be to help fund development of the fixes and features you want for this module. You can pass the cost on to your clients.

The module isn't crap. But it is an API module dealing with a 3rd-party service, so there is an ongoing maintenance burden that has been imposed by Stripe itself - the Stripe API continues to change, things like GDPR and 3DS authorization happen, and suddenly everyone using the module expects somebody else to contribute effort for free to support those changes - all so you can continue to profit?

Again, I hear you, but you need to dial back the outrage and consider what your actual contribution here is. The patch at #21 intially failed because no module tests were passing anyway. You marked that patch RTBC, so you obviously consider yourself able to test in some way. After that, it was marked "needs work" because tests failed, then "needs review" because tests were passing again, but you didn't bother to re-test, and nobody else marked it RTBC, so why would you expect anyone to commit the patch?

  • jsacksick committed 249a446 on 8.x-1.x authored by valic
    Issue #3083393 by valic, John Pitcairn, torgosPizza: Limit Stripe...
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

@valic: Thanks for the patch, committed!
@John Pitcairn: Thank you for your help with testing, and also really appreciate you stepping up!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

newaytech’s picture

StatusFileSize
new34.46 KB

Just a quick note here in case anybody comes across a similar issue. I have a Payment method of Credit card (Stripe) - that is only displayed on certain conditions. One of these is postcode (we only ship and take credit card payment to local customers). When the page first loads without Stripe being used - the stripe JS library is not added - as the payment method is not present. If the postcode is then updated - and the payment methods updated via AJAX - we get a "Stripe is not defined".

I guess this is perhaps a timing issue - but I'm going to revert to using a conditional library include as per the comment #35 - so the stripe library is always available through checkout - despite some customers not actually needing it...

https://www.drupal.org/files/issues/2022-01-25/stripe_error.PNG

This whole change came about after having to put the contact, shipping and payment info blocks all within the same Order info pane - leaving space to put the "stripe review" on its own with the review block under the review pane - this then allows us to process 2FA overlays successfully.

johnpitcairn’s picture

If the Stripe library is being added by the ajax call, then this core bug could be the problem: #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS.

If it's not being added by the ajax call, it should be.