Add option to disable loading stripe.js for anonymous users

Created on 17 October 2019, almost 6 years ago
Updated 18 August 2025, about 1 month ago

If someone wants to use stripe only for registered users, it would be nice to have option to load Stripe javascript based on login status. I solved it for my own purpose by changing this function inside commerce_stripe.module file:

/**
 * Implements hook_init().
 */
function commerce_stripe_init() {
  if(user_is_logged_in()){
    drupal_add_js('https://js.stripe.com/v3', 'external');
  }
}

This way JS is loaded only for logged in users on every page as advised. Also there are no Stripe cookies created for anonymous users.

✨ Feature request
Status

Closed: outdated

Component

Code

Created by

πŸ‡·πŸ‡ΈSerbia miksha

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024