示例#1
0
 /**
  * Construct and initialize an Pronamic Pay plugin object
  */
 public function __construct()
 {
     // Bootstrap the add-ons
     Pronamic_WP_Pay_Extensions_Charitable_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_WooCommerce_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_GravityForms_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_Shopp_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_Jigoshop_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_ClassiPress_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_EventEspressoLegacy_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_EventEspresso_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_AppThemes_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_S2Member_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::bootstrap();
     // Pronamic_WP_Pay_Extensions_EShop_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_EDD_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_IThemesExchange_Extension::bootstrap();
     Pronamic_WP_Pay_Extensions_MemberPress_Extension::bootstrap();
     // Post Types
     $this->post_types = new Pronamic_WP_Pay_PostTypes();
     // Shortcodes
     $this->shortcodes = new Pronamic_WP_Pay_Shortcodes();
     // License
     $this->license_manager = new Pronamic_WP_Pay_LicenseManager();
     // Form Processor
     $this->form_processor = new Pronamic_WP_Pay_FormProcessor();
     // Gateway Integrations
     add_filter('pronamic_pay_gateway_integrations', array($this, 'gateway_integrations'));
     $this->gateway_integrations = new Pronamic_WP_Pay_GatewayIntegrations();
     // Admin
     if (is_admin()) {
         $this->admin = new Pronamic_WP_Pay_Admin($this);
     }
     // Setup
     add_action('plugins_loaded', array($this, 'plugins_loaded'), 9);
     // Payment notes
     add_filter('comments_clauses', array($this, 'exclude_comment_payment_notes'), 10, 2);
     // Initialize requirements
     require_once self::$dirname . '/includes/version.php';
     require_once self::$dirname . '/includes/functions.php';
     require_once self::$dirname . '/includes/formatting.php';
     require_once self::$dirname . '/includes/page-functions.php';
     require_once self::$dirname . '/includes/providers.php';
     require_once self::$dirname . '/includes/gateways.php';
     require_once self::$dirname . '/includes/payment.php';
     require_once self::$dirname . '/includes/post.php';
     require_once self::$dirname . '/includes/xmlseclibs/xmlseclibs-ing.php';
     // If WordPress is loaded check on returns and maybe redirect requests
     add_action('wp_loaded', array($this, 'handle_returns'));
     add_action('wp_loaded', array($this, 'maybe_redirect'));
     // The 'pronamic_ideal_check_transaction_status' hook is scheduled the status requests
     add_action('pronamic_ideal_check_transaction_status', array($this, 'check_status'), 10, 3);
     add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
 }
 /**
  * Plugins loaded
  */
 public static function plugins_loaded()
 {
     if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::is_active()) {
         // Backwards compatibility Membership <= 3.4
         $class_aliases = array('M_Gateway' => 'Membership_Gateway', 'M_Subscription' => 'Membership_Model_Subscription', 'M_Membership' => 'Membership_Model_Member');
         if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::is_membership2()) {
             $m2_class_aliases = array('Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_ViewSettings' => 'MS_Gateway_Pronamic_View_Settings', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealViewSettings' => 'MS_Gateway_Pronamic_ideal_View_Settings', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_ViewButton' => 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Gateway_View_Button', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealViewButton' => 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealGateway_View_Button');
             $class_aliases = array_merge($class_aliases, $m2_class_aliases);
         }
         foreach ($class_aliases as $orignal => $alias) {
             if (class_exists($orignal) && !class_exists($alias)) {
                 // http://www.php.net/manual/en/function.class-alias.php
                 class_alias($orignal, $alias);
             }
         }
         // Register the Membership iDEAL gateway
         // Membership < 3.5
         if (function_exists('M_register_gateway')) {
             M_register_gateway('pronamic_ideal', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealGateway');
         }
         // Membership >= 3.5
         if (method_exists('Membership_Gateway', 'register_gateway')) {
             Membership_Gateway::register_gateway('pronamic_ideal', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealGateway');
         }
         // Membership2
         if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::is_membership2()) {
             add_filter('ms_model_gateway_register', array(__CLASS__, 'register_gateway'));
         }
         add_filter('pronamic_payment_redirect_url_' . self::SLUG, array(__CLASS__, 'redirect_url'), 10, 2);
         add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 1);
         add_filter('pronamic_payment_source_text_' . self::SLUG, array(__CLASS__, 'source_text'), 10, 2);
         if (is_admin()) {
             $admin = new Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Admin();
         }
     }
 }
 public function get_success_url()
 {
     if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::is_membership2()) {
         return esc_url_raw(add_query_arg(array('ms_relationship_id' => $this->subscription->id), MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REG_COMPLETE, false)));
     }
     return M_get_registrationcompleted_permalink();
 }
示例#4
0
 /**
  * Maybe pay
  */
 public function maybe_pay()
 {
     $pay_membership = sprintf('pronamic_pay_membership_%s', $this->gateway);
     if (filter_has_var(INPUT_POST, $pay_membership)) {
         // Data
         $subscription_id = filter_input(INPUT_POST, 'subscription_id', FILTER_SANITIZE_STRING);
         $user_id = filter_input(INPUT_POST, 'user_id', FILTER_SANITIZE_STRING);
         if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::is_membership2()) {
             $subscription = MS_Factory::load('MS_Model_Relationship', $subscription_id);
             $membership = $subscription->get_membership();
             $config_id = $this->config_id;
         } else {
             $subscription = Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::get_subscription($subscription_id);
             $membership = Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::get_membership($user_id);
             $config_id = get_option(Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::OPTION_CONFIG_ID);
         }
         if (isset($subscription, $membership)) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
             $data = new Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_PaymentData($subscription, $membership);
             // Start
             $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data, $this->payment_method);
             // Meta
             update_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', $user_id);
             update_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', $data->get_subscription_id());
             if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::is_membership2()) {
                 $invoice = $subscription->get_current_invoice();
                 $invoice->gateway_id = $this->id;
                 $invoice->save();
                 update_post_meta($payment->get_id(), '_pronamic_payment_membership_invoice_id', $invoice->id);
             }
             // Membership record transaction
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L176
             $this->pronamic_record_transaction($user_id, $data->get_subscription_id(), $data->get_amount(), $data->get_currency(), time(), $payment->get_id(), '', '');
             // Error
             $error = $gateway->get_error();
             if (is_wp_error($error)) {
                 $this->error = $error;
             } else {
                 // Redirect
                 $gateway->redirect($payment);
             }
         }
     }
 }