You are here

function stripe_update_7102 in Stripe 7

Convert `stripe_{set}_secret` and `stripe_{$set}_publishable` keys to a single set.

File

./stripe.install, line 130
Install, update and uninstall functions for the Stripe module.

Code

function stripe_update_7102(&$sandbox) {
  if (!empty(variable_get('stripe_test_secret', ''))) {

    // Find out which status we are using.
    $set = variable_get('stripe_key_status', 'test');
    drupal_set_message(t('Using Stripe API key status: %set', array(
      '%set' => $set,
    )));

    // Update values from our previous settings.
    $secret = variable_get('stripe_' . $set . '_secret', '');
    if (!empty($secret)) {
      variable_set('stripe_secret', $secret);
      drupal_set_message(t('Set secret key.'));
      variable_del('stripe_test_secret');
      variable_del('stripe_live_secret');
      drupal_set_message(t('Deleted old secret keys'));
    }
    $publishable = variable_get('stripe_' . $set . '_publishable', '');
    if (!empty($publishable)) {
      variable_set('stripe_publishable', $publishable);
      drupal_set_message(t('Set publishable key.'));
      variable_del('stripe_test_publishable');
      variable_del('stripe_live_publishable');
      drupal_set_message(t('Deleted old publishable keys'));
    }
  }
}