You are here

function stripe_element_validate_empty in Stripe 7

Element validate function to ensure that the posted value for an element is empty. We do this just to double check that credit card numbers are not getting posted to the server, as this would create PCI implications. If they are making it back to the server, we stop the form from processing, and log a watchdog alert.

1 string reference to 'stripe_element_validate_empty'
stripe_element_process in ./stripe.module
Process callback for this module elements.

File

./stripe.module, line 281
stripe.module Drupal hooks used for integrating the Stripe service.

Code

function stripe_element_validate_empty($element, $form_state, $form) {
  static $logged = FALSE;

  // Log a watchdog message the first time only. No need to log two messages.
  if (!empty($element['#value']) && !$logged) {

    // Set an error on the first element this happened on.
    form_error($element, t('There was a problem processing your payment.
      For your own protection, it is recommended you do NOT attempt to re-enter
      your payment information.'));

    // Now log a watchdog alert.
    $message = 'Credit Card information is being posted to your server. ' . 'Please disable Stripe module immediately and submit a bug ' . 'report at http://drupal.org/node/add/project-issue/stripe.';
    watchdog('stripe', $message, NULL, WATCHDOG_ALERT);
    $logged = TRUE;
  }
}