Example #1
0
 /**
  * Setup the module for runtime
  *
  * Auto-loads settings for the module and setups defaults
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function __construct()
 {
     $this->module = get_class($this);
     $this->session = ShoppShopping()->session;
     $this->Order = ShoppOrder();
     if ('ShoppFreeOrder' != $this->module) {
         // There are no settings for ShoppFreeOrder
         $this->settings = shopp_setting($this->module);
         // @todo Remove legacy gateway settings migrations
         // Attempt to copy old settings if this is a new prefixed gateway class
         if (empty($this->settings) && false !== strpos($this->module, 'Shopp')) {
             $legacy = substr($this->module, 5);
             $this->settings = shopp_setting($legacy);
             if (!empty($this->settings)) {
                 shopp_set_setting($this->module, $this->settings);
             }
         }
     }
     if (!isset($this->settings['label']) && $this->cards) {
         $this->settings['label'] = __('Credit Card', 'Shopp');
     }
     $this->baseop = ShoppBaseLocale()->settings();
     $this->currency = ShoppBaseCurrency()->code();
     $this->precision = ShoppBaseCurrency()->precision();
     $this->_loadcards();
     $gateway = GatewayModules::hookname($this->module);
     add_action('shopp_init', array($this, 'myactions'), 30);
     add_action('shopp_' . $gateway . '_refunded', array($this, 'cancelorder'));
     if ($this->authonly) {
         add_filter('shopp_purchase_order_' . $gateway . '_processing', create_function('', 'return "auth";'));
     } elseif ($this->saleonly) {
         add_filter('shopp_purchase_order_' . $gateway . '_processing', create_function('', 'return "sale";'));
     }
 }
Example #2
0
 /**
  * Order processing decides the type of transaction processing request to make
  *
  * Decides which processing operation to perform:
  *     auth - Get authorization from the payment processor to charge the order amount
  *     sale - Get authorization and immediate capture of the payment
  *
  * @author Jonathan Davis
  * @since 1.2
  * @param $Purchase
  * @return void
  */
 public function process($Purchase)
 {
     // Authorize payments for shipped orders, use sale (auth+capture) for anything else
     $processing = $this->Cart->shipped() ? 'auth' : 'sale';
     $default = array($this, $processing);
     // Gateway modules can use 'shopp_purchase_order_gatewaymodule_processing' filter hook to override order processing
     // Return a string of 'auth' for auth processing, or 'sale' for sale processing
     // For advanced overrides, gateways can provide custom callbacks as a standard PHP object callback array: array($this,'customhandler')
     if (!empty($Purchase->gateway)) {
         $processing = apply_filters('shopp_purchase_order_' . sanitize_key($Purchase->gateway) . '_processing', $processing, $Purchase);
         $processing = apply_filters('shopp_purchase_order_' . GatewayModules::hookname($Purchase->gateway) . '_processing', $processing, $Purchase);
     }
     // General order processing filter override
     $processing = apply_filters('shopp_purchase_order_processing', $processing, $Purchase);
     if (is_string($processing)) {
         $callback = array($this, $processing);
     } elseif (is_array($processing)) {
         $callback = $processing;
     }
     if (!is_callable($callback)) {
         $callback = $default;
     }
     call_user_func($callback, $Purchase);
 }