Ejemplo n.º 1
0
 /**
  * Factory method for gateways.
  *
  * Return the matching gateway for the provider
  * $name must be the name of the gateway class in underscore format
  * for AuthorizeNet gateway will be authorize_net
  *
  * <code>
  *      AktiveMerchant\Billing\Base::gateway('authorize_net');
  * </code>
  *
  * @param  string $name    the underscored name of the gateway.
  * @param  array  $options the options for gateway construct.
  *
  * @return AktiveMerchant\Billing\Gateway the gateway instance
  */
 public static function gateway($name = null, $options = array())
 {
     $gateway = "\\AktiveMerchant\\Billing\\Gateways\\" . Inflect::camelize($name);
     if (class_exists($gateway)) {
         return new $gateway($options);
     }
     throw new Exception("Unable to load class: {$gateway}.");
 }
Ejemplo n.º 2
0
 /**
  * Gets an array with supported actions for given gateway.
  *
  * @param string|Gateway $gateway
  * @access public
  * @return array
  */
 public function getSupportedActions($gateway)
 {
     if (!is_string($gateway)) {
         $gateway = get_class($gateway);
     }
     $gateway = Inflect::camelize($gateway);
     $class = new \ReflectionClass('AktiveMerchant\\Billing\\Gateways\\' . $gateway);
     $actions = array();
     foreach ($this->actions as $action) {
         if ($class->hasMethod($action)) {
             $actions[] = $action;
         }
     }
     return $actions;
 }
Ejemplo n.º 3
0
 public function factory_name()
 {
     $class = str_replace('ActiveMerchant\\Billing\\Gateways\\', '', get_class($this));
     return Inflect::underscore($class);
 }