protected function __construct()
 {
     parent::__construct();
     // Cache CC info into hidden field
     add_filter('si_credit_card_form_controls', array($this, 'credit_card_cache'), 10, 2);
     add_action('si_checkout_action', array($this, 'process_credit_card_cache'), 10, 2);
     // Add CC input fields and process & validate
     add_action('si_checkout_action_' . SI_Checkouts::PAYMENT_PAGE, array($this, 'process_payment_page'), 10, 1);
 }
Пример #2
0
 private function __construct()
 {
     self::do_not_cache();
     // never cache the checkout pages
     $this->load_cache();
     $this->load_invoice();
     $this->payment_processor = SI_Payment_Processors::get_payment_processor();
     $this->load_pages();
     $this->handle_action(isset($_REQUEST[self::CHECKOUT_ACTION]) ? $_REQUEST[self::CHECKOUT_ACTION] : '');
 }
 /**
  * Show a pane based on the page within checkout. If not on the checkout
  * show all invoice panes and the active cc processors payments pane.
  *
  * @param  string $current
  * @return string
  */
 public static function show_payments_pane($current = '')
 {
     $processor = '';
     $checkout = SI_Checkouts::get_instance();
     if (SI_Checkouts::is_checkout_page()) {
         $current = $checkout->get_current_page();
         do_action('payments_pane_action_' . strtolower($current), $checkout);
         do_action('payments_pane_action', $current, $checkout);
         $processor = $checkout->get_processor();
     }
     $pane = '';
     switch ($current) {
         case SI_Checkouts::CONFIRMATION_PAGE:
             if (method_exists($processor, 'confirmation_pane')) {
                 $pane = $processor->confirmation_pane($checkout);
             }
             break;
         case SI_Checkouts::REVIEW_PAGE:
             if (method_exists($processor, 'review_pane')) {
                 $pane = $processor->review_pane($checkout);
             }
             break;
         case SI_Checkouts::PAYMENT_PAGE:
             if (method_exists($processor, 'payments_pane')) {
                 $pane = $processor->payments_pane($checkout);
             }
             break;
         default:
             // Load up all invoice level panes
             self::$active_payment_processors = self::enabled_processors();
             foreach (self::$active_payment_processors as $class) {
                 $processor = self::load_processor($class);
                 if (method_exists($processor, 'invoice_pane')) {
                     $pane .= $processor->invoice_pane($checkout);
                 }
                 if (self::is_cc_processor($class) && method_exists($processor, 'payments_pane')) {
                     $pane .= $processor->payments_pane($checkout);
                 }
             }
             break;
     }
     return $pane;
 }
Пример #4
0
/**
 * Load the SI application
 * (function called at the bottom of this page)
 *
 * @package Sprout_Invoices
 * @return void
 */
function sprout_invoices_load()
{
    if (class_exists('Sprout_Invoices')) {
        error_log('** Sprout_Invoices Already Loaded **');
        return;
        // already loaded, or a name collision
    }
    do_action('sprout_invoices_preload');
    //////////
    // Load //
    //////////
    // Master class
    require_once SI_PATH . '/Sprout_Invoices.class.php';
    // base classes
    require_once SI_PATH . '/models/_Model.php';
    require_once SI_PATH . '/controllers/_Controller.php';
    do_action('si_require_base_classes');
    // models
    require_once SI_PATH . '/models/Client.php';
    require_once SI_PATH . '/models/Estimate.php';
    require_once SI_PATH . '/models/Invoice.php';
    require_once SI_PATH . '/models/Notification.php';
    require_once SI_PATH . '/models/Payment.php';
    require_once SI_PATH . '/models/Record.php';
    // Premium models
    require_once SI_PATH . '/models/Project.php';
    // i18n
    require_once SI_PATH . '/controllers/i18n/Countries_States.php';
    require_once SI_PATH . '/controllers/i18n/Locales.php';
    do_action('si_require_model_classes');
    /////////////////
    // Controllers //
    /////////////////
    // settings
    require_once SI_PATH . '/controllers/admin/Settings.php';
    if (!class_exists('SA_Settings_API')) {
        require_once SI_PATH . '/controllers/admin/Settings_API.php';
    }
    require_once SI_PATH . '/controllers/admin/Capabilities.php';
    require_once SI_PATH . '/controllers/admin/Help.php';
    // json api
    require_once SI_PATH . '/controllers/api/JSON_API.php';
    // checkouts
    require_once SI_PATH . '/controllers/checkout/Checkouts.php';
    // clients
    require_once SI_PATH . '/controllers/clients/Clients.php';
    // developer logs
    require_once SI_PATH . '/controllers/developer/Logs.php';
    // Estimates
    require_once SI_PATH . '/controllers/estimates/Estimate_Submission.php';
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/estimates/Estimate_Submission_Premium.php')) {
        require_once SI_PATH . '/controllers/estimates/Estimate_Submission_Premium.php';
    }
    require_once SI_PATH . '/controllers/estimates/Estimates.php';
    require_once SI_PATH . '/controllers/estimates/Estimates_Admin.php';
    require_once SI_PATH . '/controllers/estimates/Estimates_Edit.php';
    require_once SI_PATH . '/controllers/estimates/Estimates_Records.php';
    require_once SI_PATH . '/controllers/estimates/Estimates_Template.php';
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/estimates/Estimates_Premium.php')) {
        require_once SI_PATH . '/controllers/estimates/Estimates_Premium.php';
    }
    // invoices
    require_once SI_PATH . '/controllers/invoices/Invoices.php';
    require_once SI_PATH . '/controllers/invoices/Invoices_Admin.php';
    require_once SI_PATH . '/controllers/invoices/Invoices_Edit.php';
    require_once SI_PATH . '/controllers/invoices/Invoices_Records.php';
    require_once SI_PATH . '/controllers/invoices/Invoices_Template.php';
    require_once SI_PATH . '/controllers/invoices/Invoices_Deposit.php';
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/invoices/Invoices_Premium.php')) {
        require_once SI_PATH . '/controllers/invoices/Invoices_Premium.php';
    }
    // Line Items
    require_once SI_PATH . '/controllers/line-items/Line_Items.php';
    // notifications
    require_once SI_PATH . '/controllers/notifications/Notifications_Control.php';
    require_once SI_PATH . '/controllers/notifications/Notifications.php';
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/notifications/Notifications_Premium.php')) {
        require_once SI_PATH . '/controllers/notifications/Notifications_Premium.php';
    }
    require_once SI_PATH . '/controllers/notifications/Notifications_Admin_Table.php';
    // payment processing
    require_once SI_PATH . '/controllers/payment-processing/Payment_Processors.php';
    require_once SI_PATH . '/controllers/payment-processing/Credit_Card_Processors.php';
    require_once SI_PATH . '/controllers/payment-processing/Offsite_Processors.php';
    // payment processors
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/payment-processing/processors/SI_Paypal_EC.php')) {
        require_once SI_PATH . '/controllers/payment-processing/processors/SI_Paypal_EC.php';
    }
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/payment-processing/processors/SI_Paypal_Pro.php')) {
        require_once SI_PATH . '/controllers/payment-processing/processors/SI_Paypal_Pro.php';
    }
    require_once SI_PATH . '/controllers/payment-processing/processors/SI_Checks.php';
    require_once SI_PATH . '/controllers/payment-processing/processors/SI_Admin_Payment.php';
    do_action('si_payment_processors_loaded');
    // payments
    require_once SI_PATH . '/controllers/payments/Payments.php';
    require_once SI_PATH . '/controllers/payments/Payments_Admin_Table.php';
    // Projects
    require_once SI_PATH . '/controllers/projects/Projects.php';
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/projects/Projects_Premium.php')) {
        require_once SI_PATH . '/controllers/projects/Projects_Premium.php';
    }
    // internal records
    require_once SI_PATH . '/controllers/records/Internal_Records.php';
    require_once SI_PATH . '/controllers/records/Records_Admin_Table.php';
    // reporting
    require_once SI_PATH . '/controllers/reporting/Dashboard.php';
    require_once SI_PATH . '/controllers/reporting/Reporting.php';
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/reporting/Reporting_Premium.php')) {
        require_once SI_PATH . '/controllers/reporting/Reporting_Premium.php';
    }
    require_once SI_PATH . '/controllers/templating/Templating.php';
    require_once SI_PATH . '/controllers/templating/Customizer.php';
    // updates
    if (!SI_FREE_TEST && file_exists(SI_PATH . '/controllers/updates/Updates.php')) {
        require_once SI_PATH . '/controllers/updates/Updates.php';
    }
    if (file_exists(SI_PATH . '/controllers/updates/Free_License.php')) {
        require_once SI_PATH . '/controllers/updates/Free_License.php';
    }
    // importers
    require_once SI_PATH . '/importers/Importer.php';
    require_once SI_PATH . '/importers/Freshbooks.php';
    require_once SI_PATH . '/importers/Harvest.php';
    require_once SI_PATH . '/importers/WP-Invoice.php';
    require_once SI_PATH . '/importers/CSV.php';
    do_action('si_importers_loaded');
    // Fix others problems
    require_once SI_PATH . '/controllers/compat/Compatibility.php';
    // all done
    do_action('si_require_controller_classes');
    // Template tags
    require_once SI_PATH . '/template-tags/estimates.php';
    require_once SI_PATH . '/template-tags/clients.php';
    require_once SI_PATH . '/template-tags/forms.php';
    require_once SI_PATH . '/template-tags/invoices.php';
    require_once SI_PATH . '/template-tags/line-items.php';
    require_once SI_PATH . '/template-tags/projects.php';
    require_once SI_PATH . '/template-tags/ui.php';
    require_once SI_PATH . '/template-tags/utility.php';
    require_once SI_PATH . '/template-tags/docs.php';
    // l18n
    require_once SI_PATH . '/languages/SI_l10n.php';
    require_once SI_PATH . '/languages/SI_Strings.php';
    // i18n & l10n
    SI_l10n::init();
    SI_Strings::load_additional_strings();
    SI_Locales::init();
    SI_Countries_States::init();
    ///////////////////
    // init() models //
    ///////////////////
    do_action('si_models_init');
    SI_Post_Type::init();
    // _Model
    SI_Record::init();
    SI_Notification::init();
    SI_Invoice::init();
    SI_Estimate::init();
    SI_Client::init();
    SI_Payment::init();
    SI_Project::init();
    /////////////////////////
    // init() controllers //
    /////////////////////////
    do_action('si_controllers_init');
    SI_Controller::init();
    SA_Settings_API::init();
    SI_Templating_API::init();
    SI_Customizer::init();
    SI_Admin_Capabilities::init();
    // updates
    if (!SI_FREE_TEST && class_exists('SI_Updates')) {
        SI_Updates::init();
    }
    if (class_exists('SI_Free_License')) {
        SI_Free_License::init();
    }
    // api
    SI_JSON_API::init();
    // reports
    SI_Dashboard::init();
    SI_Reporting::init();
    if (!SI_FREE_TEST && class_exists('SI_Reporting_Premium')) {
        SI_Reporting_Premium::init();
    }
    // records and logs
    SI_Internal_Records::init();
    SI_Dev_Logs::init();
    // settings
    SI_Admin_Settings::init();
    // payments and processing
    SI_Payment_Processors::init();
    SI_Payments::init();
    // notifications
    SI_Notifications::init();
    // Hooks come before parent class.
    if (!SI_FREE_TEST && class_exists('SI_Notifications_Premium')) {
        SI_Notifications_Premium::init();
    }
    SI_Notifications_Control::init();
    // clients
    SI_Clients::init();
    // estimates
    SI_Estimates::init();
    if (!SI_FREE_TEST && class_exists('SI_Estimates_Premium')) {
        SI_Estimates_Premium::init();
    }
    if (!SI_FREE_TEST && class_exists('SI_Estimates_Submission_Premium')) {
        SI_Estimates_Submission_Premium::init();
    }
    SI_Estimate_Submissions::init();
    SI_Estimates_Admin::init();
    SI_Estimates_Edit::init();
    SI_Estimates_Template::init();
    SI_Estimates_Records::init();
    // checkouts
    SI_Checkouts::init();
    // invoices
    SI_Invoices::init();
    SI_Invoices_Admin::init();
    SI_Invoices_Edit::init();
    SI_Invoices_Template::init();
    SI_Invoices_Records::init();
    SI_Invoices_Deposit::init();
    if (!SI_FREE_TEST && class_exists('SI_Invoices_Premium')) {
        SI_Invoices_Premium::init();
    }
    // Line items
    SI_Line_Items::init();
    // projects
    SI_Projects::init();
    if (!SI_FREE_TEST && class_exists('SI_Projects_Premium')) {
        SI_Projects_Premium::init();
    }
    // importer
    SI_Importer::init();
    // help
    SI_Help::init();
    // Compat
    SI_Compatibility::init();
    // addons
    require_once SI_PATH . '/add-ons/Addons.php';
    require_once SI_PATH . '/add-ons/updates/edd_plugin_updater.class.php';
    SA_Addons::init();
    do_action('sprout_invoices_loaded');
}
Пример #5
0
 /**
  * The payment link for invoices
  * @param  integer $id
  * @param  string $type
  * @return string
  */
 function si_get_payment_link($id = 0, $type = '')
 {
     if (!$id) {
         $id = get_the_ID();
     }
     if ($type == '') {
         $processor = SI_Payment_Processors::get_payment_processor();
         $type = $processor->get_slug();
     }
     $url = add_query_arg(array(SI_Checkouts::CHECKOUT_QUERY_VAR => $type, 'nonce' => wp_create_nonce(SI_Controller::NONCE)), si_get_payment_url($id));
     return apply_filters('si_get_payment_link', esc_url_raw($url), $id, $type);
 }
 protected function __construct()
 {
     parent::__construct();
     add_action('si_checkout_action_' . SI_Checkouts::PAYMENT_PAGE, array($this, 'processed_payment_page'), 20, 1);
 }
Пример #7
0
 /**
  * Cancel a recurring payment
  *
  * @return void
  */
 public function cancel()
 {
     if ($this->get_status() == self::STATUS_RECURRING) {
         do_action('sa_cancelling_recurring_payment', $this);
         // cancel the actual payment
         $payment_processor = SI_Payment_Processors::get_payment_processor();
         $payment_processor->cancel_recurring_payment($this);
         $this->set_status(self::STATUS_CANCELLED);
         // notify plugins that this has been cancelled
         $purchase_id = $this->get_purchase();
         do_action('sa_recurring_payment_cancelled', $this, $purchase_id);
     }
 }
Пример #8
0
 /**
  * The payment link for invoices
  * @param  integer $id 
  * @param  string $type
  * @return string      
  */
 function si_get_payment_link($id = 0, $type = '')
 {
     if (!$id) {
         global $post;
         $id = $post->ID;
     }
     if ($type == '') {
         $processor = SI_Payment_Processors::get_payment_processor();
         $type = $processor->get_slug();
     }
     $url = add_query_arg(array(SI_Checkouts::CHECKOUT_QUERY_VAR => $type, 'nonce' => wp_create_nonce(SI_Controller::NONCE)), si_get_payment_url($id));
     return esc_url_raw($url);
 }
Пример #9
0
/**
 * Get the currency symbol, filtering out the location string(%)
 * @param boolean $filter_location filter out the location string from return
 * @return return
 */
function sa_get_currency_symbol($filter_location = true)
{
    $string = apply_filters('sa_get_currency_symbol_pre', SI_Payment_Processors::get_currency_symbol());
    if ($filter_location && strstr($string, '%')) {
        $string = str_replace('%', '', $string);
    }
    // If no position is set add it.
    if (!$filter_location && !strstr($string, '%')) {
        $locale_formatting = si_localeconv();
        if (!$locale_formatting['p_cs_precedes']) {
            $string . '%';
        }
    }
    return apply_filters('sa_get_currency_symbol', $string);
}
 /**
  * Show time tracking metabox.
  * @param  WP_Post $post
  * @param  array $metabox
  * @return
  */
 public static function show_subscription_payments_meta_box($post, $metabox)
 {
     $invoice = SI_Invoice::get_instance($post->ID);
     $recurring_payment = SI_Payment_Processors::get_recurring_payment($invoice);
     self::load_addon_view('admin/meta-boxes/invoices/subscription-payments', array('invoice_id' => $post->ID, 'recurring_payment' => $recurring_payment, 'fields' => self::subscription_options($invoice)), false);
 }