Prevent renewals on non-production environments

Created on 8 November 2019, over 4 years ago
Updated 13 September 2023, 10 months ago

I'm trying to determine the best way to prevent renewals from firing on non-production (e.g. dev) environments. In Drupal 7, it was rules based and I could use a rule to check environment variables before invoking the queue. I'm still looking through this module and Advanced Queue to figure out the best way to handle this, but figured I'd go ahead and get this issue posted.

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States andyg5000 North Carolina, USA

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.

  • πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

    Overriding the payment gateway via settings.php for each environment is what I'm currently doing, using the gateway in test mode everywhere except production, so only test credentials are ever stored in the db config.

    I think this is right

    So at the very least you want to be really really sure outbound email does not get sent. I'm constantly trapping fail messages in Mailhog.

    There's many reasons why you want to be really really sure of that.

    I think this stuff is important, but more fundamental than should be in scope for commerce_recurring. At most a warning in the module documentation.

  • πŸ‡ΊπŸ‡ΈUnited States mariacha1

    I'm just leaving a quick note on how I solved the problem in case it can help others.

    Since commerce_recurring uses "advancedqueue" with an option to set the processor to either "daemon" (meaning run by drush or drupal console) or "cron" I just added some lines to my settings.php file to say "only run commerce_recurring on cron on live". With that I'm able to test out recurring charges on my local or dev databases using drush advancedqueue:queue:process commerce_recurring (and have it run against my testing sandbox for credit cards, handled also through settings.php) while still having the live site run on cron. Here's the code in my settings.php file (example is for Pantheon):

    // Protect ourselves from a cron run attempting to renew subscriptions.
    $config['advancedqueue.advancedqueue_queue.commerce_recurring']['processor'] = 'daemon';
    
    if (defined('PANTHEON_ENVIRONMENT') && (PANTHEON_ENVIRONMENT == 'live')) {
      $config['advancedqueue.advancedqueue_queue.commerce_recurring']['processor'] = 'cron';
    }
    
Production build 0.69.0 2024