$pricing = $sub->get_pricingarray(); if ($pricing) { do_action('membership_purchase_button', $sub, $pricing, $member->ID); } ?> </td> </tr> <?php } ?> </table> </div> <?php } else { $sub = new M_Subscription($subscription); $pricing = $sub->get_pricingarray(); $coupon_code = membership_get_current_coupon(); if (!empty($pricing) && !empty($coupon_code)) { $pricing = $sub->apply_coupon_pricing($coupon_code, $pricing); } ?> <div class='header' style='width: 750px'> <h1><?php echo __('Sign up for', 'membership') . " " . $sub->sub_name(); ?> </h1> </div> <div class='fullwidth'> <p><?php echo __('Please check the details of your subscription below and click on the relevant button to complete the subscription.', 'membership');
function handle_coupons_panel() { global $action, $page, $M_options; wp_reset_vars(array('action', 'page')); switch (addslashes($action)) { case 'edit': if (isset($_GET['coupon_id'])) { $this->handle_coupon_edit_form((int) $_GET['coupon_id']); } else { $this->handle_coupon_edit_form(); } return; // so we don't show the list below break; } $messages = array(); $messages[1] = __('Coupon added.', 'membership'); $messages[2] = __('Coupon not added.', 'membership'); $messages[3] = __('Coupon updated.', 'membership'); $messages[4] = __('Coupon not updated.', 'membership'); $messages[5] = __('Coupon deleted.', 'membership'); $messages[6] = __('Coupon not deleted.', 'membership'); $messages[7] = __('Coupons deleted.', 'membership'); ?> <div class='wrap'> <div class="icon32" id="icon-link-manager"><br></div> <h2><?php _e('Edit Coupons', 'membership'); ?> <a class="add-new-h2" href="admin.php?page=<?php echo $page; ?> &action=edit&coupon="><?php _e('Add New', 'membership'); ?> </a></h2> <?php if (isset($_GET['msg'])) { echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>'; $_SERVER['REQUEST_URI'] = 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.coupons.php'); echo ob_get_clean(); ?> </div> <?php } $coupons = $this->get_coupons(); $posts_columns = array('code' => __('Coupon Code', 'membership'), 'discount' => __('Discount', 'membership'), 'start' => __('Start Date', 'membership'), 'end' => __('Expire Date', 'membership'), 'sub' => __('Subscription', 'membership'), 'used' => __('Used', 'membership'), 'remaining' => __('Remaining Uses', 'membership')); ?> <form method="get" action="?page=<?php echo esc_attr($page); ?> "> <input type="hidden" name="page" value="<?php echo esc_attr($page); ?> " /> <?php wp_nonce_field('bulk-coupon-actions'); ?> <div class="tablenav"> <div class="alignleft actions"> <select name="action"> <option selected="selected" value=""><?php _e('Bulk Actions', 'membership'); ?> </option> <option value="bulk-delete"><?php _e('Delete Coupon', 'membership'); ?> </option> </select> <input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php _e('Apply', 'membership'); ?> "> </div> </div> <table width="100%" cellpadding="3" cellspacing="3" class="widefat fixed"> <thead> <tr> <th scope="col" class="check-column"><input type="checkbox" /></th> <?php foreach ($posts_columns as $column_id => $column_display_name) { $col_url = $column_display_name; ?> <th scope="col"><?php echo $col_url; ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <th scope="col" class="check-column"><input type="checkbox" /></th> <?php foreach ($posts_columns as $column_id => $column_display_name) { $col_url = $column_display_name; ?> <th scope="col"><?php echo $col_url; ?> </th> <?php } ?> </tr> </tfoot> <tbody id="the-list"> <?php if (!empty($coupons)) { $bgcolor = isset($class) ? $class : ''; foreach ($coupons as $key => $coupon) { $class = isset($class) && 'alternate' == $class ? '' : 'alternate'; //assign classes based on coupon availability //$class = ($this->check_coupon($coupon_code)) ? $class . ' coupon-active' : $class . ' coupon-inactive'; echo '<tr class="' . $class . ' blog-row" style="vertical-align: top;"><th scope="row" class="check-column" valign="top"><input type="checkbox" name="coupons_checks[]"" value="' . $coupon->id . '" /></th>'; foreach ($posts_columns as $column_name => $column_display_name) { switch ($column_name) { case 'code': ?> <td scope="row"> <?php echo $coupon->couponcode; $actions = array(); //$actions['id'] = "<strong>" . __('ID : ', 'membership') . $level->id . "</strong>"; $actions['edit'] = "<span class='edit'><a href='?page=" . $page . "&action=edit&coupon_id=" . $coupon->id . "'>" . __('Edit', 'membership') . "</a></span>"; $actions['delete'] = "<span class='delete'><a href='" . wp_nonce_url("?page=" . $page . "&action=delete&coupon_id=" . $coupon->id . "", 'delete-coupon_' . $coupon->id) . "'>" . __('Delete', 'membership') . "</a></span>"; ?> <br><div class="row-actions"><?php echo implode(" | ", $actions); ?> </div> </td> <?php break; case 'discount': ?> <td scope="row"> <?php if ($coupon->discount_type == 'pct') { echo $coupon->discount . '%'; } else { if ($coupon->discount_type == 'amt') { echo $coupon->discount_currency . ' ' . number_format_i18n($coupon->discount, 2); } } ?> </td> <?php break; case 'start': ?> <td scope="row"> <?php echo mysql2date(get_option('date_format'), $coupon->coupon_startdate); ?> </td> <?php break; case 'end': ?> <td scope="row"> <?php if (!empty($coupon->coupon_enddate)) { echo mysql2date(get_option('date_format'), $coupon->coupon_enddate); } else { _e('No End', 'membership'); } ?> </td> <?php break; case 'sub': ?> <td scope="row"> <?php if ($coupon->coupon_sub_id != 0) { $sub = new M_Subscription($coupon->coupon_sub_id); echo $sub->sub_name(); } else { _e('Any Subscription', 'membership'); } ?> </td> <?php break; case 'used': ?> <td scope="row"> <?php echo number_format_i18n($coupon->coupon_used); ?> </td> <?php break; case 'remaining': ?> <td scope="row"> <?php if ($coupon->coupon_uses > 0) { echo number_format_i18n(intval($coupon->coupon_uses) - intval($coupon->coupon_used)); } else { _e('Unlimited', 'membership'); } ?> </td> <?php break; } } ?> </tr> <?php } } else { ?> <tr> <td colspan="8"><?php _e('No coupons yet.', 'membership'); ?> </td> </tr> <?php } // end if coupons ?> </tbody> </table> </form> <?php }
function move_subscription($fromsub_id, $tosub_id, $tolevel_id, $to_order) { if (!apply_filters('pre_membership_move_subscription', true, $fromsub_id, $tosub_id, $tolevel_id, $to_order, $this->ID)) { return false; } if (!$this->on_level($tolevel_id, true) && $this->on_sub($fromsub_id)) { // Get the level for this subscription before removing it $fromlevel_id = $this->get_level_for_sub($fromsub_id); // grab the level information for this position $subscription = new M_Subscription($tosub_id); $level = $subscription->get_level_at($tolevel_id, $to_order); if ($level) { $start = current_time('mysql'); switch ($level->level_period_unit) { case 'd': $period = 'days'; break; case 'w': $period = 'weeks'; break; case 'm': $period = 'months'; break; case 'y': $period = 'years'; break; default: $period = 'days'; break; } $expires = gmdate('Y-m-d H:i:s', strtotime('+' . $level->level_period . ' ' . $period, strtotime($start))); // Update users start and expiry meta delete_user_meta($this->ID, 'start_current_' . $fromsub_id); delete_user_meta($this->ID, 'expire_current_' . $fromsub_id); delete_user_meta($this->ID, 'sent_msgs_' . $fromsub_id); // get the gateway and then remove it from the usermeta $gateway = get_user_meta($this->ID, 'using_gateway_' . $fromsub_id, true); delete_user_meta($this->ID, 'using_gateway_' . $fromsub_id); update_user_meta($this->ID, 'start_current_' . $tosub_id, strtotime($start)); update_user_meta($this->ID, 'expire_current_' . $tosub_id, strtotime($expires)); update_user_meta($this->ID, 'using_gateway_' . $tosub_id, $gateway); $this->db->update($this->membership_relationships, array('sub_id' => $tosub_id, 'level_id' => $tolevel_id, 'updateddate' => $start, 'expirydate' => $expires, 'order_instance' => $level->level_order), array('sub_id' => $fromsub_id, 'user_id' => $this->ID)); do_action('membership_move_subscription', $fromsub_id, $fromlevel_id, $tosub_id, $tolevel_id, $to_order, $this->ID); } } }
function membership_record_sub_move($fromsub_id, $fromlevel_id, $tosub_id, $tolevel_id, $to_order, $user_id) { global $wpdb; $table = membership_db_prefix($wpdb, 'membership_news'); // Get the information $user = new WP_User($user_id); $fromsub = new M_Subscription($fromsub_id); $tosub = new M_Subscription($tosub_id); $fromlevel = new M_Level($fromlevel_id); $level = new M_Level($tolevel_id); $message = sprintf(__('<strong>%s</strong> has moved from level <strong>%s</strong> on subscription <strong>%s</strong> to level <strong>%s</strong> on subscription <strong>%s</strong>', 'membership'), $user->display_name, $fromlevel->level_title(), $fromsub->sub_name(), $level->level_title(), $tosub->sub_name()); $wpdb->insert($table, array('newsitem' => $message, 'newsdate' => current_time('mysql'))); }
function do_subscriptionprice_shortcode($atts, $content = null, $code = "") { global $wp_query; $defaults = array("holder" => '', "holderclass" => '', "item" => '', "itemclass" => '', "postfix" => '', "prefix" => '', "wrapwith" => '', "wrapwithclass" => '', "subscription" => '', "level" => 1); extract(shortcode_atts($defaults, $atts)); $level = (int) $level; if (empty($subscription)) { return ''; } $html = ''; if (!empty($holder)) { $html .= "<{$holder} class='{$holderclass}'>"; } if (!empty($item)) { $html .= "<{$item} class='{$itemclass}'>"; } $html .= $prefix; // The title if (!empty($wrapwith)) { $html .= "<{$wrapwith} class='{$wrapwithclass}'>"; } $sub = new M_Subscription((int) $subscription); $first = $sub->get_level_at_position($level); if (!empty($first)) { $price = $first->level_price; if ($price == 0) { $price = "Free"; } else { $M_options = get_option('membership_options', array()); switch ($M_options['paymentcurrency']) { case "USD": $price = "\$" . $price; break; case "GBP": $price = "£" . $price; break; case "EUR": $price = "€" . $price; break; default: $price = apply_filters('membership_currency_symbol_' . $M_options['paymentcurrency'], $M_options['paymentcurrency']) . $price; } } } $html .= $price; if (!empty($wrapwith)) { $html .= "</{$wrapwith}>"; } $html .= $postfix; if (!empty($item)) { $html .= "</{$item}>"; } if (!empty($holder)) { $html .= "</{$holder}>"; } return $html; }
function show_subscription_ping_information($sub_id) { // Get all the pings $pings = $this->get_pings(); // Get the currentlt set ping for each level $subscription = new M_Subscription($sub_id); $joinping = $subscription->get_meta('joining_ping', ''); $leaveping = $subscription->get_meta('leaving_ping', ''); ?> <h3><?php _e('Subscription Pings', 'membership'); ?> </h3> <p class='description'><?php _e('If you want any pings to be sent when a member joins and/or leaves this subscription then set them below.', 'membership'); ?> </p> <div class='sub-details'> <label for='joiningping'><?php _e('Joining Ping', 'membership'); ?> </label> <select name='joiningping'> <option value='' <?php selected($joinping, ''); ?> ><?php _e('None', 'membership'); ?> </option> <?php if (!empty($pings)) { foreach ($pings as $ping) { ?> <option value='<?php echo $ping->id; ?> ' <?php selected($joinping, $ping->id); ?> ><?php echo stripslashes($ping->pingname); ?> </option> <?php } } ?> </select><br/> <label for='leavingping'><?php _e('Leaving Ping', 'membership'); ?> </label> <select name='leavingping'> <option value='' <?php selected($leaveping, ''); ?> ><?php _e('None', 'membership'); ?> </option> <?php if (!empty($pings)) { foreach ($pings as $ping) { ?> <option value='<?php echo $ping->id; ?> ' <?php selected($leaveping, $ping->id); ?> ><?php echo stripslashes($ping->pingname); ?> </option> <?php } } ?> </select> </div> <?php }
} </style> <div id='membership-wrapper'> <div class="alert"> <?php echo __('You have already a subscription'); ?> </div> <a class="logoutbutton" href="<?php echo wp_logout_url(); ?> " title="Logout">Logout</a> </div> <?php } else { $sub = new M_Subscription($subscription); // Get the coupon $coupon = membership_get_current_coupon(); // Build the pricing array $pricing = $sub->get_pricingarray(); if (!empty($pricing) && !empty($coupon) && method_exists($coupon, 'valid_for_subscription') && $coupon->valid_for_subscription($sub->id)) { $pricing = $coupon->apply_coupon_pricing($pricing); } ?> <style type="text/css"> .pricescolumn { float: left; width: 100%; } .radio-outerbox { margin: 0 auto;
<p class="help-block"><?php _e('We have the following subscriptions available for our site. To join, simply click on the <strong>Sign Up</strong> button and then complete the registration details.', 'membership'); ?> </p> <form class="form-membership" action="<?php echo get_permalink(); ?> " method="post"> <div class="priceboxes"> <?php do_action('membership_subscription_form_before_subscriptions'); $subs = $this->get_subscriptions(); $subs = apply_filters('membership_override_subscriptions', $subs); foreach ((array) $subs as $key => $sub) { $subscription = new M_Subscription($sub->id); ?> <div class="pricebox subscriptionbox" id='subscriptionbox-<?php echo $subscription->id; ?> '> <div class="topbar"><span class='title'><?php echo $subscription->sub_name(); ?> </span></div> <div class="pricedetails"><?php echo $subscription->sub_description(); ?> </div> <div class="bottombar"><span class='price'><?php echo $subscription->sub_pricetext();
function mytransactions($type = 'past') { if (empty($_GET['paged'])) { $paged = 1; } else { $paged = (int) $_GET['paged']; } $startat = ($paged - 1) * 50; $transactions = $this->get_transactions($type, $startat, 50); $total = $this->get_total(); $columns = array(); $columns['subscription'] = __('Subscription', 'membership'); $columns['user'] = __('User', 'membership'); $columns['date'] = __('Date', 'membership'); $columns['amount'] = __('Amount', 'membership'); $columns['transid'] = __('Transaction id', 'membership'); $trans_navigation = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'total' => ceil($total / 50), 'current' => $paged)); echo '<div class="tablenav">'; if ($trans_navigation) { echo "<div class='tablenav-pages'>{$trans_navigation}</div>"; } echo '</div>'; ?> <table cellspacing="0" class="widefat fixed"> <thead> <tr> <?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> <?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 ($transactions) { foreach ($transactions as $key => $transaction) { ?> <tr valign="middle" class="alternate"> <td class="column-subscription"> <?php if (class_exists('M_Subscription')) { $subscription = new M_Subscription($transaction->transaction_subscription_ID); echo $subscription->sub_name(); } else { echo __('Subscription not found', 'membership'); } ?> </td> <td class="column-user"> <?php if (class_exists('M_Membership')) { $member = new M_Membership($transaction->transaction_user_ID); echo $member->user_login; } else { echo __('User not found', 'membership'); } ?> </td> <td class="column-date"> <?php echo mysql2date("d-m-Y", $transaction->transaction_stamp); ?> </td> <td class="column-amount"> <?php $amount = $transaction->transaction_total_amount / 100; echo $transaction->transaction_currency; echo " " . number_format($amount, 2, '.', ','); ?> </td> <td class="column-transid"> <?php if (!empty($transaction->transaction_paypal_ID)) { echo $transaction->transaction_paypal_ID; } else { echo __('None yet', 'membership'); } ?> </td> </tr> <?php } } else { $columncount = count($columns); ?> <tr valign="middle" class="alternate" > <td colspan="<?php echo $columncount; ?> " scope="row"><?php _e('No Transactions have been found, patience is a virtue.', 'membership'); ?> </td> </tr> <?php } ?> </tbody> </table> <?php }
function process_dripped_wizard_step() { if (isset($_POST['levelname'])) { // Create an initial subscription $sub_id = $this->create_subscription(__('Dripped Subscription', 'membership')); $sub = new M_Subscription($sub_id); $sub->toggleactivation(); $sub->togglepublic(); foreach ($_POST['levelname'] as $key => $value) { if (empty($value)) { $value = __('Level ', 'membership') . ((int) $key + 1); } // Create a level $level_id = $this->create_level($value); // Add the level to the subscription $this->add_level_to_subscription($level_id, $sub_id, 'finite'); // Activate and make public the levels and subscriptions $level = new M_Level($level_id); $level->toggleactivation(); } } // Create a visitor level and set it in the options if (isset($_POST['creatavisitorlevel']) && $_POST['creatavisitorlevel'] == 'yes') { $level_id = $this->create_level(__('Visitors', 'membership')); $level = new M_Level($level_id); $level->toggleactivation(); if (defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { if (function_exists('get_blog_option')) { if (function_exists('switch_to_blog')) { switch_to_blog(MEMBERSHIP_GLOBAL_MAINSITE); } $M_options = get_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', array()); } else { $M_options = get_option('membership_options', array()); } } else { $M_options = get_option('membership_options', array()); } $M_options['strangerlevel'] = (int) $level_id; if (defined('MEMBERSHIP_GLOBAL_TABLES') && MEMBERSHIP_GLOBAL_TABLES === true) { if (function_exists('update_blog_option')) { update_blog_option(MEMBERSHIP_GLOBAL_MAINSITE, 'membership_options', $M_options); } else { update_option('membership_options', $M_options); } } else { update_option('membership_options', $M_options); } } // Activate the relevant gateway if it's set if (isset($_POST['wizardgateway'])) { $active = get_option('membership_activated_gateways', array()); if (!in_array($_POST['wizardgateway'], $active)) { $active[] = $_POST['wizardgateway']; update_option('membership_activated_gateways', array_unique($active)); } } }
</div> </div> <!-- renew-form --> <?php } } else { // No next level so nothing to do - the subscription will end at the end of this one. } if ($upgradedat <= strtotime('-' . $period . ' days')) { // Show upgrades $upgradesubs = $this->get_subscriptions(); $upgradesubs = apply_filters('membership_override_upgrade_subscriptions', $upgradesubs); foreach ((array) $upgradesubs as $key => $upgradesub) { if ($upgradesub->id == $rel->sub_id) { // Don't want to show our current subscription as we will display this above. } else { $subscription = new M_Subscription($upgradesub->id); ?> <div class="subscription"> <div class="description"> <h3><strong><?php _e('Move to subscription : ', 'membership'); ?> </strong><?php echo $subscription->sub_name(); ?> </h3> <p><?php echo $subscription->sub_description(); ?> </p> </div>
function send_ping($sub_id = false, $level_id = false, $user_id = false) { $this->ping = $this->get_ping(); if (!class_exists('WP_Http')) { include_once ABSPATH . WPINC . '/class-http.php'; } $pingdata = $this->pingconstants; if (empty($user_id)) { $user = wp_get_current_user(); $member = new M_Membership($user->ID); } else { $member = new M_Membership($user_id); } foreach ($pingdata as $key => $value) { switch ($key) { case '%blogname%': $pingdata[$key] = get_option('blogname'); break; case '%blogurl%': $pingdata[$key] = get_option('home'); break; case '%username%': $pingdata[$key] = $member->user_login; break; case '%usernicename%': $pingdata[$key] = $member->user_nicename; break; case '%useremail%': $pingdata[$key] = $member->user_email; break; case '%userid%': $pingdata[$key] = $member->ID; break; case '%networkname%': $pingdata[$key] = get_site_option('site_name'); break; case '%networkurl%': $pingdata[$key] = get_site_option('siteurl'); break; case '%subscriptionname%': if (!$sub_id) { $ids = $member->get_subscription_ids(); if (!empty($ids)) { $sub_id = $ids[0]; } } if (!empty($sub_id)) { $sub = new M_Subscription($sub_id); $pingdata[$key] = $sub->sub_name(); } else { $pingdata[$key] = ''; } break; case '%levelname%': if (!$level_id) { $ids = $member->get_level_ids(); if (!empty($ids)) { $levels = $ids[0]; } } if (!empty($levels->level_id)) { $level = new M_Level($levels->level_id); $pingdata[$key] = $level->level_title(); } else { $pingdata[$key] = ''; } break; case '%timestamp%': $pingdata[$key] = time(); break; default: $pingdata[$key] = apply_filter('membership_pingfield_' . $key, ''); break; } } $url = $this->ping->pingurl; // Globally replace the values in the ping and then make it into an array to send $pingmessage = str_replace(array_keys($pingdata), array_values($pingdata), $this->ping->pinginfo); $pingmessage = array_map('trim', explode("\n", $pingmessage)); // make the ping message into a sendable bit of text $pingtosend = array(); foreach ($pingmessage as $key => $value) { $temp = explode("=", $value); $pingtosend[$temp[0]] = $temp[1]; } // Send the request if (class_exists('WP_Http')) { $request = new WP_Http(); switch ($this->ping->pingtype) { case 'GET': $url = untrailingslashit($url) . "?"; foreach ($pingtosend as $key => $val) { if (substr($url, -1) != '?') { $url .= "&"; } $url .= $key . "=" . urlencode($val); } $result = $request->request($url, array('method' => 'GET', 'body' => '')); break; case 'POST': $result = $request->request($url, array('method' => 'POST', 'body' => $pingtosend)); break; } /* 'headers': an array of response headers, such as "x-powered-by" => "PHP/5.2.1" 'body': the response string sent by the server, as you would see it with you web browser 'response': an array of HTTP response codes. Typically, you'll want to have array('code'=>200, 'message'=>'OK') 'cookies': an array of cookie information */ $this->add_history($pingtosend, $result); } }
function handle_payment_return() { global $M_options, $M_membership_url; $return = array(); if ($_SERVER['HTTPS'] != 'on') { wp_die(__('You must use HTTPS in order to do this', 'membership')); exit; } $coupon_code = isset($_REQUEST['remove_coupon']) ? '' : $_REQUEST['coupon_code']; if (empty($M_options['paymentcurrency'])) { $M_options['paymentcurrency'] = 'USD'; } $subscription = new M_Subscription($_POST['subscription_id']); $pricing = $subscription->get_pricingarray(); if (!empty($coupon_code)) { $pricing = $subscription->apply_coupon_pricing($coupon_code, $pricing); } $user_id = is_user_logged_in() ? get_current_user_id() : $_POST['user_id']; $user = get_userdata($user_id); $sub_id = $subscription->id; // A basic price or a single subscription if ($pricing) { $timestamp = time(); if (get_option($this->gateway . "_mode", 'sandbox') == 'sandbox') { $endpoint = "https://test.authorize.net/gateway/transact.dll"; } else { $endpoint = "https://secure.authorize.net/gateway/transact.dll"; } $payment = new M_Gateway_Worker_AuthorizeNet_AIM($endpoint, get_option($this->gateway . "_delim_data", 'yes'), get_option($this->gateway . "_delim_char", ','), get_option($this->gateway . "_encap_char", ''), get_option($this->gateway . "_api_user", ''), get_option($this->gateway . "_api_key", ''), get_option($this->gateway . "_mode", 'sandbox') == 'sandbox'); $payment->transaction($_POST['card_num']); $amount = number_format($pricing[0]['amount'], 2); // Billing Info $payment->setParameter("x_card_code", $_POST['card_code']); $payment->setParameter("x_exp_date ", $_POST['exp_month'] . $_POST['exp_year']); $payment->setParameter("x_amount", $amount); // Payment billing information passed to authorize, thanks to Kevin L. for spotting this. $payment->setParameter("x_first_name", $_POST['first_name']); $payment->setParameter("x_last_name", $_POST['last_name']); $payment->setParameter("x_address", $_POST['address']); $payment->setParameter("x_zip", $_POST['zip']); $payment->setParameter("x_email", is_email($user->user_email) != false ? is_email($user->user_email) : ''); // Order Info $payment->setParameter("x_description", $subscription->sub_name()); $payment->setParameter("x_duplicate_window", 30); // E-mail $payment->setParameter("x_header_email_receipt", get_option($this->gateway . "_header_email_receipt", '')); $payment->setParameter("x_footer_email_receipt", get_option($this->gateway . "_footer_email_receipt", '')); $payment->setParameter("x_email_customer", strtoupper(get_option($this->gateway . "_email_customer", ''))); $payment->setParameter("x_customer_ip", $_SERVER['REMOTE_ADDR']); $payment->process(); if ($payment->isApproved()) { $status = __('Processed', 'membership'); $note = ''; $member = new M_Membership($user_id); if ($member) { if ($member->has_subscription() && $member->on_sub($sub_id)) { remove_action('membership_expire_subscription', 'membership_record_user_expire', 10, 2); remove_action('membership_add_subscription', 'membership_record_user_subscribe', 10, 4); $member->expire_subscription($sub_id); $member->create_subscription($sub_id, $this->gateway); } else { $member->create_subscription($sub_id, $this->gateway); } } // TODO: create switch for handling different authorize aim respone codes $this->record_transaction($user_id, $sub_id, $amount, $M_options['paymentcurrency'], time(), $payment->results[6] == 0 ? 'TESTMODE' : $payment->results[6], $status, $note); do_action('membership_payment_subscr_signup', $user_id, $sub_id); $return['status'] = 'success'; $return['redirect'] = !strpos(home_url, 'https:') ? str_replace('https:', 'http:', M_get_registrationcompleted_permalink()) : M_get_registrationcompleted_permalink(); } else { $return['status'] = 'error'; $return['errors'][] = __('Your payment was declined. Please check all your details or use a different card.', 'membership'); } } else { $return['status'] = 'error'; $return['errors'][] = __('There was an issue determining the price.', 'membership'); } echo json_encode($return); exit; }
function affiliate_membership_add_subscription($m_tosub_id, $m_tolevel_id, $m_to_order, $m_user_id) { global $blog_id, $site_id; //echo "m_tosub_id[". $m_tosub_id ."]<br />"; //echo "m_tolevel_id[". $m_tolevel_id ."]<br />"; //echo "m_to_order[". $m_to_order ."]<br />"; //echo "m_user_id[". $m_user_id ."]<br />"; $default_headers = array('Name' => 'Plugin Name', 'Version' => 'Version'); $membership_plugin_base = 'membership/membershippremium.php'; if (file_exists(WPMU_PLUGIN_DIR . '/' . $membership_plugin_base)) { $membership_plugin_file = WPMU_PLUGIN_DIR . '/' . $membership_plugin_base; } else { if (file_exists(WP_PLUGIN_DIR . '/' . $membership_plugin_base)) { $membership_plugin_file = WP_PLUGIN_DIR . '/' . $membership_plugin_base; } } $plugin_data = get_file_data($membership_plugin_file, $default_headers, 'plugin'); //echo "plugin_data<pre>"; print_r($plugin_data); echo "</pre>"; if (isset($plugin_data['Version'])) { if (version_compare($plugin_data['Version'], '3.4.9.9', '>')) { //echo "Membersip 3.5 or more<br />"; return; } } //$aff = get_user_meta($user_id, 'affiliate_referred_by', true); $affiliate_referred_by = get_user_meta($m_user_id, 'affiliate_referred_by', true); //echo "affiliate_referred_by[". $affiliate_referred_by ."]<br />"; if (empty($affiliate_referred_by)) { return; } //$paid = get_user_meta($user_id, 'affiliate_paid', true); $affiliate_paid = get_user_meta($m_user_id, 'affiliate_paid', true); //echo "affiliate_paid[". $affiliate_paid ."]<br />"; if (defined('AFFILIATE_PAYONCE') && AFFILIATE_PAYONCE == 'yes' && $affiliate_paid == 'yes') { return; } $whole = get_option("membership_whole_payment_" . $m_tosub_id, 0); //echo "whole[". $whole ."]<br />"; $partial = get_option("membership_partial_payment_" . $m_tosub_id, 0); //echo "partial[". $partial ."]<br />"; $type = get_option("membership_payment_type_" . $m_tosub_id, 'actual'); //echo "type[". $type ."]<br />"; //die(); switch ($type) { case 'actual': if (!empty($whole) || !empty($partial)) { $amount = $whole . '.' . $partial; } else { $amount = 0; } break; case 'percentage': // Calculate the charge for this subscription / level / order $sub = new M_Subscription($m_tosub_id); $level = $sub->get_level_at($m_tolevel_id, $m_to_order); if (!empty($level)) { // We have a level so we need to get the charge $percentage = $whole . '.' . $partial; $levelprice = $level->level_price; $floatprice = floatval($levelprice); $floatpercentage = floatval($percentage); if ($floatprice > 0 && $floatpercentage > 0) { // We have a positive value to check against $amount = $floatprice / 100 * $floatpercentage; $amount = round($amount, 2, PHP_ROUND_HALF_DOWN); } else { $amount = 0; } } else { $amount = 0; } break; } //echo "amount[". $amount ."]<br />"; $meta = array('tosub_id' => $m_tosub_id, 'tolevel_id' => $m_tolevel_id, 'to_order' => $m_to_order, 'user_id' => $m_user_id, 'blog_id' => $blog_id, 'site_id' => $site_id, 'current_user_id' => get_current_user_id(), 'REMOTE_URL' => esc_attr($_SERVER['HTTP_REFERER']), 'LOCAL_URL' => (is_ssl() ? 'https://' : 'http://') . esc_attr($_SERVER['HTTP_HOST']) . esc_attr($_SERVER['REQUEST_URI']), 'IP' => isset($_SERVER['HTTP_X_FORWARD_FOR']) ? esc_attr($_SERVER['HTTP_X_FORWARD_FOR']) : esc_attr($_SERVER['REMOTE_ADDR'])); do_action('affiliate_purchase', $affiliate_referred_by, $amount, 'paid:membership', $m_user_id, __('Membership', 'affiliate'), $meta); if (defined('AFFILIATE_PAYONCE') && AFFILIATE_PAYONCE == 'yes') { if (function_exists('update_user_meta')) { update_user_meta($m_user_id, 'affiliate_paid', 'yes'); } else { update_usermeta($m_user_id, 'affiliate_paid', 'yes'); } } }
<h2><?php _e('Step 2. Select a subscription', 'membership'); ?> </h2> <p> <?php _e('Please select a subscription from the options below.', 'membership'); ?> </p> <?php do_action('membership_subscription_form_before_subscriptions', $user_id); $subs = $this->get_subscriptions(); do_action('membership_subscription_form_before_paid_subscriptions', $user_id); $subs = apply_filters('membership_override_subscriptions', $subs); foreach ((array) $subs as $key => $sub) { $subscription = new M_Subscription($sub->id); ?> <div class="subscription"> <div class="description"> <h3><?php echo $subscription->sub_name(); ?> </h3> <p><?php echo $subscription->sub_description(); ?> </p> </div> <?php $pricing = $subscription->get_pricingarray();
function handle_profile_member_page() { ?> <div class='wrap'> <div class="icon32" id="icon-users"><br></div> <h2><?php _e('Membership details', 'membership'); ?> </h2> <?php if (isset($_GET['msg'])) { echo '<div id="message" class="updated fade"><p>' . $messages[(int) $_GET['msg']] . '</p></div>'; $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); } if (!current_user_is_member()) { // Not a member so show the message and signup forms ?> <div class='nonmembermessage'> <h3><?php _e('Not called yet', 'membership'); ?> </h3> <?php _e('Not called yet', 'membership'); ?> </div> <div class='signups'> <h3><?php _e('Select a subscription', 'membership'); ?> </h3> <p> <?php _e('Please select a subscription from the options below.', 'membership'); ?> </p> <?php do_action('membership_subscription_form_before_subscriptions', $user_id); $subs = $this->get_subscriptions(); do_action('membership_subscription_form_before_paid_subscriptions', $user_id); foreach ((array) $subs as $key => $sub) { $subscription = new M_Subscription($sub->id); ?> <div class="subscription"> <div class="description"> <h3><?php echo $subscription->sub_name(); ?> </h3> <p><?php echo $subscription->sub_description(); ?> </p> </div> <?php $pricing = $subscription->get_pricingarray(); if ($pricing) { ?> <div class='priceforms'> <?php do_action('membership_purchase_button', $subscription, $pricing, $user_id); ?> </div> <?php } ?> </div> <?php } do_action('membership_subscription_form_after_paid_subscriptions', $user_id); do_action('membership_subscription_form_after_subscriptions', $user_id); ?> </div> <?php } else { if (current_user_has_subscription()) { // User has a subscription already. Display the details - and an action to enable upgrading / not upgrading to take place. ?> <div class='nonmembermessage'> <h3><?php _e('Not called yet', 'membership'); ?> </h3> <?php _e('Not called yet', 'membership'); ?> </div> <?php } } ?> </div> <!-- wrap --> <?php }