/** * 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'); 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'); } add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 2); 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 __construct() { parent::__construct(); add_action('M_gateways_settings_' . $this->gateway, array(&$this, 'mysettings')); // If I want to override the transactions output - then I can use this action //add_action('M_gateways_transactions_' . $this->gateway, array(&$this, 'mytransactions')); if ($this->is_active()) { // Subscription form gateway add_action('membership_purchase_button', array(&$this, 'display_subscribe_button'), 1, 3); // Payment return add_action('membership_handle_payment_return_' . $this->gateway, array(&$this, 'handle_paypal_return')); add_filter('membership_subscription_form_subscription_process', array(&$this, 'signup_free_subscription'), 10, 2); } }
/** * Constructs and initliaze an Membership iDEAL gateway */ public function __construct() { parent::__construct(); // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.freesubscriptions.php#L30 // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L97 if ($this->is_active()) { add_action('init', array($this, 'maybe_pay')); // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/includes/payment.form.php#L78 add_action('membership_purchase_button', array($this, 'purchase_button'), 1, 3); // Status update $slug = Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Extension::SLUG; add_action("pronamic_payment_status_update_{$slug}", array($this, 'status_update'), 10, 2); } }
public function __construct() { parent::__construct(); add_action('M_gateways_settings_' . $this->gateway, array(&$this, 'mysettings')); // https://sandbox.2checkout.com/checkout/purchase if (get_option($this->gateway . "_twocheckout_status") != 'live') { $this->tco_url = "https://sandbox.2checkout.com"; } // If I want to override the transactions output - then I can use this action //add_action('M_gateways_transactions_' . $this->gateway, array(&$this, 'mytransactions')); if ($this->is_active()) { // Subscription form gateway add_action('membership_purchase_button', array(&$this, 'display_subscribe_button'), 1, 3); // Payment return add_action('membership_handle_payment_return_' . $this->gateway, array(&$this, 'handle_2checkout_return')); add_filter('membership_gateway_exp_window', array(&$this, 'twocheckout_expiration_window')); add_action('membership_mark_for_expire', array(&$this, 'remove_recurring_line_item'), null, 2); } }
function __construct() { parent::__construct(); add_action('M_gateways_settings_' . $this->gateway, array(&$this, 'mysettings')); add_action('membership_subscription_form_registration_process', array(&$this, 'force_ssl_cookie'), null, 2); if ($this->is_active()) { // Subscription form gateway add_action('membership_purchase_button', array(&$this, 'display_subscribe_button'), 1, 3); add_action('membership_payment_form', array(&$this, 'display_payment_form'), 10, 3); // Payment return add_action('membership_handle_payment_return_' . $this->gateway, array(&$this, 'handle_payment_return')); add_filter('membership_subscription_form_subscription_process', array(&$this, 'signup_subscription'), 10, 2); // Ajax calls for purchase buttons - if logged out add_action('wp_ajax_nopriv_purchaseform', array(&$this, 'popover_payment_form')); // if logged in add_action('wp_ajax_purchaseform', array(&$this, 'popover_payment_form')); // Ajax calls for purchase processing - if logged out add_action('wp_ajax_nopriv_processpurchase_' . $this->gateway, array(&$this, 'process_payment_form')); // if logged in add_action('wp_ajax_processpurchase_' . $this->gateway, array(&$this, 'process_payment_form')); } }
/** * Renders renew subscriptions. * * @since 3.5 * * @access private * @global membershippublic $membershippublic The global membershippublic object. * @global array $M_options The settings array. */ private function _render_renew_subscription() { global $membershippublic, $M_options; $factory = Membership_Plugin::factory(); // The user has a subscription so we can display it with the information $member = current_member(); $rels = array_filter((array) $member->get_relationships()); if (empty($M_options['renewalperiod'])) { $M_options['renewalperiod'] = 7; } $success_msg = __('Your current subscriptions are listed here. You can renew, cancel or upgrade your subscriptions by using the forms below.', 'membership'); ?> <div id="membership-wrapper"> <legend><?php echo __('Your Subscriptions', 'membership'); ?> </legend> <div class="alert alert-success"> <?php echo $success_msg; ?> </div> <div class="priceboxes"><?php foreach ($rels as $rel) { $sub = $factory->get_subscription($rel->sub_id); $nextlevel = $sub->get_next_level($rel->level_id, $rel->order_instance); $currentlevel = $sub->get_level_at($rel->level_id, $rel->order_instance); $expire_date = mysql2date('U', $rel->expirydate); $expire_date_string = date_i18n(get_option('date_format'), $expire_date); if (!empty($rel->usinggateway) && $rel->usinggateway != 'admin') { $gateway = Membership_Gateway::get_gateway($rel->usinggateway); if (!empty($gateway) && $gateway->issingle) { $gatewayissingle = 'yes'; } else { $gatewayissingle = 'no'; } } else { $gatewayissingle = 'admin'; } ?> <div class="pricebox subscribedbox" id="subscribedbox-<?php echo $sub->id; ?> "> <div class="topbar"> <span class="title"><?php echo $sub->sub_name(); ?> </span> </div> <div class="pricedetails"><?php if ($member->is_marked_for_expire($rel->sub_id)) { echo sprintf(__('Your membership has been cancelled and will expire on: <strong>%s</strong>', 'membership'), $expire_date_string); } else { if ($currentlevel->sub_type == 'indefinite') { echo __('You are on an <strong>indefinite</strong> membership.', 'membership'); } elseif ($gatewayissingle == 'yes') { echo sprintf(__('Your membership is due to expire on: <strong>%s</strong> ', 'membership'), $expire_date_string); } else { // Serial gateway switch ($currentlevel->sub_type) { case 'serial': echo __('Your membership is set to <strong>automatically renew</strong>', 'membership'); break; case 'finite': if (!empty($nextlevel)) { // We have a level we can move to next echo __('Your membership is set to <strong>automatically renew</strong>', 'membership'); } else { echo sprintf(__('Your membership is due to expire on: <strong>%s</strong> ', 'membership'), $expire_date_string); } break; } } } // Get the last upgrade time $upgradedat = get_user_meta($member->ID, '_membership_last_upgraded', true); if (empty($upgradedat)) { $upgradedat = strtotime('-1 year'); } $period = isset($M_options['upgradeperiod']) ? $M_options['upgradeperiod'] : 1; if (empty($period) && $period != 0) { $period = 1; } if (!$member->is_marked_for_expire($rel->sub_id) && $gatewayissingle == 'yes') { $renewalperiod = strtotime('-' . $M_options['renewalperiod'] . ' days', $expire_date); if ($nextlevel && time() >= $renewalperiod) { // we have a next level so we can display the details and form for it if ($member->has_active_payment($rel->sub_id, $nextlevel->level_id, $nextlevel->level_order)) { ?> <legend><?php echo __('Renewal your subscription', 'membership'); ?> </legend> <div class="renew-form"> <div class="formleft"> <p><?php printf(__('Renewal for the %s following %s has been completed.', 'membership'), sprintf('<strong>%s %s</strong>', $nextlevel->level_period, $this->_get_period($nextlevel->level_period_unit, $nextlevel->level_period)), $expire_date_string); ?> </p> </div> </div> <!-- renew-form --><?php } else { ?> <div class="renew-form"> <div class="formleft"> <p><?php printf($nextlevel->level_price > 0 ? __('To renew your subscription for another %s following %s you will need to pay %s.', 'membership') : __('To renew your subscription for another %s following %s click on the button to the right.', 'membership'), sprintf('<strong>%s %s</strong>', $nextlevel->level_period, $this->_get_period($nextlevel->level_period_unit, $nextlevel->level_period)), $expire_date_string, sprintf('<strong>%s %s</strong>', $nextlevel->level_price, apply_filters('membership_real_currency_display', $M_options['paymentcurrency']))); // Need to put in coupon code bit here in case they have signed up with one $gateway->display_subscribe_button($sub, $sub->get_pricingarray(), $member->ID, $nextlevel->level_order); ?> </p> </div> </div> <!-- renew-form --> <?php } } } ?> </div> <div class="bottombar"> <div style="float:right;margin-right:10px"><?php if (!$member->is_marked_for_expire($rel->sub_id)) { if ($gatewayissingle != 'admin' && method_exists($gateway, 'display_cancel_button')) { $gateway->display_cancel_button($sub, $sub->get_pricingarray(), $member->ID); } else { ?> <form class="unsubbutton" method="post"> <input type="hidden" name="action" value="unsubscribe"> <input type="hidden" name="gateway" value="admin"> <input type="hidden" name="subscription" value="<?php echo esc_attr($rel->sub_id); ?> "> <input type="hidden" name="user" value="<?php echo esc_attr($member->ID); ?> "> <?php wp_nonce_field('cancel-sub_' . $rel->sub_id); ?> <input type="submit" value="<?php esc_attr_e('Unsubscribe', 'membership'); ?> " class="button <?php echo apply_filters('membership_subscription_button_color', ''); ?> "> </form><?php } } ?> </div> </div> </div> <!-- price box --><?php if ($upgradedat <= strtotime('-' . $period . ' days') || !current_user_has_subscription() && !empty($M_options['freeusersubscription'])) { $upgradesubs = array(); foreach (array_filter((array) apply_filters('membership_override_upgrade_subscriptions', $membershippublic->get_subscriptions())) as $upgradesub) { if ($upgradesub->id == $rel->sub_id || $member->on_sub($upgradesub->id)) { // Don't want to show our current subscription as we will display this above. continue; } $upgradesubs[] = $upgradesub; } // Show upgrades if (!empty($upgradesubs)) { ?> <legend class="upgradefrom-<?php echo $sub->id; ?> "> <?php printf(_x('Upgrade from %s', 'Upgrade from {subscription name}', 'membership'), $sub->sub_name()); ?> </legend><?php } foreach ($upgradesubs as $upgradesub) { $subscription = $factory->get_subscription($upgradesub->id); ?> <div class="pricebox upgradebox upgradefrom-<?php echo $sub->id; ?> " id="upgradebox-<?php echo $subscription->id; ?> "> <div class="topbar"> <span class="title"> <strong><?php _ex('Move to:', 'Move to another subscription', 'membership'); ?> </strong> <?php echo $subscription->sub_name(); ?> </span> </div> <div class="pricedetails"> <?php echo $subscription->sub_description(); ?> </div> <div class="bottombar"> <div style="float:right;margin-right:10px"><?php // do an upgrade button $pricing = $subscription->get_pricingarray(); if (!empty($pricing)) { if ($gatewayissingle != 'admin') { if ($currentlevel->level_price < 1) { // We are on a free level, so need to do an upgrade from free if (method_exists($gateway, 'display_upgrade_from_free_button')) { $gateway->display_upgrade_from_free_button($subscription, $pricing, $member->ID, $rel->sub_id, $sub->id); } } else { // We want a normal upgrade button if (method_exists($gateway, 'display_upgrade_button')) { $gateway->display_upgrade_button($subscription, $pricing, $member->ID, $rel->sub_id); } } } else { $class = ''; if (isset($M_options['formtype']) && $M_options['formtype'] == 'new') { // pop up form $link = add_query_arg(array('action' => 'buynow', 'subscription' => $subscription->id, 'from_subscription' => $rel->sub_id), admin_url('admin-ajax.php')); $class = 'popover'; } else { // original form $link = add_query_arg(array('action' => 'registeruser', 'subscription' => $subscription->id, 'from_subscription' => $rel->sub_id), get_permalink($M_options['registration_page'])); } ?> <a href="<?php echo esc_url($link); ?> " class="button button-primary <?php echo $class; ?> <?php echo esc_attr(apply_filters('membership_subscription_button_color', '')); ?> "> <?php echo esc_html(apply_filters('membership_subscription_signup_text', __('Sign Up', 'membership'))); ?> </a><?php } } ?> </div> <span class="price"><?php echo $subscription->sub_pricetext(); ?> </span> </div> </div> <!-- pricebox --><?php } } } ?> </div> <!-- price boxes --> </div><!-- membership wrapper --><?php }
<?php global $M_options; $factory = Membership_Plugin::factory(); if (isset($_REQUEST['gateway']) && isset($_REQUEST['extra_form'])) { $gateway = Membership_Gateway::get_gateway($_REQUEST['gateway']); if ($gateway && is_object($gateway) && $gateway->haspaymentform == true) { $sub = $factory->get_subscription($subscription); $pricing = $sub->get_pricingarray(); do_action('membership_payment_form_' . $_REQUEST['gateway'], $sub, $pricing, $member->ID); } } else { if ($member->on_sub($subscription)) { $sub = $factory->get_subscription($subscription); // Get the coupon $coupon = membership_get_current_coupon(); ?> <div id='membership-wrapper'> <legend><?php echo __('Sign up for', 'membership'), " ", $sub->sub_name(); ?> </legend> <div class="alert"> <?php printf(__('You currently have a subscription for the %s subscription. If you wish to sign up a different subscription then you can do so below.', 'membership'), '<strong>' . $sub->sub_name() . '</strong>'); ?> </div> <table class='purchasetable'><?php $subs = $this->get_subscriptions();
/** * Hook to add custom transaction status. * This is called by the MS_Factory * * @since 1.0.0 */ public function after_load() { parent::after_load(); $this->group = 'Pronamic'; $this->manual_payment = true; $this->pro_rate = true; $this->mode = 'live'; }
function handle_gateways_panel() { global $action, $page; wp_reset_vars(array('action', 'page')); $gateway = filter_input(INPUT_GET, 'gateway'); if ($gateway) { switch (addslashes($action)) { case 'edit': $gateway = Membership_Gateway::get_gateway($gateway); if ($gateway) { $gateway->settings(); return; // so we don't show the list below } break; case 'transactions': $gateway = Membership_Gateway::get_gateway($gateway); if ($gateway) { $gateway->transactions(); return; // so we don't show the list below } break; } } $messages = array(); $messages[1] = __('Gateway updated.', 'membership'); $messages[2] = __('Gateway not updated.', 'membership'); $messages[3] = __('Gateway activated.', 'membership'); $messages[4] = __('Gateway not activated.', 'membership'); $messages[5] = __('Gateway deactivated.', 'membership'); $messages[6] = __('Gateway not deactivated.', 'membership'); $messages[7] = __('Gateway activation toggled.', 'membership'); $messages[8] = __('Only Paypal and Free Subscriptions gateway available. <a class="m-pro-update" href="http://premium.wpmudev.org/project/membership/">Upgrade to activate this Gateway »</a>', 'membership'); ?> <div class='wrap'> <div class="icon32" id="icon-plugins"><br></div> <h2><?php _e('Edit Gateways', 'membership'); ?> </h2> <?php if (isset($_GET['msg'])) { echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>'; $_SERVER['REQUEST_URI'] = esc_url_raw(remove_query_arg(array('message'), $_SERVER['REQUEST_URI'])); } if ($this->show_user_help($page)) { ?> <div class='screenhelpheader'> <a href="admin.php?page=<?php echo $page; ?> &action=removeheader" class="welcome-panel-close"><?php _e('Dismiss', 'membership'); ?> </a> <?php ob_start(); include_once membership_dir('membershipincludes/help/header.gateways.php'); echo ob_get_clean(); ?> </div> <?php } ?> <form method="get" action="?page=<?php echo esc_attr($page); ?> " id="posts-filter"> <input type='hidden' name='page' value='<?php echo esc_attr($page); ?> ' /> <div class="tablenav"> <div class="alignleft actions"> <select name="action"> <option selected="selected" value=""><?php _e('Bulk Actions', 'membership'); ?> </option> <option value="toggle"><?php _e('Toggle activation', 'membership'); ?> </option> </select> <input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php _e('Apply', 'membership'); ?> "> </div> <div class="alignright actions"></div> <br class="clear"> </div> <div class="clear"></div> <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('bulk-gateways'); $columns = array("name" => __('Gateway Name', 'membership'), "active" => __('Active', 'membership')); $columns = apply_filters('membership_gatewaycolumns', $columns); $gateways = get_membership_gateways(); $active = get_option('membership_activated_gateways', array()); ?> <table cellspacing="0" class="widefat fixed"> <thead> <tr> <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> <?php foreach ($columns as $key => $col) { ?> <th style="" class="manage-column column-<?php echo $key; ?> " id="<?php echo $key; ?> " scope="col"><?php echo $col; ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th> <?php reset($columns); foreach ($columns as $key => $col) { ?> <th style="" class="manage-column column-<?php echo $key; ?> " id="<?php echo $key; ?> " scope="col"><?php echo $col; ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php if ($gateways) { foreach ($gateways as $key => $gateway) { $default_headers = array('Name' => 'Addon Name', 'Author' => 'Author', 'Description' => 'Description', 'AuthorURI' => 'Author URI', 'gateway_id' => 'Gateway ID'); $gateway_data = get_file_data(membership_dir('membershipincludes/gateways/' . $gateway), $default_headers, 'plugin'); if (empty($gateway_data['Name'])) { continue; } ?> <tr valign="middle" class="alternate" id="gateway-<?php echo $gateway_data['gateway_id']; ?> "> <th class="check-column" scope="row"><input type="checkbox" value="<?php echo esc_attr($gateway_data['gateway_id']); ?> " name="gatewaycheck[]"></th> <td class="column-name"> <strong><?php echo esc_html($gateway_data['Name']); ?> </strong> <?php if (!empty($gateway_data['Description'])) { ?> <br/><?php echo esc_html($gateway_data['Description']); } $actions = array(); if (in_array($gateway_data['gateway_id'], $active)) { $actions['edit'] = "<span class='edit'><a href='?page=" . $page . "&action=edit&gateway=" . $gateway_data['gateway_id'] . "'>" . __('Settings', 'membership') . "</a></span>"; $actions['transactions'] = "<span class='edit'><a href='?page=" . $page . "&action=transactions&gateway=" . $gateway_data['gateway_id'] . "'>" . __('View transactions', 'membership') . "</a></span>"; $actions['toggle'] = "<span class='edit deactivate'><a href='" . wp_nonce_url("?page=" . $page . "&action=deactivate&gateway=" . $gateway_data['gateway_id'] . "", 'toggle-gateway-' . $gateway_data['gateway_id']) . "'>" . __('Deactivate', 'membership') . "</a></span>"; } else { $actions['toggle'] = "<span class='edit activate'><a href='" . wp_nonce_url("?page=" . $page . "&action=activate&gateway=" . $gateway_data['gateway_id'] . "", 'toggle-gateway-' . $gateway_data['gateway_id']) . "'>" . __('Activate', 'membership') . "</a></span>"; } ?> <br><div class="row-actions"><?php echo implode(" | ", $actions); ?> </div> </td> <td class="column-active"> <?php if (in_array($gateway_data['gateway_id'], $active)) { echo "<span\t class='membershipactivestatus'>" . __('Active', 'membership') . "</span>"; } else { echo "<span\t class='membershipinactivestatus'>" . __('Inactive', 'membership') . "</span>"; } ?> </td> </tr> <?php } } else { $columncount = count($columns) + 1; ?> <tr valign="middle" class="alternate" > <td colspan="<?php echo $columncount; ?> " scope="row"><?php _e('No Gateways where found for this install.', 'membership'); ?> </td> </tr> <?php } ?> </tbody> </table> <div class="tablenav"> <div class="alignleft actions"> <select name="action2"> <option selected="selected" value=""><?php _e('Bulk Actions'); ?> </option> <option value="toggle"><?php _e('Toggle activation'); ?> </option> </select> <input type="submit" class="button-secondary action" id="doaction2" name="doaction2" value="<?php _e('Apply', 'membership'); ?> "> </div> <div class="alignright actions"></div> <br class="clear"> </div> </form> </div> <!-- wrap --> <?php }
$timestamp = $response['currentTime']; // Update to work with latest 3.5.x Membership version // and keep backward compatibility with older versions as well if (!class_exists('Membership_Gateway')) $this->record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $response['id'], $response['status'], $note); else $this->_record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $response['id'], $response['status'], $note); do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $response['id']); break; */ default: // case: various error cases break; } } else { // Did not find expected POST variables. Possible access attempt from a non BitPay site. header('Status: 404 Not Found'); echo 'Error: Missing POST variables. Identification is not possible.'; exit; } } } // Update to work with latest 3.5.x Membership version // and keep backward compatibility with older versions as well if (!class_exists('Membership_Gateway')) { M_register_gateway('bitpay', 'bitpay'); } else { Membership_Gateway::register_gateway('bitpay', 'bitpay'); }
<?php /* Addon Name: Authorize.net gateway Description: The Authorize.net payment gateway Author: Incsub Author URI: http://premium.wpmudev.org Gateway ID: authorize */ Membership_Gateway::register_gateway('authorize', 'Membership_Gateway_Authorize');
/** * Constructor. * * @since 3.5 * * @access public */ public function __construct() { parent::__construct(); $this->_add_action('M_gateways_settings_' . $this->gateway, 'render_settings'); $this->_add_action('membership_purchase_button', 'render_subscribe_button', 10, 3); $this->_add_action('membership_payment_form_' . $this->gateway, 'render_payment_form', 10, 3); $this->_add_action('membership_expire_subscription', 'cancel_subscription_transactions', 10, 3); $this->_add_action('membership_drop_subscription', 'drop_subscription_transactions', 10, 3); $this->_add_action('membership_move_subscription', 'capture_next_transaction', 10, 6); $this->_add_filter('membership_unsubscribe_subscription', 'process_unsubscribe_subscription', 10, 3); $this->_add_action('wp_enqueue_scripts', 'enqueue_scripts'); $this->_add_action('wp_login', 'propagate_ssl_cookie', 10, 2); $this->_add_action('wpmu_delete_user', 'save_cim_profile_id'); $this->_add_action('delete_user', 'save_cim_profile_id'); $this->_add_action('deleted_user', 'delete_cim_profile'); $this->_add_ajax_action('processpurchase_' . $this->gateway, 'process_purchase', true, true); $this->_add_ajax_action('purchaseform', 'render_popover_payment_form'); }