コード例 #1
0
 function popover_register_process()
 {
     global $M_options;
     //include_once(ABSPATH . WPINC . '/registration.php');
     $error = new WP_Error();
     if (!wp_verify_nonce($_POST['nonce'], 'membership_register')) {
         $error->add('invalid', __('Invalid form submission.', 'membership'));
     }
     if (!validate_username($_POST['user_login'])) {
         $error->add('usernamenotvalid', __('The username is not valid, sorry.', 'membership'));
     }
     if (username_exists(sanitize_user($_POST['user_login']))) {
         $error->add('usernameexists', __('That username is already taken, sorry.', 'membership'));
     }
     if (!is_email($_POST['email'])) {
         $error->add('emailnotvalid', __('The email address is not valid, sorry.', 'membership'));
     }
     if (email_exists($_POST['email'])) {
         $error->add('emailexists', __('That email address is already taken, sorry.', 'membership'));
     }
     $error = apply_filters('membership_subscription_form_before_registration_process', $error);
     if (is_wp_error($error)) {
         $anyerrors = $error->get_error_messages();
     } else {
         $anyerrors = array();
     }
     if (empty($anyerrors)) {
         // Pre - error reporting check for final add user
         $user_id = wp_create_user(sanitize_user($_POST['user_login']), $_POST['password'], $_POST['email']);
         if (is_wp_error($user_id) && method_exists($user_id, 'get_error_message')) {
             $error->add('userid', $user_id->get_error_message());
         } else {
             $member = new M_Membership($user_id);
             if (defined('MEMBERSHIP_DEACTIVATE_USER_ON_REGISTRATION') && MEMBERSHIP_DEACTIVATE_USER_ON_REGISTRATION == true) {
                 $member->deactivate();
             } else {
                 $creds = array('user_login' => $_POST['user_login'], 'user_password' => $_POST['password'], 'remember' => true);
                 $is_ssl = isset($_SERVER['https']) && strtolower($_SERVER['https']) == 'on' ? true : false;
                 $user = wp_signon($creds, $is_ssl);
                 if (is_wp_error($user) && method_exists($user, 'get_error_message')) {
                     $error->add('userlogin', $user->get_error_message());
                 } else {
                     // Set the current user up
                     wp_set_current_user($user_id);
                 }
             }
             if (has_action('membership_susbcription_form_registration_notification')) {
                 do_action('membership_susbcription_form_registration_notification', $user_id, $_POST['password']);
             } else {
                 /*wp_new_user_notification($user_id, $_POST['password']);*/
             }
             do_action('membership_subscription_form_registration_process', $error, $user_id);
         }
     } else {
         do_action('membership_subscription_form_registration_process', $error, 0);
     }
     $anyerrors = $error->get_error_code();
     if (is_wp_error($error) && !empty($anyerrors)) {
         // we have an error - output
         $messages = $error->get_error_messages();
         //sendback error
         echo json_encode(array('errormsg' => $messages[0]));
     } else {
         // everything seems fine (so far), so we have our queued user so let's
         // move to picking a subscription - so send back the form.
         echo $this->popover_sendpayment_form($user_id);
     }
     exit;
 }
コード例 #2
0
 function signup_free_subscription($content, $error)
 {
     if (isset($_POST['custom'])) {
         list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
     }
     // create_subscription
     $member = new M_Membership($user_id);
     if ($member) {
         $member->create_subscription($sub_id, $this->gateway);
     }
     do_action('membership_payment_subscr_signup', $user_id, $sub_id);
     $content .= '<div id="reg-form">';
     // because we can't have an enclosing form for this part
     $content .= '<div class="formleft">';
     $message = get_option($this->gateway . "_completed_message", $this->defaultmessage);
     $content .= stripslashes($message);
     $content .= '</div>';
     $content .= "</div>";
     $content = apply_filters('membership_subscriptionform_signedup', $content, $user_id, $sub_id);
     return $content;
 }
コード例 #3
0
 function check_for_membership_pages($posts)
 {
     global $M_options;
     if (count($posts) == 1) {
         // We have only the one post, so check if it's one of our pages
         $post = $posts[0];
         if ($post->post_type == 'page') {
             if ($post->ID == $M_options['registration_page']) {
                 // check if page contains a shortcode
                 if (strstr($post->post_content, '[subscriptionform]') !== false) {
                     // There is content in there with the shortcode so just return it
                     return $posts;
                 } else {
                     // registration page found - add in the styles
                     if (!current_theme_supports('membership_subscription_form')) {
                         wp_enqueue_style('subscriptionformcss', membership_url('membershipincludes/css/subscriptionform.css'));
                         wp_enqueue_style('publicformscss', membership_url('membershipincludes/css/publicforms.css'));
                         wp_enqueue_style('buttoncss', membership_url('membershipincludes/css/buttons.css'));
                         if ($M_options['formtype'] == 'new') {
                             // pop up registration form
                             wp_enqueue_style('fancyboxcss', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.css'));
                             wp_enqueue_script('fancyboxjs', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.pack.js'), array('jquery'), false, true);
                             wp_enqueue_script('popupmemjs', membership_url('membershipincludes/js/popupregistration.js'), array('jquery'), false, true);
                             wp_enqueue_style('popupmemcss', membership_url('membershipincludes/css/popupregistration.css'));
                             wp_localize_script('popupmemjs', 'membership', array('ajaxurl' => admin_url('admin-ajax.php'), 'registernonce' => wp_create_nonce('membership_register'), 'loginnonce' => wp_create_nonce('membership_login'), 'regproblem' => __('Problem with registration.', 'membership'), 'logpropblem' => __('Problem with Login.', 'membership'), 'regmissing' => __('Please ensure you have completed all the fields', 'membership'), 'regnomatch' => __('Please ensure passwords match', 'membership'), 'logmissing' => __('Please ensure you have entered an username or password', 'membership')));
                         }
                     }
                     do_action('membership_subscriptionbutton_onpage');
                     // There is no shortcode content in there, so override
                     remove_filter('the_content', 'wpautop');
                     $post->post_content .= $this->do_subscription_form();
                 }
             }
             if ($post->ID == $M_options['account_page']) {
                 // account page - check if page contains a shortcode
                 if (strstr($post->post_content, '[accountform]') !== false || strstr($post->post_content, '[upgradeform]') !== false || strstr($post->post_content, '[renewform]') !== false) {
                     // There is content in there with the shortcode so just return it
                     return $posts;
                 } else {
                     // account page found - add in the styles
                     if (!current_theme_supports('membership_account_form')) {
                         wp_enqueue_style('accountformcss', membership_url('membershipincludes/css/accountform.css'));
                         wp_enqueue_script('accountformjs', membership_url('membershipincludes/js/accountform.js'), array('jquery'));
                         wp_enqueue_style('publicformscss', membership_url('membershipincludes/css/publicforms.css'));
                         wp_enqueue_style('buttoncss', membership_url('membershipincludes/css/buttons.css'));
                     }
                     // There is no shortcode in there, so override
                     remove_filter('the_content', 'wpautop');
                     $post->post_content .= $this->do_account_form();
                 }
             }
             if ($post->ID == $M_options['subscriptions_page']) {
                 // Handle any updates passed
                 $page = isset($_REQUEST['action']) ? addslashes($_REQUEST['action']) : '';
                 if (empty($page)) {
                     $page = 'renewform';
                 }
                 switch ($page) {
                     case 'subscriptionsignup':
                         if (is_user_logged_in()) {
                             $member = current_member();
                             list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                             if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                                 $gateway = $_POST['gateway'];
                                 // Join the new subscription
                                 $member->create_subscription($sub_id, $gateway);
                                 do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                                 // Timestamp the update
                                 update_user_meta($user_id, '_membership_last_upgraded', time());
                                 // Added another redirect to the same url because the show_no_access filters
                                 // have already run on the "parse_request" action (Cole)
                                 wp_redirect(M_get_subscription_permalink());
                                 exit;
                             }
                         } else {
                             // check if a custom is posted and of so then process the user
                             if (isset($_POST['custom'])) {
                                 list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                                 if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                                     $gateway = $_POST['gateway'];
                                     // Join the new subscription
                                     $member = new M_Membership($user_id);
                                     $member->create_subscription($sub_id, $gateway);
                                     do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                                     // Timestamp the update
                                     update_user_meta($user_id, '_membership_last_upgraded', time());
                                     // Added another redirect to the same url because the show_no_access filters
                                     // have already run on the "parse_request" action (Cole)
                                     wp_redirect(M_get_subscription_permalink());
                                     exit;
                                 }
                             }
                         }
                         break;
                     default:
                         break;
                 }
                 // account page - check if page contains a shortcode
                 if (strstr($post->post_content, '[upgradeform]') !== false || strstr($post->post_content, '[renewform]') !== false) {
                     // There is content in there with the shortcode so just return it
                     return $posts;
                 } else {
                     // account page found - add in the styles
                     if (!current_theme_supports('membership_account_form')) {
                         wp_enqueue_style('subscriptionformcss', membership_url('membershipincludes/css/subscriptionform.css'));
                         wp_enqueue_style('upgradeformcss', membership_url('membershipincludes/css/upgradeform.css'));
                         wp_enqueue_style('renewformcss', membership_url('membershipincludes/css/renewform.css'));
                         wp_enqueue_script('renewformjs', membership_url('membershipincludes/js/renewform.js'), array('jquery'));
                         wp_localize_script('renewformjs', 'membership', array('unsubscribe' => __('Are you sure you want to unsubscribe from this subscription?', 'membership'), 'deactivatelevel' => __('Are you sure you want to deactivate this level?', 'membership')));
                         wp_enqueue_style('publicformscss', membership_url('membershipincludes/css/publicforms.css'));
                         wp_enqueue_style('buttoncss', membership_url('membershipincludes/css/buttons.css'));
                         if ($M_options['formtype'] == 'new') {
                             // pop up registration form
                             wp_enqueue_style('fancyboxcss', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.css'));
                             wp_enqueue_script('fancyboxjs', membership_url('membershipincludes/js/fancybox/jquery.fancybox-1.3.4.pack.js'), array('jquery'), false, true);
                             wp_enqueue_script('popupmemjs', membership_url('membershipincludes/js/popupregistration.js'), array('jquery'), false, true);
                             wp_enqueue_style('popupmemcss', membership_url('membershipincludes/css/popupregistration.css'));
                             wp_localize_script('popupmemjs', 'membership', array('ajaxurl' => admin_url('admin-ajax.php'), 'registernonce' => wp_create_nonce('membership_register'), 'loginnonce' => wp_create_nonce('membership_login'), 'regproblem' => __('Problem with registration.', 'membership'), 'logpropblem' => __('Problem with Login.', 'membership'), 'regmissing' => __('Please ensure you have completed all the fields', 'membership'), 'regnomatch' => __('Please ensure passwords match', 'membership'), 'logmissing' => __('Please ensure you have entered an username or password', 'membership')));
                         }
                     }
                     // There is no shortcode in there, so override
                     remove_filter('the_content', 'wpautop');
                     $post->post_content .= $this->do_renew_form();
                 }
             }
             if ($post->ID == $M_options['nocontent_page']) {
                 // no access page - we must return the content entered by the user so just return it
                 return $posts;
             }
             // Registration complete page
             if ($post->ID == $M_options['registrationcompleted_page']) {
                 // Handle any updates passed
                 if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) {
                     $page = addslashes($_REQUEST['action']);
                 } else {
                     $page = 'renewform';
                 }
                 switch ($page) {
                     case 'subscriptionsignup':
                         if (is_user_logged_in() && isset($_POST['custom'])) {
                             list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                             if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                                 $member = current_member();
                                 $gateway = $_POST['gateway'];
                                 // Join the new subscription
                                 $member->create_subscription($sub_id, $gateway);
                                 do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                                 // Timestamp the update
                                 update_user_meta($user_id, '_membership_last_upgraded', time());
                                 // Added another redirect to the same url because the show_no_access filters
                                 // have already run on the "parse_request" action (Cole)
                                 wp_redirect(M_get_returnurl_permalink());
                                 exit;
                             } else {
                             }
                         } else {
                             // check if a custom is posted and of so then process the user
                             if (isset($_POST['custom'])) {
                                 list($timestamp, $user_id, $sub_id, $key, $sublevel) = explode(':', $_POST['custom']);
                                 if (wp_verify_nonce($_REQUEST['_wpnonce'], 'free-sub_' . $sub_id)) {
                                     $gateway = $_POST['gateway'];
                                     // Join the new subscription
                                     $member = new M_Membership($user_id);
                                     $member->create_subscription($sub_id, $gateway);
                                     do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                                     // Timestamp the update
                                     update_user_meta($user_id, '_membership_last_upgraded', time());
                                     // Added another redirect to the same url because the show_no_access filters
                                     // have already run on the "parse_request" action (Cole)
                                     wp_redirect(M_get_returnurl_permalink());
                                     exit;
                                 }
                             }
                         }
                         break;
                 }
                 return $posts;
             }
         }
     }
     // If nothing else is hit, just return the content
     return $posts;
 }
コード例 #4
0
 function handle_2checkout_return()
 {
     // Return handling code
     $timestamp = time();
     if (isset($_REQUEST['key'])) {
         $total = $_REQUEST['total'];
         $sub_id = false;
         $user_id = false;
         list($sub_id, $user_id) = explode(':', $_REQUEST['merchant_order_id']);
         if (esc_attr(get_option($this->gateway . "_twocheckout_status")) == 'test') {
             $hash = strtoupper(md5(esc_attr(get_option($this->gateway . "_twocheckout_secret_word")) . esc_attr(get_option($this->gateway . "_twocheckout_sid")) . 1 . $total));
         } else {
             $hash = strtoupper(md5(esc_attr(get_option($this->gateway . "_twocheckout_secret_word")) . esc_attr(get_option($this->gateway . "_twocheckout_sid")) . $_REQUEST['order_number'] . $total));
         }
         if ($sub_id && $user_id && $_REQUEST['key'] == $hash && $_REQUEST['credit_card_processed'] == 'Y') {
             $this->record_transaction($user_id, $sub_id, $_REQUEST['total'], $_REQUEST['currency'], $timestamp, $_REQUEST['order_number'], 'Processed', '');
             // Added for affiliate system link
             do_action('membership_payment_processed', $user_id, $sub_id, $_REQUEST['total'], $_REQUEST['currency'], $_REQUEST['order_number']);
             $member = new M_Membership($user_id);
             if ($member) {
                 $member->create_subscription($sub_id, $this->gateway);
             }
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             wp_redirect(get_option('home'));
             exit;
         }
     } else {
         if (isset($_REQUEST['message_type'])) {
             $md5_hash = strtoupper(md5("{$_REQUEST['sale_id']}" . esc_attr(get_option($this->gateway . "_twocheckout_sid")) . "{$_REQUEST['invoice_id']}" . esc_attr(get_option($this->gateway . "_twocheckout_secret_word"))));
             $sub_id = false;
             $user_id = false;
             //$product_id = $_REQUEST['item_id_1'];
             list($sub_id, $user_id) = explode(':', $_REQUEST['vendor_order_id']);
             if ($md5_hash == $_REQUEST['md5_hash']) {
                 switch ($_REQUEST['message_type']) {
                     case 'RECURRING_INSTALLMENT_SUCCESS':
                         if (!$this->duplicate_transaction($user_id, $sub_id, $_REQUEST['item_rec_list_amount_1'], $_REQUEST['list_currency'], $timestamp, $_POST['invoice_id'], 'Processed', '')) {
                             $this->record_transaction($user_id, $sub_id, $_REQUEST['item_rec_list_amount_1'], $_REQUEST['list_currency'], $timestamp, $_POST['invoice_id'], 'Processed', '');
                             $member = new M_Membership($user_id);
                             if ($member) {
                                 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);
                             }
                             // Added for affiliate system link
                             do_action('membership_payment_processed', $user_id, $sub_id, $_REQUEST['item_rec_list_amount_1'], $_REQUEST['list_currency'], $_POST['invoice_id']);
                         }
                         break;
                     case 'FRAUD_STATUS_CHANGED':
                     case 'INVOICE_STATUS_CHANGED':
                         // We don't really want to do anything here without pulling out more information
                         break;
                     case 'ORDER_CREATED':
                     case 'RECURRING_RESTARTED':
                         $this->record_transaction($user_id, $sub_id, $_REQUEST['item_rec_list_amount_1'], $_REQUEST['list_currency'], $timestamp, $_POST['invoice_id'], 'Processed', '');
                         $member = new M_Membership($user_id);
                         if ($member) {
                             $member->create_subscription($sub_id, $this->gateway);
                         }
                         break;
                     case 'RECURRING_STOPPED':
                     case 'RECURRING_COMPLETE':
                     case 'RECURRING_INSTALLMENT_FAILED':
                     default:
                         $member = new M_Membership($user_id);
                         if ($member) {
                             $member->mark_for_expire($sub_id);
                         }
                         do_action('membership_payment_subscr_cancel', $user_id, $sub_id);
                         break;
                 }
             } else {
                 // MD5 Hash Failed
                 header('Status: 403 Forbidden');
                 echo 'Error: Unexpected Security Value. Verification is not possible.';
                 exit;
             }
             echo "OK";
             exit;
         } else {
             // Did not find expected POST variables. Possible access attempt from a non PayPal site.
             header('Status: 400 Bad Request');
             echo 'Error: Missing POST variables. Identification is not possible.';
             exit;
         }
     }
 }
コード例 #5
0
 function handle_paypal_return()
 {
     // PayPal IPN handling code
     if ((isset($_POST['payment_status']) || isset($_POST['txn_type'])) && isset($_POST['custom'])) {
         if (get_option($this->gateway . "_paypal_status") == 'live') {
             $domain = 'https://www.paypal.com';
         } else {
             $domain = 'https://www.sandbox.paypal.com';
         }
         $req = 'cmd=_notify-validate';
         if (!isset($_POST)) {
             $_POST = $HTTP_POST_VARS;
         }
         foreach ($_POST as $k => $v) {
             if (get_magic_quotes_gpc()) {
                 $v = stripslashes($v);
             }
             $req .= '&' . $k . '=' . $v;
         }
         $header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n" . 'Content-Type: application/x-www-form-urlencoded' . "\r\n" . 'Content-Length: ' . strlen($req) . "\r\n" . "\r\n";
         @set_time_limit(60);
         if ($conn = @fsockopen($domain, 80, $errno, $errstr, 30)) {
             fputs($conn, $header . $req);
             socket_set_timeout($conn, 30);
             $response = '';
             $close_connection = false;
             while (true) {
                 if (feof($conn) || $close_connection) {
                     fclose($conn);
                     break;
                 }
                 $st = @fgets($conn, 4096);
                 if ($st === false) {
                     $close_connection = true;
                     continue;
                 }
                 $response .= $st;
             }
             $error = '';
             $lines = explode("\n", str_replace("\r\n", "\n", $response));
             // looking for: HTTP/1.1 200 OK
             if (count($lines) == 0) {
                 $error = 'Response Error: Header not found';
             } else {
                 if (substr($lines[0], -7) != ' 200 OK') {
                     $error = 'Response Error: Unexpected HTTP response';
                 } else {
                     // remove HTTP header
                     while (count($lines) > 0 && trim($lines[0]) != '') {
                         array_shift($lines);
                     }
                     // first line will be empty, second line will have the result
                     if (count($lines) < 2) {
                         $error = 'Response Error: No content found in transaction response';
                     } else {
                         if (strtoupper(trim($lines[1])) != 'VERIFIED') {
                             $error = 'Response Error: Unexpected transaction response';
                         }
                     }
                 }
             }
             if ($error != '') {
                 echo $error;
                 exit;
             }
         }
         // handle cases that the system must ignore
         //if ($_POST['payment_status'] == 'In-Progress' || $_POST['payment_status'] == 'Partially-Refunded') exit;
         $new_status = false;
         // process PayPal response
         switch ($_POST['payment_status']) {
             case 'Partially-Refunded':
                 break;
             case 'In-Progress':
                 break;
             case 'Completed':
             case 'Processed':
                 // case: successful payment
                 $amount = $_POST['mc_gross'];
                 $currency = $_POST['mc_currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 $this->record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $_POST['txn_id'], $_POST['payment_status'], '');
                 // Added for affiliate system link
                 do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $_POST['txn_id']);
                 break;
             case 'Reversed':
                 // case: charge back
                 $note = 'Last transaction has been reversed. Reason: Payment has been reversed (charge back)';
                 $amount = $_POST['mc_gross'];
                 $currency = $_POST['mc_currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 $this->record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $_POST['txn_id'], $_POST['payment_status'], $note);
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->expire_subscription($sub_id);
                     $member->deactivate();
                 }
                 do_action('membership_payment_reversed', $user_id, $sub_id, $amount, $currency, $_POST['txn_id']);
                 break;
             case 'Refunded':
                 // case: refund
                 $note = 'Last transaction has been reversed. Reason: Payment has been refunded';
                 $amount = $_POST['mc_gross'];
                 $currency = $_POST['mc_currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 $this->record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $_POST['txn_id'], $_POST['payment_status'], $note);
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->expire_subscription($sub_id);
                 }
                 do_action('membership_payment_refunded', $user_id, $sub_id, $amount, $currency, $_POST['txn_id']);
                 break;
             case 'Denied':
                 // case: denied
                 $note = 'Last transaction has been reversed. Reason: Payment Denied';
                 $amount = $_POST['mc_gross'];
                 $currency = $_POST['mc_currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 $this->record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $_POST['txn_id'], $_POST['payment_status'], $note);
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->expire_subscription($sub_id);
                     $member->deactivate();
                 }
                 do_action('membership_payment_denied', $user_id, $sub_id, $amount, $currency, $_POST['txn_id']);
                 break;
             case 'Pending':
                 // case: payment is pending
                 $pending_str = array('address' => 'Customer did not include a confirmed shipping address', 'authorization' => 'Funds not captured yet', 'echeck' => 'eCheck that has not cleared yet', 'intl' => 'Payment waiting for aproval by service provider', 'multi-currency' => 'Payment waiting for service provider to handle multi-currency process', 'unilateral' => 'Customer did not register or confirm his/her email yet', 'upgrade' => 'Waiting for service provider to upgrade the PayPal account', 'verify' => 'Waiting for service provider to verify his/her PayPal account', '*' => '');
                 $reason = @$_POST['pending_reason'];
                 $note = 'Last transaction is pending. Reason: ' . (isset($pending_str[$reason]) ? $pending_str[$reason] : $pending_str['*']);
                 $amount = $_POST['mc_gross'];
                 $currency = $_POST['mc_currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 $this->record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $_POST['txn_id'], $_POST['payment_status'], $note);
                 do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $_POST['txn_id']);
                 break;
             default:
                 // case: various error cases
         }
         //check for subscription details
         switch ($_POST['txn_type']) {
             case 'subscr_signup':
                 // start the subscription
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 // create_subscription
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->create_subscription($sub_id, $this->gateway);
                 }
                 do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                 break;
             case 'subscr_modify':
                 // modify the subscription
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 // create_subscription
                 $member = new M_Membership($user_id);
                 if ($member) {
                     // Remove the old subscription
                     $member->drop_subscription($sub_id);
                     // Join the new subscription
                     $member->create_subscription((int) $_POST['item_number'], $this->gateway);
                     // Timestamp the update
                     update_user_meta($user_id, '_membership_last_upgraded', time());
                 }
                 do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                 break;
             case 'subscr_cancel':
                 // mark for removal
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $_POST['custom']);
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->mark_for_expire($sub_id);
                 }
                 do_action('membership_payment_subscr_cancel', $user_id, $sub_id);
                 break;
             case 'new_case':
                 // a dispute
                 if ($_POST['case_type'] == 'dispute') {
                     // immediately suspend the account
                     $member = new M_Membership($user_id);
                     if ($member) {
                         $member->deactivate();
                     }
                 }
                 do_action('membership_payment_new_case', $user_id, $sub_id, $_POST['case_type']);
                 break;
         }
     } else {
         // Did not find expected POST variables. Possible access attempt from a non PayPal site.
         header('Status: 404 Not Found');
         echo 'Error: Missing POST variables. Identification is not possible.';
         exit;
     }
 }
コード例 #6
0
 function do_subscription_shortcode($atts, $content = null, $code = "")
 {
     global $nxt_query;
     $error = array();
     $page = addslashes($_REQUEST['action']);
     $M_options = get_option('membership_options', array());
     switch ($page) {
         case 'validatepage1':
             // Page 1 of the form has been submitted - validate
             include_once ABSPATH . nxtINC . '/registration.php';
             $required = array('user_login' => __('Username', 'membership'), 'user_email' => __('Email address', 'membership'), 'user_email2' => __('Email address confirmation', 'membership'), 'password' => __('Password', 'membership'), 'password2' => __('Password confirmation', 'membership'));
             $error = array();
             foreach ($required as $key => $message) {
                 if (empty($_POST[$key])) {
                     $error[] = __('Please ensure that the ', 'membership') . "<strong>" . $message . "</strong>" . __(' information is completed.', 'membership');
                 }
             }
             if ($_POST['user_email'] != $_POST['user_email2']) {
                 $error[] = __('Please ensure the email addresses match.', 'membership');
             }
             if ($_POST['password'] != $_POST['password2']) {
                 $error[] = __('Please ensure the passwords match.', 'membership');
             }
             if (username_exists(sanitize_user($_POST['user_login']))) {
                 $error[] = __('That username is already taken, sorry.', 'membership');
             }
             if (email_exists($_POST['user_email'])) {
                 $error[] = __('That email address is already taken, sorry.', 'membership');
             }
             if (function_exists('get_site_option')) {
                 $terms = get_site_option('signup_tos_data');
             } else {
                 $terms = '';
             }
             if (!empty($terms)) {
                 if (empty($_POST['tosagree'])) {
                     $error[] = __('You need to agree to the terms of service to register.', 'membership');
                 }
             }
             $error = apply_filters('membership_subscription_form_before_registration_process', $error);
             if (empty($error)) {
                 // Pre - error reporting check for final add user
                 $user_id = nxt_create_user(sanitize_user($_POST['user_login']), $_POST['password'], $_POST['user_email']);
                 if (is_nxt_error($user_id) && method_exists($userid, 'get_error_message')) {
                     $error[] = $userid->get_error_message();
                 } else {
                     $member = new M_Membership($user_id);
                     if (empty($M_options['enableincompletesignups']) || $M_options['enableincompletesignups'] != 'yes') {
                         $member->deactivate();
                     }
                     if (has_action('membership_susbcription_form_registration_notification')) {
                         do_action('membership_susbcription_form_registration_notification', $user_id, $_POST['password']);
                     } else {
                         nxt_new_user_notification($user_id, $_POST['password']);
                     }
                 }
             }
             do_action('membership_subscription_form_registration_process', $error, $user_id);
             if (!empty($error)) {
                 $content .= "<div class='error'>";
                 $content .= implode('<br/>', $error);
                 $content .= "</div>";
                 $content .= $this->show_subpage_one(true);
             } else {
                 // everything seems fine (so far), so we have our queued user so let's
                 // look at picking a subscription.
                 $content .= $this->show_subpage_two($user_id);
             }
             break;
         case 'validatepage1bp':
             global $bp;
             include_once ABSPATH . nxtINC . '/registration.php';
             $required = array('signup_username' => __('Username', 'membership'), 'signup_email' => __('Email address', 'membership'), 'signup_password' => __('Password', 'membership'), 'signup_password_confirm' => __('Password confirmation', 'membership'));
             $error = array();
             foreach ($required as $key => $message) {
                 if (empty($_POST[$key])) {
                     $error[] = __('Please ensure that the ', 'membership') . "<strong>" . $message . "</strong>" . __(' information is completed.', 'membership');
                 }
             }
             if ($_POST['signup_password'] != $_POST['signup_password_confirm']) {
                 $error[] = __('Please ensure the passwords match.', 'membership');
             }
             if (username_exists(sanitize_user($_POST['signup_username']))) {
                 $error[] = __('That username is already taken, sorry.', 'membership');
             }
             if (email_exists($_POST['signup_email'])) {
                 $error[] = __('That email address is already taken, sorry.', 'membership');
             }
             $meta_array = array();
             // xprofile required fields
             /* Now we've checked account details, we can check profile information */
             if (function_exists('xprofile_check_is_required_field')) {
                 /* Make sure hidden field is passed and populated */
                 if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) {
                     /* Let's compact any profile field info into an array */
                     $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
                     /* Loop through the posted fields formatting any datebox values then validate the field */
                     foreach ((array) $profile_field_ids as $field_id) {
                         if (!isset($_POST['field_' . $field_id])) {
                             if (isset($_POST['field_' . $field_id . '_day'])) {
                                 $_POST['field_' . $field_id] = strtotime($_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year']);
                             }
                         }
                         /* Create errors for required fields without values */
                         if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id])) {
                             $field = new BP_Xprofile_Field($field_id);
                             $error[] = __('Please ensure that the ', 'membership') . "<strong>" . $field->name . "</strong>" . __(' information is completed.', 'membership');
                         }
                         $meta_array[$field_id] = $_POST['field_' . $field_id];
                     }
                 }
             }
             $error = apply_filters('membership_subscription_form_before_registration_process', $error);
             if (empty($error)) {
                 // Pre - error reporting check for final add user
                 $user_id = nxt_create_user(sanitize_user($_POST['signup_username']), $_POST['signup_password'], $_POST['signup_email']);
                 if (is_nxt_error($user_id) && method_exists($userid, 'get_error_message')) {
                     $error[] = $userid->get_error_message();
                 } else {
                     $member = new M_Membership($user_id);
                     if (empty($M_options['enableincompletesignups']) || $M_options['enableincompletesignups'] != 'yes') {
                         $member->deactivate();
                     }
                     if (has_action('membership_susbcription_form_registration_notification')) {
                         do_action('membership_susbcription_form_registration_notification', $user_id, $_POST['password']);
                     } else {
                         nxt_new_user_notification($user_id, $_POST['signup_password']);
                     }
                     foreach ((array) $meta_array as $field_id => $field_content) {
                         if (function_exists('xprofile_set_field_data')) {
                             xprofile_set_field_data($field_id, $user_id, $field_content);
                         }
                     }
                 }
             }
             do_action('membership_subscription_form_registration_process', $error, $user_id);
             if (!empty($error)) {
                 $content .= "<div class='error'>";
                 $content .= implode('<br/>', $error);
                 $content .= "</div>";
                 $content .= $this->show_subpage_one(true);
             } else {
                 // everything seems fine (so far), so we have our queued user so let's
                 // look at picking a subscription.
                 $content .= $this->show_subpage_two($user_id);
             }
             break;
         case 'validatepage2':
             $content = apply_filters('membership_subscription_form_subscription_process', $content, $error);
             break;
         case 'page2':
         case 'page1':
         default:
             if (!is_user_logged_in()) {
                 $content .= $this->show_subpage_one();
             } else {
                 // logged in check for sub
                 $user = nxt_get_current_user();
                 $member = new M_Membership($user->ID);
                 if ($member->is_member()) {
                     // This person is a member - display already registered stuff
                     $content .= $this->show_subpage_member();
                 } else {
                     // Show page two;
                     $content .= $this->show_subpage_two($user->ID);
                 }
             }
             break;
     }
     $content = apply_filters('membership_subscription_form', $content);
     return $content;
 }
コード例 #7
0
 function send_ping($sub_id = false, $level_id = false, $user_id = false)
 {
     $this->ping = $this->get_ping();
     if (!class_exists('nxt_Http')) {
         include_once ABSPATH . nxtINC . '/class-http.php';
     }
     $pingdata = $this->pingconstants;
     if (empty($user_id)) {
         $user = nxt_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 '%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('nxt_Http')) {
         $request = new nxt_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);
     }
 }
コード例 #8
0
 function handle_bitpay_return()
 {
     try {
         $post = file_get_contents("php://input");
         if (!$post) {
             return 'No post data';
         }
         $response = json_decode($post, true);
         if (is_string($response)) {
             return $response;
         }
         // error
         if (!array_key_exists('posData', $response)) {
             return 'No posData';
         }
         $posData = json_decode($response['posData'], true);
         if ($bpOptions['verifyPos'] and $posData['hash'] != bpHash(serialize($posData['posData']), $bpOptions['apiKey'])) {
             return 'Authentication failed (bad hash)';
         }
         $response['posData'] = $posData['posData'];
     } catch (Exception $e) {
         if ($bpOptions['useLogging']) {
             bpLog('Error: ' . $e->getMessage());
         }
         return array('error' => $e->getMessage());
     }
     if (isset($response['status'])) {
         switch ($response['status']) {
             case 'new':
                 // invoice just created, skip
                 break;
             case 'paid':
             case 'complete':
             case 'confirmed':
                 // payment has been paid, confirmed or marked complete
                 $note = 'Payment ' . $response['status'] . '! BitPay Invoice ID: ' . $response['id'];
                 $amount = $response['price'];
                 $currency = $response['currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $response['posData']);
                 // // Update to work with latest 3.5.x Membership version
                 // // and keep backward compatibility with older versions as well
                 // if (!class_exists('Membership_Gateway'))
                 // 	$isDuplicate = $this->duplicate_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $response['id'], $response['status'], $note);
                 // else
                 // 	$isDuplicate = $this->_check_duplicate_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $response['id'], $response['status'], $note);
                 // if(!$isDuplicate) {
                 // 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_processed', $user_id, $sub_id, $amount, $currency, $response['id']);
                 // create_subscription
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->create_subscription($sub_id, $this->gateway);
                 }
                 do_action('membership_payment_subscr_signup', $user_id, $sub_id);
                 // }
                 break;
             case 'invalid':
                 // payment has been deemed invalid. bad transaction!
                 $note = 'This payment has been marked as invalid. Do not process membership! BitPay Invoice ID: ' . $response['id'];
                 $amount = $response['price'];
                 $currency = $response['currency'];
                 list($timestamp, $user_id, $sub_id, $key) = explode(':', $response['posData']);
                 // 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);
                 }
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->expire_subscription($sub_id);
                     $member->deactivate();
                 }
                 do_action('membership_payment_denied', $user_id, $sub_id, $amount, $currency, $response['id']);
                 break;
                 // Since we want instant membership activation, the paid status is combined with the confirmed
                 // and completed statuses above. In the future if you want to change that, remove the paid: switch
                 // above and uncomment this code:
                 /*case 'paid':
                 					// payment has been made but confirmation pending
                 					$pending_str = 'BitPay payment received. Awaiting confirmation. BitPay Invoice ID: ' . $response['id'];
                 					$reason = 'paid';
                 					$note = $pending_str;
                 					$amount = $response['price'];
                 					$currency = $response['currency'];
                 					$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;
                 				*/
             // Since we want instant membership activation, the paid status is combined with the confirmed
             // and completed statuses above. In the future if you want to change that, remove the paid: switch
             // above and uncomment this code:
             /*case 'paid':
             					// payment has been made but confirmation pending
             					$pending_str = 'BitPay payment received. Awaiting confirmation. BitPay Invoice ID: ' . $response['id'];
             					$reason = 'paid';
             					$note = $pending_str;
             					$amount = $response['price'];
             					$currency = $response['currency'];
             					$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;
     }
 }
 function memeber_event_price_for_user($price, $event_id, $user_id)
 {
     $mi_price = get_post_meta($event_id, 'eab_events_mi_price', true);
     if (empty($mi_price)) {
         // Event price
         // Check if the user is free to enter
         $meta = get_post_meta($event_id, 'eab_events_mi', true);
         if (empty($meta['level'])) {
             return $price;
         }
         global $current_user;
         $member = new M_Membership($user_id);
         $levels = $member->get_level_ids();
         if (is_array($levels) and is_array($meta["level"])) {
             foreach ($levels as $level) {
                 if (in_array($level->level_id, $meta["level"])) {
                     return 0;
                 }
                 // Free for this level
             }
         }
         return $price;
         // Not free for this guy
     }
     global $current_user;
     $member = new M_Membership($user_id);
     $levels = $member->get_level_ids();
     $new_price = false;
     foreach ($levels as $level) {
         if (isset($mi_price[$level->level_id])) {
             $new_price = $mi_price[$level->level_id];
         }
     }
     return $new_price ? $new_price : $price;
 }
コード例 #10
0
ファイル: membershipadmin.php プロジェクト: hscale/webento
 function popover_register_process()
 {
     global $M_options;
     //include_once(ABSPATH . WPINC . '/registration.php');
     $error = array();
     if (!wp_verify_nonce($_POST['nonce'], 'membership_register')) {
         $error[] = __('Invalid form submission.', 'membership');
     }
     if (username_exists(sanitize_user($_POST['user_login']))) {
         $error[] = __('That username is already taken, sorry.', 'membership');
     }
     if (email_exists($_POST['email'])) {
         $error[] = __('That email address is already taken, sorry.', 'membership');
     }
     $error = apply_filters('membership_subscription_form_before_registration_process', $error);
     if (empty($error)) {
         // Pre - error reporting check for final add user
         $user = wp_create_user(sanitize_user($_POST['user_login']), $_POST['password'], $_POST['email']);
         if (is_wp_error($user) && method_exists($user, 'get_error_message')) {
             $error[] = $user->get_error_message();
         } else {
             $member = new M_Membership($user);
             if (empty($M_options['enableincompletesignups']) || $M_options['enableincompletesignups'] != 'yes') {
                 $member->deactivate();
             }
             $creds = array('user_login' => $_POST['user_login'], 'user_password' => $_POST['password'], 'remember' => true);
             $is_ssl = isset($_SERVER['https']) && $_SERVER['https'] == 'on' ? true : false;
             $user = wp_signon($creds, $is_ssl);
             if (is_wp_error($user) && method_exists($user, 'get_error_message')) {
                 $error[] = $user->get_error_message();
             }
             if (has_action('membership_susbcription_form_registration_notification')) {
                 do_action('membership_susbcription_form_registration_notification', $user->ID, $_POST['password']);
             } else {
                 wp_new_user_notification($user->ID, $_POST['password']);
             }
         }
     }
     do_action('membership_subscription_form_registration_process', $error, $user->ID);
     if (!empty($error)) {
         //sendback error
         echo json_encode(array('errormsg' => $error[0]));
     } else {
         // everything seems fine (so far), so we have our queued user so let's
         // move to picking a subscription - so send back the form.
         echo $this->popover_sendpayment_form($user->ID);
     }
     exit;
 }
コード例 #11
0
 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;
 }
コード例 #12
0
 function send_message($user_id, $sub_id = false, $level_id = false)
 {
     $this->comm = $this->get_communication();
     $M_options = get_option('membership_options');
     $commdata = apply_filters('membership_comm_constants_list', $this->commconstants);
     $member = new M_Membership($user_id);
     foreach ($commdata as $key => $value) {
         switch ($key) {
             case '%blogname%':
                 $commdata[$key] = get_option('blogname');
                 break;
             case '%blogurl%':
                 $commdata[$key] = get_option('home');
                 break;
             case '%username%':
                 $commdata[$key] = $member->user_login;
                 break;
             case '%usernicename%':
                 $commdata[$key] = $member->user_nicename;
                 break;
             case '%networkname%':
                 $commdata[$key] = get_site_option('site_name');
                 break;
             case '%networkurl%':
                 $commdata[$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);
                     $commdata[$key] = $sub->sub_name();
                 } else {
                     $commdata[$key] = '';
                 }
                 break;
             case '%levelname%':
                 if (!$level_id) {
                     $ids = $member->get_level_ids();
                     if (!empty($ids)) {
                         $level_id = $ids[0]->level_id;
                     }
                 }
                 if (!empty($level_id)) {
                     $level =& new M_Level($level_id);
                     $commdata[$key] = $level->level_title();
                 } else {
                     $commdata[$key] = '';
                 }
                 break;
             case '%accounturl%':
                 $commdata[$key] = M_get_account_permalink();
                 break;
             default:
                 $commdata[$key] = apply_filters('membership_commfield_' . $key, '', $user_id);
                 break;
         }
     }
     // Globally replace the values in the ping and then make it into an array to send
     $commmessage = str_replace(array_keys($commdata), array_values($commdata), stripslashes($this->comm->message));
     if (!empty($member->user_email)) {
         $res = @wp_mail($member->user_email, stripslashes($this->comm->subject), stripslashes($commmessage));
     }
 }
コード例 #13
0
 /**
  * Status update
  */
 public function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
 {
     $user_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', true);
     $sub_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', true);
     $amount = $payment->get_amount();
     $currency = $payment->get_currency();
     $status = $payment->get_status();
     $note = '';
     // 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, $sub_id, $amount, $currency, time(), $payment->get_id(), $status, $note);
     switch ($status) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L871
             do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             $member = new M_Membership($user_id);
             if ($member) {
                 $member->create_subscription($sub_id, $this->gateway);
             }
             // Added for affiliate system link
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L790
             do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L901
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             break;
     }
 }
コード例 #14
0
        function add_profile_feed_key($profileuser)
        {
            $id = $profileuser->ID;
            $member = new M_Membership($id);
            if ($member->is_member()) {
                $key = get_usermeta($id, '_membership_key');
                if (empty($key)) {
                    $key = md5($id . $profileuser->user_pass . time());
                    update_usermeta($id, '_membership_key', $key);
                }
                ?>
				<h3><?php 
                _e('Membership key');
                ?>
</h3>

				<table class="form-table">
				<tr>
					<th><label for="description"><?php 
                _e('Membership key');
                ?>
</label></th>
					<td><?php 
                esc_html_e($key);
                ?>
						<br />
					<span class="description"><?php 
                _e('This key is used to give you access the the members RSS feed, keep it safe and secret.');
                ?>
</span></td>
				</tr>
				</table>
				<?php 
            }
        }
コード例 #15
0
ファイル: functions.php プロジェクト: hscale/webento
function current_user_on_subscription($sub_id)
{
    $user = wp_get_current_user();
    $member = new M_Membership($user->ID);
    if (!empty($member)) {
        return $member->on_sub($sub_id);
    } else {
        return false;
    }
}
コード例 #16
0
 /**
  * Finds if user is Membership member with sufficient level
  * @return bool
  */
 function is_member()
 {
     if ($this->membership_active && isset($this->options["members"])) {
         global $current_user;
         $meta = maybe_unserialize($this->options["members"]);
         $member = new M_Membership($current_user->ID);
         if (is_array($meta) && $current_user->ID > 0 && $member->has_levels()) {
             // Load the levels for this member
             $levels = $member->get_level_ids();
             if (is_array($levels) && is_array($meta["level"])) {
                 foreach ($levels as $level) {
                     if (in_array($level->level_id, $meta["level"])) {
                         return true;
                     }
                     // Yes, user has sufficent level
                 }
             }
         }
     }
     return false;
 }
コード例 #17
0
<?php

if (!$user_id) {
    $user = wp_get_current_user();
    $spmemuserid = $user->ID;
    if (!empty($user->ID) && is_numeric($user->ID)) {
        $member = new M_Membership($user->ID);
    } else {
        $member = current_member();
    }
} else {
    $member = new M_Membership($user_id);
}
$subscription = (int) $_REQUEST['subscription'];
if (isset($_REQUEST['gateway']) && isset($_REQUEST['extra_form'])) {
    $gateway = M_get_class_for_gateway($_REQUEST['gateway']);
    if ($gateway && is_object($gateway) && $gateway->haspaymentform == true) {
        $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 __('Enter Your Credit Card Information', 'membership') . " " . $sub->sub_name();
        ?>
</h1>
		</div>
		<div class='fullwidth'>
コード例 #18
0
 /**
  * Update lead status of the specified payment
  *
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $invoice_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_invoice_id', true);
     $user_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_user_id', true);
     $sub_id = get_post_meta($payment->get_id(), '_pronamic_payment_membership_subscription_id', true);
     $amount = $payment->get_amount();
     $currency = $payment->get_currency();
     $status = $payment->get_status();
     $note = '';
     if (Pronamic_WP_Pay_Class::method_exists('MS_Factory', 'load') && class_exists('MS_Model_Invoice')) {
         $invoice = MS_Factory::load('MS_Model_Invoice', $invoice_id);
         $gateway_id = $invoice->gateway_id;
     } else {
         // Versions prior to Membership 2 only supported the iDEAL gateway.
         $gateway_id = 'pronamic_ideal';
     }
     if (isset(self::$gateways[$gateway_id])) {
         $gateway_class = self::$gateways[$gateway_id];
         if (class_exists($gateway_class)) {
             $gateway = new $gateway_class();
         }
         // Membership record transaction
         // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/classes/class.gateway.php#L176
         $gateway->pronamic_record_transaction($user_id, $sub_id, $amount, $currency, time(), $payment->get_id(), $status, $note);
     }
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::OPEN:
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L871
             do_action('membership_payment_pending', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/class-ms-factory.php#L116-L184
             // @see https://github.com/wp-plugins/membership/blob/4.0.0.2/app/model/class-ms-model-invoice.php
             if (isset($gateway, $invoice) && !$invoice->is_paid()) {
                 $invoice->pay_it($gateway->gateway, $payment->get_id());
             }
             if (class_exists('M_Membership')) {
                 $member = new M_Membership($user_id);
                 if ($member) {
                     $member->create_subscription($sub_id, $gateway->gateway);
                 }
             }
             // Added for affiliate system link
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L790
             do_action('membership_payment_processed', $user_id, $sub_id, $amount, $currency, $payment->get_id());
             // @see http://plugins.trac.wordpress.org/browser/membership/tags/3.4.4.1/membershipincludes/gateways/gateway.paypalexpress.php#L901
             do_action('membership_payment_subscr_signup', $user_id, $sub_id);
             break;
     }
 }