/**
  * Register a file as a payment gateway module.
  *
  * The payment gateway inside the file must be defined as a subclass of WPSC_Payment_Gateway.
  *
  * The file name should be lowercase, using hyphens or underscores between words
  * instead of spaces. The class name must have "WPSC_Payment_Gateway_" as the
  * prefix, followed by the file name, in which words are capitalized and connected
  * by underscore.
  *
  * For example, if the file name is "paypal-pro.php", then the class name inside
  * the file must be WPSC_Payment_Gateway_Paypal_Pro.
  *
  * @access public
  * @since 3.9
  * @see WPSC_Payment_Gateways::register_dir()
  *
  * @param string $file Absolute path to the file containing the payment gateway
  * class
  * @return mixed Return true if the file is successfully included and contains
  * a valid class. Otherwise, a WP_Error object is returned.
  */
 public static function register_file($file)
 {
     if (empty(self::$payment_gateway_cache)) {
         self::$payment_gateway_cache = get_option('wpsc_payment_gateway_cache', array());
     }
     $filename = basename($file, '.php');
     // payment gateway already exists in cache
     if (isset(self::$payment_gateway_cache[$filename])) {
         self::$gateways[$filename] = self::$payment_gateway_cache[$filename];
     }
     // if payment gateway is not in cache, load metadata
     $classname = ucwords(str_replace('-', ' ', $filename));
     $classname = 'WPSC_Payment_Gateway_' . str_replace(' ', '_', $classname);
     if (file_exists($file)) {
         require_once $file;
     }
     if (is_callable(array($classname, 'load')) && !call_user_func(array($classname, 'load'))) {
         self::unregister_file($filename);
         $error = new WP_Error('wpsc-payment', __('Error', 'wp-e-commerce'));
         return $error;
     }
     $meta = array('class' => $classname, 'path' => $file, 'internalname' => $filename);
     $gateway = self::get($filename, $meta);
     if (is_wp_error($gateway)) {
         return $gateway;
     }
     $meta['name'] = $gateway->get_title();
     $meta['image'] = $gateway->get_image_url();
     $meta['mark'] = $gateway->get_mark_html();
     self::$gateways[$filename] = $meta;
     return true;
 }
 /**
  * Register a file as a payment gateway module.
  *
  * The payment gateway inside the file must be defined as a subclass of WPSC_Payment_Gateway.
  *
  * The file name should be lowercase, using hyphens or underscores between words
  * instead of spaces. The class name must have "WPSC_Payment_Gateway_" as the
  * prefix, followed by the file name, in which words are capitalized and connected
  * by underscore.
  *
  * For example, if the file name is "paypal-pro.php", then the class name inside
  * the file must be WPSC_Payment_Gateway_Paypal_Pro.
  *
  * @access public
  * @since 3.9
  * @see WPSC_Payment_Gateways::register_dir()
  *
  * @param string $file Absolute path to the file containing the payment gateway
  * class
  * @return mixed Return true if the file is successfully included and contains
  * a valid class. Otherwise, a WP_Error object is returned.
  */
 public static function register_file($file)
 {
     if (empty(self::$payment_gateway_cache)) {
         self::$payment_gateway_cache = get_option('wpsc_payment_gateway_cache', array());
     }
     $filename = basename($file, '.php');
     // payment gateway already exists in cache
     if (isset(self::$payment_gateway_cache[$filename])) {
         self::$gateways[$filename] = self::$payment_gateway_cache[$filename];
         return true;
     }
     // if payment gateway is not in cache, load metadata
     $classname = ucwords(str_replace('-', ' ', $filename));
     $classname = 'WPSC_Payment_Gateway_' . str_replace(' ', '_', $classname);
     $meta = array('class' => $classname, 'path' => $file, 'internalname' => $filename);
     $gateway = self::get($filename, $meta);
     if (is_wp_error($gateway)) {
         return $gateway;
     }
     $meta['name'] = $gateway->get_title();
     $meta['image'] = $gateway->get_image_url();
     $meta['mark'] = $gateway->get_mark_html();
     self::$gateways[$filename] = $meta;
     return true;
 }