Drupal Commerce Blog

What's happening in the world of Drupal Commerce.

How to switch your payment settings based on environment variables using Platform.sh

When working on a Commerce project which uses a payment gateway, you need to always make sure that your Staging and Development environments are properly targeting the sandbox or test mode of your payment gateway, and that your Production site is targeting the live account.

This is actually true for any third-party service integration which provides a sandbox where you can test. The objective is to make sure you never send test data on a live account, no matter the service you're testing on.

For this tutorial, I will focus on payment method settings, but the principle remains the same for any other third-party integration.

I will start from an empty Drupal site hosted on Platform.sh and go through the following steps:

  • Enable and configure Paypal WPS payment method
  • Export its configuration to a settings.local.php file
  • Override its Sandbox configuration on the Staging environment
  • Write custom code to read the configuration from the settings.local.php

As you see, the goal (as always with Drupal) is to read the configuration from your code so that you can easily switch from a sandbox mode to a live mode.

Augustin Delaporte
Posted: Dec 4, 2014

Converting Your Existing Platform.sh Development Environment to a Makefile

Platform.sh build window: Building as a vanilla project, you are missing out!

One of the most exciting features of Platform.sh is it’s ability to use Drush makefiles to rapidly prototype sites. By default, new projects can start with a makefile that will automatically add Commerce Kickstart or vanilla Drupal. Then, using the makefile, you can add new modules, themes, and libraries, by simply adding a few lines to the makefile and commiting. When you push the changes to your platform, the entire site will be rebuilt. Plus, whenever you’re in “makefile mode” any extra files that are in the root of the respository get pushed into sites/all/default. So if you have any custom modules, you can just stick them in modules/ and they’ll end up in sites/all/default/modules. This can make your code bases not only small, but far more manageable. You can convert a site that isn’t a makefile into a makefile. And in this post, that’s exactly what we’re going to do.

Nicholas Vahalik
Posted: Jul 21, 2014
Subscribe to RSS - Platform.sh