예제 #1
0
 /**
  * Handles Registration Links.
  *
  * @package optimizeMember\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after redirection.
  */
 public static function register()
 {
     do_action("ws_plugin__optimizemember_before_register", get_defined_vars());
     /**/
     if (!empty($_GET["optimizemember_register"])) {
         eval('while (@ob_end_clean ());');
         /* First we end/clean any output buffers that may exist already. */
         /**/
         $msg_503 = _x('<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
         /**/
         if (is_array($register = preg_split("/\\:\\.\\:\\|\\:\\.\\:/", c_ws_plugin__optimizemember_utils_encryption::decrypt(trim(stripslashes((string) $_GET["optimizemember_register"])))))) {
             if (count($register) === 6 && $register[0] === "subscr_gateway_subscr_id_custom_item_number_time") {
                 if (is_numeric($register[5]) && $register[5] <= strtotime("now") && $register[5] >= strtotime("-" . apply_filters("ws_plugin__optimizemember_register_link_exp_time", "2 days", get_defined_vars()))) {
                     $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($register[1]);
                     $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($register[2]);
                     $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($register[3]);
                     $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($register[4]);
                     /**/
                     if (($reg_cookies = c_ws_plugin__optimizemember_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
                         status_header(200);
                         /* Send a 200 OK status header. */
                         header("Content-Type: text/html; charset=utf-8");
                         /* Content-Type with UTF-8. */
                         /**/
                         setcookie("optimizemember_subscr_gateway", $_COOKIE["optimizemember_subscr_gateway"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_subscr_gateway", $_COOKIE["optimizemember_subscr_gateway"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         setcookie("optimizemember_subscr_id", $_COOKIE["optimizemember_subscr_id"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_subscr_id", $_COOKIE["optimizemember_subscr_id"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         setcookie("optimizemember_custom", $_COOKIE["optimizemember_custom"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_custom", $_COOKIE["optimizemember_custom"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         setcookie("optimizemember_item_number", $_COOKIE["optimizemember_item_number"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_item_number", $_COOKIE["optimizemember_item_number"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                         /**/
                         do_action("ws_plugin__optimizemember_during_register", get_defined_vars());
                         /**/
                         if (is_multisite() && c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() && is_main_site() && ($location = c_ws_plugin__optimizemember_utils_urls::wp_signup_url())) {
                             echo '<script type="text/javascript">' . "\n";
                             echo "window.location = '" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq($location) . "';";
                             echo '</script>' . "\n";
                         } else {
                             if ($location = c_ws_plugin__optimizemember_utils_urls::wp_register_url()) {
                                 echo '<script type="text/javascript">' . "\n";
                                 echo "window.location = '" . c_ws_plugin__optimizemember_utils_strings::esc_js_sq($location) . "';";
                                 echo '</script>' . "\n";
                             }
                         }
                         exit;
                         /* Clean exit. The browser will now be redirected to ``$location``. */
                     } else {
                         status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
                     }
                 } else {
                     status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
                 }
             } else {
                 status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
             }
         } else {
             status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
         }
     }
     /**/
     do_action("ws_plugin__optimizemember_after_register", get_defined_vars());
 }
예제 #2
0
 /**
  * Handles processing of Pro Form billing updates.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_update()
 {
     if (!empty($_POST['optimizemember_pro_stripe_update']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_update']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-update')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_update_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_update_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_update']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_update_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('update', $post_vars))) {
                 if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($cur__subscr_cid = get_user_option('optimizemember_subscr_cid')) && ($cur__subscr_id = get_user_option('optimizemember_subscr_id'))) {
                         if (is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id)) && !preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
                             unset($_POST['optimizemember_pro_stripe_update']['card_token']);
                             // These are good one-time only.
                             unset($_POST['optimizemember_pro_stripe_update']['card_token_summary']);
                             if (is_object($set_customer_card_token = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($cur__subscr_cid, $post_vars['card_token']))) {
                                 $global_response = array('response' => _x('<strong>Confirmed.</strong> Your billing information has been updated.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 $global_response = array('response' => $set_customer_card_token, 'error' => TRUE);
                             }
                         } else {
                             $global_response = array('response' => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Oops.</strong> No Customer|Subscr. ID. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                     }
                 } else {
                     $global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
예제 #3
0
 /**
  * Handles the return of Tax for Pro Forms, via AJAX; through a JSON object.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  */
 public static function stripe_ajax_tax()
 {
     if (!empty($_POST['ws_plugin__optimizemember_pro_stripe_ajax_tax']) && ($nonce = $_POST['ws_plugin__optimizemember_pro_stripe_ajax_tax']) && (wp_verify_nonce($nonce, 'ws-plugin--optimizemember-pro-stripe-ajax-tax') || c_ws_plugin__optimizemember_utils_encryption::decrypt($nonce) === 'ws-plugin--optimizemember-pro-stripe-ajax-tax')) {
         status_header(200);
         // Send a 200 OK status header.
         header('Content-Type: text/plain; charset=UTF-8');
         // Content-Type text/plain with UTF-8.
         while (@ob_end_clean()) {
         }
         // Clean any existing output buffers.
         if (!empty($_POST['ws_plugin__optimizemember_pro_stripe_ajax_tax_vars']) && is_array($_p_tax_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['ws_plugin__optimizemember_pro_stripe_ajax_tax_vars'])))) {
             if (is_array($attr = !empty($_p_tax_vars['attr']) ? unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($_p_tax_vars['attr'])) : FALSE)) {
                 $attr = !empty($attr['coupon']) ? c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($attr, $attr['coupon']) : $attr;
                 $trial = $attr['rr'] !== 'BN' && $attr['tp'] ? TRUE : FALSE;
                 // Is there a trial?
                 $sub_total_today = $trial ? $attr['ta'] : $attr['ra'];
                 // What is the sub-total today?
                 $state = strip_tags($_p_tax_vars['state']);
                 $country = strip_tags($_p_tax_vars['country']);
                 $zip = strip_tags($_p_tax_vars['zip']);
                 $currency = $attr['cc'];
                 $desc = $attr['desc'];
                 /* Trial is `null` in this function call. We only need to return what it costs today.
                 			However, we do tag on a 'trial' element in the array so the ajax routine will know about this. */
                 $a = c_ws_plugin__optimizemember_pro_stripe_utilities::cost(NULL, $sub_total_today, $state, $country, $zip, $currency, $desc);
                 echo json_encode(array('trial' => $trial, 'sub_total' => $a['sub_total'], 'tax' => $a['tax'], 'tax_per' => $a['tax_per'], 'total' => $a['total'], 'cur' => $a['cur'], 'cur_symbol' => $a['cur_symbol'], 'desc' => $a['desc']));
             }
         }
         exit;
         // Clean exit.
     }
 }
예제 #4
0
 /**
  * Handles the return of Tax for Pro Forms, via AJAX; through a JSON object.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @return null Or exits script execution after returning data for AJAX caller.
  *
  * @todo Check the use of ``strip_tags()`` in this routine?
  * @todo Continue optimizing this routine with ``empty()`` and ``isset()``.
  * @todo Candidate for the use of ``ifsetor()``?
  */
 public static function paypal_ajax_tax()
 {
     if (!empty($_POST["ws_plugin__optimizemember_pro_paypal_ajax_tax"]) && ($nonce = $_POST["ws_plugin__optimizemember_pro_paypal_ajax_tax"]) && (wp_verify_nonce($nonce, "ws-plugin--optimizemember-pro-paypal-ajax-tax") || c_ws_plugin__optimizemember_utils_encryption::decrypt($nonce) === "ws-plugin--optimizemember-pro-paypal-ajax-tax")) {
         status_header(200);
         /* Send a 200 OK status header. */
         header("Content-Type: text/plain; charset=utf-8");
         /* Content-Type text/plain with UTF-8. */
         eval('while (@ob_end_clean ());');
         /* End/clean all output buffers that may or may not exist. */
         /**/
         if (!empty($_POST["ws_plugin__optimizemember_pro_paypal_ajax_tax_vars"]) && is_array($_p_tax_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["ws_plugin__optimizemember_pro_paypal_ajax_tax_vars"])))) {
             if (is_array($attr = !empty($_p_tax_vars["attr"]) ? unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($_p_tax_vars["attr"])) : false)) {
                 $attr = !empty($attr["coupon"]) ? c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_apply_coupon($attr, $attr["coupon"]) : $attr;
                 /**/
                 $trial = $attr["rr"] !== "BN" && $attr["tp"] ? true : false;
                 /* Is there a trial? */
                 $sub_total_today = $trial ? $attr["ta"] : $attr["ra"];
                 /* What is the sub-total today? */
                 /**/
                 $state = strip_tags($_p_tax_vars["state"]);
                 $country = strip_tags($_p_tax_vars["country"]);
                 $zip = strip_tags($_p_tax_vars["zip"]);
                 $currency = $attr["cc"];
                 /* Currency. */
                 $desc = $attr["desc"];
                 /* Description. */
                 /**/
                 /* Trial is `null` in this function call. We only need to return what it costs today.
                 			However, we do tag on a "trial" element in the array so the ajax routine will know about this. */
                 $a = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_cost(null, $sub_total_today, $state, $country, $zip, $currency, $desc);
                 echo json_encode(array("trial" => $trial, "sub_total" => $a["sub_total"], "tax" => $a["tax"], "tax_per" => $a["tax_per"], "total" => $a["total"], "cur" => $a["cur"], "cur_symbol" => $a["cur_symbol"], "desc" => $a["desc"]));
             }
         }
         /**/
         exit;
         /* Clean exit. */
     }
 }
 /**
  * Handles processing of Pro Form cancellations.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_cancellation()
 {
     if (!empty($_POST["optimizemember_pro_authnet_cancellation"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_authnet_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-cancellation")) {
         $GLOBALS["ws_plugin__optimizemember_pro_authnet_cancellation_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_authnet_cancellation_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_authnet_cancellation"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_authnet_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_submission_validation_errors("cancellation", $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $cur__subscr_id = get_user_option("optimizemember_subscr_id"))) {
                         if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && $authnet["subscription_status"]) {
                             if (preg_match("/^(active|suspended)\$/i", $authnet["subscription_status"])) {
                                 if (!($ipn = array())) {
                                     /* With Authorize.Net, we need their IPN signup vars. */
                                     if (is_array($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars())) {
                                         $ipn["txn_type"] = "subscr_cancel";
                                         $ipn["subscr_id"] = $ipn_signup_vars["subscr_id"];
                                         $ipn["custom"] = $ipn_signup_vars["custom"];
                                         /**/
                                         $ipn["period1"] = $ipn_signup_vars["period1"];
                                         $ipn["period3"] = $ipn_signup_vars["period3"];
                                         /**/
                                         $ipn["payer_email"] = $ipn_signup_vars["payer_email"];
                                         $ipn["first_name"] = $ipn_signup_vars["first_name"];
                                         $ipn["last_name"] = $ipn_signup_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = $ipn_signup_vars["option_name1"];
                                         $ipn["option_selection1"] = $ipn_signup_vars["option_selection1"];
                                         /**/
                                         $ipn["option_name2"] = $ipn_signup_vars["option_name2"];
                                         $ipn["option_selection2"] = $ipn_signup_vars["option_selection2"];
                                         /**/
                                         $ipn["item_name"] = $ipn_signup_vars["item_name"];
                                         $ipn["item_number"] = $ipn_signup_vars["item_number"];
                                         /**/
                                         $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                                         $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                         /**/
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                     }
                                 }
                                 /**/
                                 if ($authnet = array("x_method" => "cancel", "x_subscription_id" => $cur__subscr_id)) {
                                     c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet);
                                     /**/
                                     $global_response = array("response" => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                     /**/
                                     if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 }
                             } else {
                                 $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                             /**/
                             if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                             }
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                         /**/
                         if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #6
0
 /**
  * Checks registration cookies.
  *
  * @package optimizeMember\Registrations
  * @since 110707
  *
  * @return array|bool An array of cookies if they're OK, else false.
  */
 public static function reg_cookies_ok()
 {
     global $wpdb;
     /* Global database object reference. */
     /**/
     do_action("ws_plugin__optimizemember_before_reg_cookies_ok", get_defined_vars());
     /**/
     if (isset($_COOKIE["optimizemember_subscr_gateway"], $_COOKIE["optimizemember_subscr_id"], $_COOKIE["optimizemember_custom"], $_COOKIE["optimizemember_item_number"])) {
         if (($subscr_gateway = c_ws_plugin__optimizemember_utils_encryption::decrypt((string) $_COOKIE["optimizemember_subscr_gateway"])) && ($subscr_id = c_ws_plugin__optimizemember_utils_encryption::decrypt((string) $_COOKIE["optimizemember_subscr_id"])) && preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $custom = c_ws_plugin__optimizemember_utils_encryption::decrypt((string) $_COOKIE["optimizemember_custom"])) && preg_match($GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["membership_item_number_w_level_regex"], $item_number = c_ws_plugin__optimizemember_utils_encryption::decrypt((string) $_COOKIE["optimizemember_item_number"])) && !$wpdb->get_var("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "optimizemember_subscr_id' AND `meta_value` = '" . $wpdb->escape($subscr_id) . "' LIMIT 1")) {
             $reg_cookies_ok = $reg_cookies = array("subscr_gateway" => $subscr_gateway, "subscr_id" => $subscr_id, "custom" => $custom, "item_number" => $item_number);
         }
     }
     /**/
     return apply_filters("ws_plugin__optimizemember_reg_cookies_ok", isset($reg_cookies_ok) && $reg_cookies_ok && !empty($reg_cookies) ? $reg_cookies : false, get_defined_vars());
 }
 /**
  * Handles processing of Pro Form cancellations.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_cancellation()
 {
     if (!empty($_POST["optimizemember_pro_paypal_cancellation"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-cancellation")) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_cancellation_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_cancellation_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_paypal_cancellation"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_paypal_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("cancellation", $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if ($cur__subscr_id = get_user_option("optimizemember_subscr_id")) {
                         if (($paypal = c_ws_plugin__optimizemember_pro_paypal_utilities::payflow_get_profile($cur__subscr_id)) && $paypal["TENDER"] !== "P") {
                             if (preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_cancel";
                                     $ipn["subscr_id"] = $paypal["PROFILEID"];
                                     $ipn["custom"] = get_user_option("optimizemember_custom");
                                     /**/
                                     $ipn["period1"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($paypal);
                                     $ipn["period3"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($paypal);
                                     /**/
                                     $ipn["payer_email"] = $paypal["EMAIL"];
                                     $ipn["first_name"] = $paypal["FIRSTNAME"];
                                     $ipn["last_name"] = $paypal["LASTNAME"];
                                     /**/
                                     $ipn["option_name1"] = "Referencing Customer ID";
                                     $ipn["option_selection1"] = $paypal["PROFILEID"];
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     /* IP Address. */
                                     $ipn["option_selection2"] = get_user_option("optimizemember_registration_ip");
                                     /**/
                                     $ipn["item_name"] = $paypal["DESC"] ? $paypal["DESC"] : $paypal["PROFILENAME"];
                                     $ipn["item_number"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_item_number($paypal);
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     /**/
                                     c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                 }
                                 /**/
                                 c_ws_plugin__optimizemember_pro_paypal_utilities::payflow_cancel_profile($paypal["PROFILEID"]);
                                 /**/
                                 $global_response = array("response" => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             } else {
                                 if (preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $global_response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 } else {
                                     $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                     /**/
                                     if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 }
                             }
                         } else {
                             if ($paypal && $paypal["TENDER"] === "P") {
                                 $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to cancel your Subscription.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/cgi-bin/webscr?cmd=_subscr-find&amp;alias=" . urlencode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_business"]))), "error" => true);
                             } else {
                                 $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             }
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
                         /**/
                         if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #8
0
 /**
  * Handles Specific Post/Page Access authentication.
  *
  * @package optimizeMember\SP_Access
  * @since 3.5
  *
  * @param int|str $sp_id Numeric Post/Page ID in WordPress.
  * @param bool $read_only Optional. Defaults to false. If ``$read_only = true``,
  * 	no session cookies are set, no IP Restrictions are checked, and script execution is not exited on Link failure.
  * 	In other words, with ``$read_only = true``, this function will simply return true or false.
  * @return null|bool Always returns `true` if access is indeed allowed in one way or another.
  * 	If access is denied with ``$read_only = true`` simply return false. If access is denied with ``$read_only = false``, return false; but if a Specific Post/Page Access Link is currently being used, we exit with a warning about Access Link expiration here.
  */
 public static function sp_access($sp_id = FALSE, $read_only = FALSE)
 {
     do_action("ws_plugin__optimizemember_before_sp_access", get_defined_vars());
     /**/
     $excluded = apply_filters("ws_plugin__optimizemember_sp_access_excluded", false, get_defined_vars());
     /**/
     if ($excluded || current_user_can(apply_filters("ws_plugin__optimizemember_sp_access_excluded_cap", "edit_posts", get_defined_vars()))) {
         return apply_filters("ws_plugin__optimizemember_sp_access", true, get_defined_vars(), "auth-via-exclusion");
     } else {
         if ($sp_id && is_numeric($sp_id) && (!empty($_GET["optimizemember_sp_access"]) && ($_g["optimizemember_sp_access"] = trim(stripslashes((string) $_GET["optimizemember_sp_access"]))) && is_array($sp_access_values = array($_g["optimizemember_sp_access"])) || is_array($sp_access_values = c_ws_plugin__optimizemember_sp_access::sp_access_session())) && !empty($sp_access_values)) {
             foreach ($sp_access_values as $sp_access_value) {
                 if (is_array($sp_access = preg_split("/\\:\\.\\:\\|\\:\\.\\:/", c_ws_plugin__optimizemember_utils_encryption::decrypt($sp_access_value)))) {
                     if (count($sp_access) === 4 && $sp_access[0] === "sp_time_hours" && in_array($sp_id, preg_split("/[\r\n\t\\s;,]+/", $sp_access[1]))) {
                         if (is_numeric($sp_access[2]) && is_numeric($sp_access[3]) && $sp_access[2] <= strtotime("now") && $sp_access[2] + $sp_access[3] * 3600 >= strtotime("now")) {
                             if (!$read_only && !empty($_g["optimizemember_sp_access"])) {
                                 /* Add to session? */
                                 c_ws_plugin__optimizemember_sp_access::sp_access_session($_g["optimizemember_sp_access"]);
                             }
                             /**/
                             if ($read_only || c_ws_plugin__optimizemember_ip_restrictions::ip_restrictions_ok($_SERVER["REMOTE_ADDR"], $sp_access_value)) {
                                 return apply_filters("ws_plugin__optimizemember_sp_access", true, get_defined_vars(), "auth-via-link-session");
                             }
                         }
                     }
                 }
             }
             /* Otherwise, authentication was NOT possible via link or session. */
             if (!$read_only && !empty($_g["optimizemember_sp_access"])) {
                 status_header(503) . header("Content-Type: text/html; charset=utf-8");
                 eval('while (@ob_end_clean ());');
                 /* End/clean all output buffers that may exist. */
                 exit(_x('<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.', "s2member-front", "s2member"));
             } else {
                 /* Else return false here. */
                 return apply_filters("ws_plugin__optimizemember_sp_access", false, get_defined_vars(), "no-auth-via-link-session");
             }
         } else {
             /* Else return false here. */
             return apply_filters("ws_plugin__optimizemember_sp_access", false, get_defined_vars(), "no-auth-no-link-session");
         }
     }
 }
예제 #9
0
 function optimizemember_decrypt($base64 = FALSE, $key = FALSE)
 {
     return c_ws_plugin__optimizemember_utils_encryption::decrypt($base64, $key);
 }
 /**
  * optimizeMember's PayPal Auto-Return/PDT handler ( inner processing routine ).
  *
  * @package optimizeMember\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link optimizeMember\PayPal\c_ws_plugin__optimizemember_paypal_return_in::paypal_return()}.
  * @return array|bool The original ``$paypal`` array passed in ( extracted ) from ``$vars``, or false when conditions do NOT apply.
  *
  * @todo Optimize with ``empty()`` and ``isset()``.
  */
 public static function cp($vars = array())
 {
     extract($vars);
     /* Extract all vars passed in from: ``c_ws_plugin__optimizemember_paypal_notify_in::paypal_notify()``. */
     /**/
     if (!empty($paypal["txn_type"]) && preg_match("/^(web_accept|subscr_signup|subscr_payment)\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || !empty($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"]))) {
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__optimizemember_during_paypal_return_before_subscr_signup", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         if (!get_transient($transient_rtn = "s2m_rtn_" . md5("optimizemember_transient_" . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
             $paypal["optimizemember_log"][] = "optimizeMember `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
             /**/
             list($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split("/\\:/", $paypal["item_number"], 3);
             /**/
             $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
             $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
             $paypal["ip"] = !$paypal["ip"] && $_SERVER["REMOTE_ADDR"] ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
             /**/
             if (preg_match("/^subscr_payment\$/i", $paypal["txn_type"]) && !empty($_GET["optimizemember_paypal_return_tra"]) && (($tra = c_ws_plugin__optimizemember_utils_encryption::decrypt(trim(stripslashes($_GET["optimizemember_paypal_return_tra"])))) && is_array($tra = maybe_unserialize($tra))) && (count($tra) === 11 && isset($tra["ta"], $tra["tp"], $tra["tt"], $tra["ra"], $tra["rp"], $tra["rt"], $tra["rr"], $tra["rrt"], $tra["rra"], $tra["invoice"], $tra["checksum"])) && $tra["invoice"] === $paypal["invoice"] && $tra["checksum"] === md5($paypal["invoice"] . $paypal["ip"] . $paypal["item_number"])) {
                 $tracking_properties = true;
                 /* Yes, these tracking properties ARE being set here. */
                 /**/
                 $paypal["period1"] = $tra["rr"] !== "BN" && $tra["tp"] ? $tra["tp"] . " " . $tra["tt"] : "0 D";
                 $paypal["mc_amount1"] = $tra["rr"] !== "BN" && $tra["tp"] ? number_format($tra["ta"], 2, ".", "") : "0.00";
                 /**/
                 $paypal["period3"] = $tra["rp"] . " " . $tra["rt"];
                 $paypal["mc_amount3"] = $tra["ra"];
                 /**/
                 $paypal["recurring"] = $tra["rr"] === "1" ? "1" : "0";
                 /**/
                 $paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
                 /* Defaults to "0 D" ( zero days ). */
                 $paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
                 $paypal["regular"] = $paypal["mc_amount3"];
                 /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal. */
                 $paypal["regular_term"] = $paypal["period3"];
                 /* This is just set to keep a standard; this way both initial_term & regular_term are available. */
                 $paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
                 /* If non-recurring, this should be zero, otherwise Regular. */
                 /**/
                 eval('$ipn_signup_vars = $paypal; unset($ipn_signup_vars["optimizemember_log"]);');
                 /* Create array of wouldbe IPN signup vars w/o optimizemember_log. */
             } else {
                 if (preg_match("/^(web_accept|subscr_signup)\$/i", $paypal["txn_type"])) {
                     $tracking_properties = true;
                     /* Yes, these tracking properties ARE being set here. */
                     /**/
                     $paypal["period1"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
                     /* Defaults to "0 D" ( zero days ). */
                     $paypal["mc_amount1"] = strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0 ? $paypal["mc_amount1"] : "0.00";
                     /* "0.00". */
                     /**/
                     if (preg_match("/^web_accept\$/i", $paypal["txn_type"])) {
                         $paypal["period3"] = $paypal["eotper"] ? $paypal["eotper"] : "1 L";
                         /* 1 Lifetime. */
                         $paypal["mc_amount3"] = $paypal["mc_gross"];
                         /* The "Buy Now" amount is the full gross. */
                     }
                     /**/
                     $paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
                     /* Defaults to "0 D" ( zero days ). */
                     $paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
                     $paypal["regular"] = $paypal["mc_amount3"];
                     /* This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal. */
                     $paypal["regular_term"] = $paypal["period3"];
                     /* This is just set to keep a standard; this way both initial_term & regular_term are available. */
                     $paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
                     /* If non-recurring, this should be zero, otherwise Regular. */
                     /**/
                     eval('$ipn_signup_vars = $paypal; unset($ipn_signup_vars["optimizemember_log"]);');
                     /* Create array of wouldbe IPN signup vars w/o optimizemember_log. */
                 }
             }
             /*
             New Subscription with advanced update vars ( option_name1, option_selection1 )? Used in Subscr. Modifications.
             */
             if (preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) {
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
                 /**/
                 $paypal["optimizemember_log"][] = "optimizeMember `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
                 /**/
                 /* Check for both the old & new subscr_id's, just in case the IPN routine already changed it. */
                 if (($user_id = c_ws_plugin__optimizemember_utils_users::get_user_id_with($paypal["subscr_id"], $paypal["option_selection1"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
                     if (!$user->has_cap("administrator")) {
                         $processing = $modifying = $during = true;
                         /* Yes, we ARE processing this. */
                         /**/
                         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                         do_action("ws_plugin__optimizemember_during_paypal_return_during_before_subscr_signup_w_update_vars", get_defined_vars());
                         do_action("ws_plugin__optimizemember_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "optimizemember_level" . $paypal["level"]);
                         unset($__refs, $__v);
                         /* Unset defined __refs, __v. */
                         /**/
                         $fields = get_user_option("optimizemember_custom_fields", $user_id);
                         /* These will be needed in the routines below. */
                         $user_reg_ip = get_user_option("optimizemember_registration_ip", $user_id);
                         /* Original IP during Registration. */
                         $user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
                         /* Now merge conditionally. */
                         /**/
                         if (is_multisite() && !is_user_member_of_blog($user_id)) {
                             add_existing_user_to_blog(array("user_id" => $user_id, "role" => "optimizemember_level" . $paypal["level"]));
                             $user = new WP_User($user_id);
                         }
                         /**/
                         $current_role = c_ws_plugin__optimizemember_user_access::user_access_role($user);
                         /**/
                         if ($current_role !== "optimizemember_level" . $paypal["level"]) {
                             /* Only if we need to. */
                             $user->set_role("optimizemember_level" . $paypal["level"]);
                         }
                         /* (upgrade/downgrade) */
                         /**/
                         if ($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"]))) {
                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                 if (preg_match("/^access_optimizemember_ccap_/", $cap)) {
                                     $user->remove_cap($ccap = $cap);
                                 }
                             }
                         }
                         /**/
                         if ($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) {
                             foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap) {
                                 if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                     $user->add_cap("access_optimizemember_ccap_" . $ccap);
                                 }
                             }
                         }
                         /**/
                         update_user_option($user_id, "optimizemember_subscr_gateway", $paypal["subscr_gateway"]);
                         update_user_option($user_id, "optimizemember_subscr_id", $paypal["subscr_id"]);
                         update_user_option($user_id, "optimizemember_custom", $paypal["custom"]);
                         /**/
                         if (!get_user_option("optimizemember_registration_ip", $user_id)) {
                             update_user_option($user_id, "optimizemember_registration_ip", $paypal["ip"]);
                         }
                         /**/
                         if (!empty($ipn_signup_vars)) {
                             update_user_option($user_id, "optimizemember_ipn_signup_vars", $ipn_signup_vars);
                         }
                         /**/
                         delete_user_option($user_id, "optimizemember_file_download_access_log");
                         /**/
                         if (preg_match("/^web_accept\$/i", $paypal["txn_type"]) && $paypal["eotper"]) {
                             /* Don't update this in the return routine. Leave this for the IPN routine. */
                             /* EOT Times might be extended, and we don't want the IPN routine to extend an already-extended EOT Time. */
                             $eot_time = c_ws_plugin__optimizemember_utils_time::auto_eot_time("", "", "", $paypal["eotper"], "", get_user_option("optimizemember_auto_eot_time", $user_id));
                             $paypal["optimizemember_log"][] = "Automatic EOT ( End Of Term ) Time will be set to: " . date("D M j, Y g:i:s a T", $eot_time) . ".";
                         } else {
                             /* Otherwise, we need to clear the Auto-EOT Time. */
                             delete_user_option($user_id, "optimizemember_auto_eot_time");
                         }
                         /**/
                         $pr_times = get_user_option("optimizemember_paid_registration_times", $user_id);
                         $pr_times["level"] = !$pr_times["level"] ? time() : $pr_times["level"];
                         /* Preserves existing. */
                         $pr_times["level" . $paypal["level"]] = !$pr_times["level" . $paypal["level"]] ? time() : $pr_times["level" . $paypal["level"]];
                         update_user_option($user_id, "optimizemember_paid_registration_times", $pr_times);
                         /* Update now. */
                         /**/
                         c_ws_plugin__optimizemember_user_notes::clear_user_note_lines($user_id, "/^Demoted by optimizeMember\\:/");
                         /**/
                         $paypal["optimizemember_log"][] = "optimizeMember Level/Capabilities updated w/ advanced update routines.";
                         /**/
                         setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($paypal["subscr_id"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                         /**/
                         $paypal["optimizemember_log"][] = "Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
                         /**/
                         if ($processing && $tracking_properties && ($code = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["modification_tracking_codes"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                             if (($code = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace("/%%subscr_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["subscr_id"]), $code))) {
                                 if (($code = preg_replace("/%%initial%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["initial"]), $code)) && ($code = preg_replace("/%%regular%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["regular"]), $code)) && ($code = preg_replace("/%%recurring%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["recurring"]), $code))) {
                                     if (($code = preg_replace("/%%initial_term%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["initial_term"]), $code)) && ($code = preg_replace("/%%regular_term%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["regular_term"]), $code))) {
                                         if (($code = preg_replace("/%%item_number%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["item_number"]), $code)) && ($code = preg_replace("/%%item_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["item_name"]), $code))) {
                                             if (($code = preg_replace("/%%first_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["first_name"]), $code)) && ($code = preg_replace("/%%last_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["last_name"]), $code))) {
                                                 if ($code = preg_replace("/%%full_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $code)) {
                                                     if ($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["payer_email"]), $code)) {
                                                         if (($code = preg_replace("/%%user_first_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($user->first_name), $code)) && ($code = preg_replace("/%%user_last_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($user->last_name), $code))) {
                                                             if ($code = preg_replace("/%%user_full_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(trim($user->first_name . " " . $user->last_name)), $code)) {
                                                                 if ($code = preg_replace("/%%user_email%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($user->user_email), $code)) {
                                                                     if ($code = preg_replace("/%%user_login%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($user->user_login), $code)) {
                                                                         if ($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($user_reg_ip), $code)) {
                                                                             if ($code = preg_replace("/%%user_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($user_id), $code)) {
                                                                                 if (is_array($fields) && !empty($fields)) {
                                                                                     foreach ($fields as $var => $val) {
                                                                                         /* Custom Registration/Profile Fields. */
                                                                                         if (!($code = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(maybe_serialize($val)), $code))) {
                                                                                             break;
                                                                                         }
                                                                                     }
                                                                                 }
                                                                                 /**/
                                                                                 if ($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) {
                                                                                     $paypal["optimizemember_log"][] = "Storing Modification Tracking Codes into a Transient Queue. These will be processed on-site.";
                                                                                     set_transient("s2m_" . md5("optimizemember_transient_modification_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         /**/
                         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                         do_action("ws_plugin__optimizemember_during_paypal_return_during_subscr_signup_w_update_vars", get_defined_vars());
                         unset($__refs, $__v);
                         /* Unset defined __refs, __v. */
                         /**/
                         if ($redirection_url_after_modification = apply_filters("ws_plugin__optimizemember_redirection_url_after_modification", false, get_defined_vars())) {
                             $paypal["optimizemember_log"][] = "Redirecting Customer to a custom URL after modification: " . $redirection_url_after_modification;
                             /**/
                             wp_redirect($redirection_url_after_modification);
                         } else {
                             $paypal["optimizemember_log"][] = "Redirecting Customer to the Login Page. They need to log back in.";
                             /**/
                             echo c_ws_plugin__optimizemember_return_templates::return_template($paypal["subscr_gateway"], '<strong>' . _x("Thank you! You've been updated to:", "s2member-front", "s2member") . '<br /><em>' . esc_html($paypal["item_name"]) . '</em></strong>', _x("Please Log Back In ( Click Here )", "s2member-front", "s2member"), wp_login_url());
                         }
                     } else {
                         $paypal["optimizemember_log"][] = "Unable to modify Subscription. The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.";
                         /**/
                         $paypal["optimizemember_log"][] = "Redirecting Customer to the Home Page, due to an error that occurred.";
                         /**/
                         echo c_ws_plugin__optimizemember_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />The existing User ID is associated with an Administrator. Stopping here. Otherwise, an Administrator could lose access. Please make sure that you are NOT logged in as an Administrator while testing.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                     }
                 } else {
                     $paypal["optimizemember_log"][] = "Unable to modify Subscription. Could not get the existing User ID from the DB.";
                     /**/
                     $paypal["optimizemember_log"][] = "Redirecting Customer to the Home Page, due to an error that occurred.";
                     /**/
                     echo c_ws_plugin__optimizemember_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unable to modify Subscription.<br />Please contact Support for assistance.<br /><br />Could not get the existing User ID from the DB.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
                 }
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_paypal_return_after_subscr_signup_w_update_vars", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
             } else {
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_paypal_return_before_subscr_signup_wo_update_vars", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
                 /**/
                 $processing = $during = true;
                 /* Yes, we ARE processing this new Subscription request. */
                 /**/
                 $paypal["optimizemember_log"][] = "optimizeMember `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
                 /**/
                 setcookie("optimizemember_subscr_gateway", $optimizemember_subscr_gateway = c_ws_plugin__optimizemember_utils_encryption::encrypt($paypal["subscr_gateway"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_subscr_gateway", $optimizemember_subscr_gateway, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_subscr_gateway"] = $optimizemember_subscr_gateway);
                 setcookie("optimizemember_subscr_id", $optimizemember_subscr_id = c_ws_plugin__optimizemember_utils_encryption::encrypt($paypal["subscr_id"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_subscr_id", $optimizemember_subscr_id, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_subscr_id"] = $optimizemember_subscr_id);
                 setcookie("optimizemember_custom", $optimizemember_custom = c_ws_plugin__optimizemember_utils_encryption::encrypt($paypal["custom"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_custom", $optimizemember_custom, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_custom"] = $optimizemember_custom);
                 setcookie("optimizemember_item_number", $optimizemember_item_number = c_ws_plugin__optimizemember_utils_encryption::encrypt($paypal["item_number"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_item_number", $optimizemember_item_number, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_item_number"] = $optimizemember_item_number);
                 /**/
                 $paypal["optimizemember_log"][] = "Registration Cookies set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
                 /**/
                 setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($paypal["subscr_id"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                 /**/
                 $paypal["optimizemember_log"][] = "Transient Tracking Cookie set on ( `web_accept|subscr_signup|subscr_payment` ) w/o update vars.";
                 /**/
                 if ($processing && $tracking_properties && ($code = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["signup_tracking_codes"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
                     if (($code = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace("/%%subscr_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["subscr_id"]), $code))) {
                         if (($code = preg_replace("/%%initial%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["initial"]), $code)) && ($code = preg_replace("/%%regular%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["regular"]), $code)) && ($code = preg_replace("/%%recurring%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["recurring"]), $code))) {
                             if (($code = preg_replace("/%%initial_term%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["initial_term"]), $code)) && ($code = preg_replace("/%%regular_term%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["regular_term"]), $code))) {
                                 if (($code = preg_replace("/%%item_number%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["item_number"]), $code)) && ($code = preg_replace("/%%item_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["item_name"]), $code))) {
                                     if (($code = preg_replace("/%%first_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["first_name"]), $code)) && ($code = preg_replace("/%%last_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["last_name"]), $code))) {
                                         if ($code = preg_replace("/%%full_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $code)) {
                                             if ($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["payer_email"]), $code)) {
                                                 if ($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__optimizemember_utils_strings::esc_ds($paypal["ip"]), $code)) {
                                                     /**/
                                                     if ($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) {
                                                         $paypal["optimizemember_log"][] = "Storing Signup Tracking Codes into a Transient Queue. These will be processed on-site.";
                                                         set_transient("s2m_" . md5("optimizemember_transient_signup_tracking_codes_" . $paypal["subscr_id"]), $code, 43200);
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_paypal_return_during_subscr_signup_wo_update_vars", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
                 /**/
                 if (is_multisite() && c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() && is_main_site()) {
                     if ($redirection_url_after_mms_farm_signup = apply_filters("ws_plugin__optimizemember_redirection_url_after_mms_farm_signup", false, get_defined_vars())) {
                         $paypal["optimizemember_log"][] = "Redirecting Customer to a custom URL after signup: " . $redirection_url_after_mms_farm_signup;
                         /**/
                         wp_redirect($redirection_url_after_mms_farm_signup);
                     } else {
                         if ($custom_success_redirection) {
                             $paypal["optimizemember_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection;
                             /**/
                             wp_redirect($custom_success_redirection);
                         } else {
                             $paypal["optimizemember_log"][] = "Redirecting Customer to Signup Page. They need to Signup/Register now.";
                             /**/
                             echo c_ws_plugin__optimizemember_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Thank you! Your account has been approved.<br />The next step is to Register a Username for immediate access.</strong>', "s2member-front", "s2member"), _x("Please Register Now ( Click Here )", "s2member-front", "s2member"), c_ws_plugin__optimizemember_utils_urls::wp_signup_url());
                         }
                     }
                 } else {
                     if ($redirection_url_after_signup = apply_filters("ws_plugin__optimizemember_redirection_url_after_signup", false, get_defined_vars())) {
                         $paypal["optimizemember_log"][] = "Redirecting Customer to a custom URL after signup: " . $redirection_url_after_signup;
                         /**/
                         wp_redirect($redirection_url_after_signup);
                     } else {
                         if ($custom_success_redirection) {
                             $paypal["optimizemember_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection;
                             /**/
                             wp_redirect($custom_success_redirection);
                         } else {
                             $paypal["optimizemember_log"][] = "Redirecting Customer to Registration Page. They need to Register now.";
                             /**/
                             echo c_ws_plugin__optimizemember_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Thank you! Your account has been approved.<br />The next step is to Register a Username for immediate access.</strong>', "s2member-front", "s2member"), _x("Please Register Now ( Click Here )", "s2member-front", "s2member"), c_ws_plugin__optimizemember_utils_urls::wp_register_url());
                         }
                     }
                 }
                 /**/
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__optimizemember_during_paypal_return_after_subscr_signup_wo_update_vars", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
             }
         } else {
             $paypal["optimizemember_log"][] = "Page Expired. Duplicate Return-Data.";
             $paypal["optimizemember_log"][] = "optimizeMember `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
             $paypal["optimizemember_log"][] = "Page Expired. Redirecting Customer to the Home Page.";
             /**/
             echo c_ws_plugin__optimizemember_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Page Expired:</strong> Duplicate Return-Data.<br />Please contact Support if you need any assistance.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/"));
         }
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_plugin__optimizemember_during_paypal_return_after_subscr_signup", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         return apply_filters("c_ws_plugin__optimizemember_paypal_return_in_subscr_or_wa_w_level", $paypal, get_defined_vars());
     } else {
         return apply_filters("c_ws_plugin__optimizemember_paypal_return_in_subscr_or_wa_w_level", false, get_defined_vars());
     }
 }
 /**
  * Handles processing of Pro Form registrations.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_registration()
 {
     if (!empty($_POST["optimizemember_pro_paypal_registration"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_registration"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-registration")) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_registration_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_registration_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_paypal_registration"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_paypal_registration_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("registration", $post_vars))) {
                 if (!($create_user = array())) {
                     $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                     /* Fake this for registration configuration. */
                     $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                     /* Fake this for registration configuration. */
                     $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                     /* Fake this for registration configuration. */
                     $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                     /* Fake this too. */
                     /**/
                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                             $field_id_class = preg_replace("/_/", "-", $field_var);
                             /**/
                             if (isset($post_vars["custom_fields"][$field_var])) {
                                 $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                             }
                         }
                     }
                     /**/
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"] = $post_vars["attr"]["level"];
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps"] = $post_vars["attr"]["ccaps"];
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"] = $post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"];
                     $_EOT_ =& $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"];
                     /* Quick/shorter reference to this var. */
                     $_EOT_ = $post_vars["attr"]["tp"] && $post_vars["attr"]["tt"] ? date("Y-m-d H:i:s", c_ws_plugin__optimizemember_utils_time::auto_eot_time("", "", "", $_EOT_)) : "";
                     $GLOBALS["ws_plugin__optimizemember_registration_vars"]["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"] = $post_vars["attr"]["custom"];
                     unset($_EOT_);
                     /* We can unset this shorter/reference variable now. */
                     /**/
                     $GLOBALS["ws_plugin__optimizemember_registration_return_url"] = $post_vars["attr"]["success"];
                     /* Custom success return. */
                     /**/
                     $create_user["user_login"] = $post_vars["username"];
                     /* Copy this into a separate array for `wp_create_user()`. */
                     $create_user["user_pass"] = wp_generate_password();
                     /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                     $create_user["user_email"] = $post_vars["email"];
                     /* Copy this into a separate array for `wp_create_user()`. */
                 }
                 /**/
                 if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                         update_user_option($new__user_id, "default_password_nag", false, true);
                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                         /**/
                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                         /**/
                         if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__optimizemember_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__optimizemember_registration_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 } else {
                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                         update_user_option($new__user_id, "default_password_nag", true, true);
                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                         /**/
                         $global_response = array("response" => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                         /**/
                         if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__optimizemember_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__optimizemember_registration_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #12
0
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_checkout()
 {
     if (!empty($_POST['optimizemember_pro_stripe_checkout']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_checkout']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-checkout')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_checkout_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_checkout_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_checkout']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_checkout_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email(@$post_vars['email']), get_defined_vars());
         $post_vars['username'] = is_multisite() ? strtolower(@$post_vars['username']) : @$post_vars['username'];
         // Force lowercase.
         $post_vars['username'] = preg_replace('/\\s+/', '', sanitize_user($post_vars['_o_username'] = $post_vars['username'], is_multisite()));
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('checkout', $post_vars))) {
                 unset($_POST['optimizemember_pro_stripe_checkout']['card_token']);
                 // These are good one-time only.
                 unset($_POST['optimizemember_pro_stripe_checkout']['card_token_summary']);
                 $cp_attr = c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($post_vars['attr'], $post_vars['coupon'], 'attr', array('affiliates-silent-post'));
                 $cost_calculations = c_ws_plugin__optimizemember_pro_stripe_utilities::cost($cp_attr['ta'], $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc']);
                 if ($cost_calculations['total'] <= 0 && $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0) {
                     $post_vars['attr']['tp'] = '0';
                     // Ditch the trial period completely.
                     $cost_calculations['sub_total'] = $cost_calculations['trial_sub_total'];
                     // Use as regular sub-total (ditch trial sub-total).
                     $cost_calculations['tax'] = $cost_calculations['trial_tax'];
                     // Use as regular tax (ditch trial tax).
                     $cost_calculations['tax_per'] = $cost_calculations['trial_tax_per'];
                     // Use as regular tax (ditch trial tax).
                     $cost_calculations['total'] = $cost_calculations['trial_total'];
                     // Use as regular total (ditch trial).
                     $cost_calculations['trial_sub_total'] = '0.00';
                     // Ditch the initial total (using as grand total).
                     $cost_calculations['trial_tax'] = '0.00';
                     // Ditch this calculation now also.
                     $cost_calculations['trial_tax_per'] = '';
                     // Ditch this calculation now also.
                     $cost_calculations['trial_total'] = '0.00';
                     // Ditch this calculation now also.
                 }
                 $use_subscription = $post_vars['attr']['rr'] === 'BN' || !$post_vars['attr']['tp'] && !$post_vars['attr']['rr'] ? FALSE : TRUE;
                 $is_independent_ccaps_sale = $post_vars['attr']['level'] === '*' ? TRUE : FALSE;
                 // Selling Independent Custom Capabilities?
                 if ($use_subscription && $cost_calculations['trial_total'] <= 0 && $cost_calculations['total'] <= 0) {
                     if (!$post_vars['attr']['rr'] && $post_vars['attr']['rt'] !== 'L') {
                         if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 1) {
                             $post_vars['attr']['level_ccaps_eotper'] .= ':' . $post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt'];
                         } else {
                             if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 0) {
                                 $post_vars['attr']['level_ccaps_eotper'] .= '::' . $post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt'];
                             }
                         }
                     } else {
                         if ($post_vars['attr']['rr'] && $post_vars['attr']['rrt'] && $post_vars['attr']['rt'] !== 'L') {
                             if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 1) {
                                 $post_vars['attr']['level_ccaps_eotper'] .= ':' . $post_vars['attr']['rp'] * $post_vars['attr']['rrt'] . ' ' . $post_vars['attr']['rt'];
                             } else {
                                 if (substr_count($post_vars['attr']['level_ccaps_eotper'], ':') === 0) {
                                     $post_vars['attr']['level_ccaps_eotper'] .= '::' . $post_vars['attr']['rp'] * $post_vars['attr']['rrt'] . ' ' . $post_vars['attr']['rt'];
                                 }
                             }
                         }
                     }
                 }
                 if ($use_subscription && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     $plan_attr = $cp_attr;
                     // For the subscription plan.
                     $plan_attr['ta'] = $cost_calculations['trial_total'];
                     $plan_attr['ra'] = $cost_calculations['total'];
                     $plan_attr['desc'] = $cost_calculations['desc'];
                     update_user_meta($user_id, 'first_name', $post_vars['first_name']);
                     update_user_meta($user_id, 'last_name', $post_vars['last_name']);
                     $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt']);
                     $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt']);
                     $start_time = $post_vars['attr']['tp'] ? c_ws_plugin__optimizemember_pro_stripe_utilities::start_time($period1) : c_ws_plugin__optimizemember_pro_stripe_utilities::start_time($period3);
                     // Or next billing cycle.
                     if (!$global_response) {
                         if ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 || !$post_vars['attr']['tp'] && $cost_calculations['total'] > 0) {
                             if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name']))) {
                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                             } else {
                                 if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if (!is_object($stripe_charge = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc']))) {
                                         $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                     } else {
                                         $new__txn_cid = $stripe_customer->id;
                                         $new__txn_id = $stripe_charge->id;
                                     }
                                 }
                             }
                         }
                     }
                     if (!$global_response) {
                         if ($cost_calculations['total'] > 0) {
                             if (!is_object($stripe_plan = c_ws_plugin__optimizemember_pro_stripe_utilities::get_plan($plan_attr))) {
                                 $global_response = array('response' => $stripe_plan, 'error' => TRUE);
                             } else {
                                 if ((!isset($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name']))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if ((!isset($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id))) {
                                             $global_response = array('response' => $stripe_subscription, 'error' => TRUE);
                                         } else {
                                             $new__subscr_cid = $stripe_customer->id;
                                             $new__subscr_id = $stripe_subscription->id;
                                         }
                                     }
                                 }
                             }
                             if ($global_response && !empty($new__txn_id)) {
                                 $global_response = array();
                                 $stripe_subscription_failed_charge_succeeded = TRUE;
                             }
                         }
                     }
                     if (!$global_response) {
                         $old__subscr_cid = get_user_option('optimizemember_subscr_cid');
                         $old__subscr_id = get_user_option('optimizemember_subscr_id');
                         $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                         if (empty($new__subscr_cid)) {
                             $new__subscr_cid = strtoupper('free-' . uniqid());
                         }
                         if (empty($new__subscr_id)) {
                             $new__subscr_id = strtoupper('free-' . uniqid());
                         }
                         $ipn['txn_type'] = 'subscr_signup';
                         $ipn['subscr_cid'] = $new__subscr_cid;
                         $ipn['subscr_id'] = $new__subscr_id;
                         $ipn['custom'] = $post_vars['attr']['custom'];
                         $ipn['txn_cid'] = !empty($new__txn_cid) ? $new__txn_cid : $new__subscr_cid;
                         $ipn['txn_id'] = !empty($new__txn_id) ? $new__txn_id : $new__subscr_id;
                         $ipn['period1'] = $period1;
                         $ipn['period3'] = $period3;
                         $ipn['mc_amount1'] = $cost_calculations['trial_total'];
                         $ipn['mc_amount3'] = $cost_calculations['total'];
                         $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                         $ipn['mc_currency'] = $cost_calculations['cur'];
                         $ipn['tax'] = $cost_calculations['tax'];
                         $ipn['recurring'] = $post_vars['attr']['rr'] ? '1' : '';
                         $ipn['payer_email'] = $user->user_email;
                         $ipn['first_name'] = $post_vars['first_name'];
                         $ipn['last_name'] = $post_vars['last_name'];
                         $ipn['option_name1'] = 'Referencing Customer ID';
                         $ipn['option_selection1'] = $old__subscr_or_wp_id;
                         $ipn['option_name2'] = 'Customer IP Address';
                         $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                         $ipn['item_name'] = $cost_calculations['desc'];
                         $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                         $ipn['optimizemember_paypal_proxy'] = 'stripe';
                         $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                         $ipn['optimizemember_paypal_proxy_use'] .= $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 && $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                         $ipn['optimizemember_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                         $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                         $ipn['optimizemember_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                         $ipn['optimizemember_stripe_proxy_return_url'] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20)));
                         if (!empty($stripe_subscription_failed_charge_succeeded)) {
                             update_user_option($user_id, 'optimizemember_auto_eot_time', $start_time);
                         }
                         if ($old__subscr_cid && $old__subscr_id && apply_filters('optimizemember_pro_cancels_old_rp_before_new_rp', TRUE, get_defined_vars())) {
                             c_ws_plugin__optimizemember_pro_stripe_utilities::cancel_customer_subscription($old__subscr_cid, $old__subscr_id, FALSE);
                         }
                         c_ws_plugin__optimizemember_list_servers::process_list_servers_against_current_user((bool) @$post_vars['custom_fields']['opt_in'], TRUE, TRUE);
                         setcookie('optimizemember_tracking', $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('optimizemember_tracking', $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['optimizemember_tracking'] = $optimizemember_tracking);
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been updated :-)', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                         if ($post_vars['attr']['success'] && substr($ipn['optimizemember_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['optimizemember_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     }
                 } else {
                     if ($use_subscription && !is_user_logged_in()) {
                         $plan_attr = $cp_attr;
                         // For the subscription plan.
                         $plan_attr['ta'] = $cost_calculations['trial_total'];
                         $plan_attr['ra'] = $cost_calculations['total'];
                         $plan_attr['desc'] = $cost_calculations['desc'];
                         $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt']);
                         $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars['attr']['rp'] . ' ' . $post_vars['attr']['rt']);
                         $start_time = $post_vars['attr']['tp'] ? c_ws_plugin__optimizemember_pro_stripe_utilities::start_time($period1) : c_ws_plugin__optimizemember_pro_stripe_utilities::start_time($period3);
                         // Or next billing cycle.
                         if (!$global_response) {
                             if ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 || !$post_vars['attr']['tp'] && $cost_calculations['total'] > 0) {
                                 if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name']))) {
                                     $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                 } else {
                                     if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_charge = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc']))) {
                                             $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                         } else {
                                             $new__txn_cid = $stripe_customer->id;
                                             $new__txn_id = $stripe_charge->id;
                                         }
                                     }
                                 }
                             }
                         }
                         if (!$global_response) {
                             if ($cost_calculations['total'] > 0) {
                                 if (!is_object($stripe_plan = c_ws_plugin__optimizemember_pro_stripe_utilities::get_plan($plan_attr))) {
                                     $global_response = array('response' => $stripe_plan, 'error' => TRUE);
                                 } else {
                                     if ((!isset($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if ((!isset($stripe_customer) || !is_object($stripe_customer)) && !is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id))) {
                                                 $global_response = array('response' => $stripe_subscription, 'error' => TRUE);
                                             } else {
                                                 $new__subscr_cid = $stripe_customer->id;
                                                 $new__subscr_id = $stripe_subscription->id;
                                             }
                                         }
                                     }
                                 }
                                 if ($global_response && !empty($new__txn_id)) {
                                     $global_response = array();
                                     $stripe_subscription_failed_charge_succeeded = TRUE;
                                 }
                             }
                         }
                         if (!$global_response) {
                             if (empty($new__subscr_cid)) {
                                 $new__subscr_cid = strtoupper('free-' . uniqid());
                             }
                             if (empty($new__subscr_id)) {
                                 $new__subscr_id = strtoupper('free-' . uniqid());
                             }
                             $ipn['txn_type'] = 'subscr_signup';
                             $ipn['subscr_cid'] = $new__subscr_cid;
                             $ipn['subscr_id'] = $new__subscr_id;
                             $ipn['custom'] = $post_vars['attr']['custom'];
                             $ipn['txn_cid'] = !empty($new__txn_cid) ? $new__txn_cid : $new__subscr_cid;
                             $ipn['txn_id'] = !empty($new__txn_id) ? $new__txn_id : $new__subscr_id;
                             $ipn['period1'] = $period1;
                             $ipn['period3'] = $period3;
                             $ipn['mc_amount1'] = $cost_calculations['trial_total'];
                             $ipn['mc_amount3'] = $cost_calculations['total'];
                             $ipn['mc_gross'] = preg_match('/^[1-9]/', $ipn['period1']) ? $ipn['mc_amount1'] : $ipn['mc_amount3'];
                             $ipn['mc_currency'] = $cost_calculations['cur'];
                             $ipn['tax'] = $cost_calculations['tax'];
                             $ipn['recurring'] = $post_vars['attr']['rr'] ? '1' : '';
                             $ipn['payer_email'] = $post_vars['email'];
                             $ipn['first_name'] = $post_vars['first_name'];
                             $ipn['last_name'] = $post_vars['last_name'];
                             $ipn['option_name1'] = 'Originating Domain';
                             $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                             $ipn['option_name2'] = 'Customer IP Address';
                             $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                             $ipn['item_name'] = $cost_calculations['desc'];
                             $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                             $ipn['optimizemember_paypal_proxy'] = 'stripe';
                             $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                             $ipn['optimizemember_paypal_proxy_use'] .= $post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0 && $ipn['mc_gross'] > 0 ? ',subscr-signup-as-subscr-payment' : '';
                             $ipn['optimizemember_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                             $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                             $ipn['optimizemember_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_user_pass1'] = $post_vars['password1'];
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_first_name'] = $post_vars['first_name'];
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_last_name'] = $post_vars['last_name'];
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                             if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields']) {
                                 foreach (json_decode($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields'], TRUE) as $field) {
                                     $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                     $field_id_class = preg_replace('/_/', '-', $field_var);
                                     if (isset($post_vars['custom_fields'][$field_var])) {
                                         $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                                     }
                                 }
                             }
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_gateway'] = 'stripe';
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_cid'] = $new__subscr_cid;
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_id'] = $new__subscr_id;
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_level'] = $post_vars['attr']['level'];
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps'] = $post_vars['attr']['ccaps'];
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_custom'] = $post_vars['attr']['custom'];
                             @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $post_vars['attr']['level_ccaps_eotper'], 3));
                             if (!empty($eotper)) {
                                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time'] = date('Y-m-d H:i:s', c_ws_plugin__optimizemember_utils_time::auto_eot_time('', '', '', $eotper));
                             }
                             $create_user['user_email'] = $post_vars['email'];
                             // Copy this into a separate array for `wp_create_user()`.
                             $create_user['user_login'] = $post_vars['username'];
                             // Copy this into a separate array for `wp_create_user()`.
                             $create_user['user_pass'] = wp_generate_password();
                             // Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`.
                             $has_custom_password = $post_vars['password1'] && $post_vars['password1'] === $create_user['user_pass'];
                             if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                                 update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                                 wp_new_user_notification($new__user_id, $create_user['user_pass']);
                                 if (!empty($stripe_subscription_failed_charge_succeeded)) {
                                     update_user_option($new__user_id, 'optimizemember_auto_eot_time', $start_time);
                                 }
                                 $ipn['optimizemember_stripe_proxy_return_url'] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                 setcookie('optimizemember_tracking', $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('optimizemember_tracking', $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['optimizemember_tracking'] = $optimizemember_tracking);
                                 if ($has_custom_password) {
                                     $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                 } else {
                                     $global_response = array('response' => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                                 }
                                 if ($post_vars['attr']['success'] && substr($ipn['optimizemember_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['optimizemember_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             } else {
                                 c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20));
                                 $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                             }
                         }
                     } else {
                         if (!$use_subscription && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                             update_user_meta($user_id, 'first_name', $post_vars['first_name']);
                             update_user_meta($user_id, 'last_name', $post_vars['last_name']);
                             if (!$global_response) {
                                 if ($cost_calculations['total'] > 0) {
                                     if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name']))) {
                                         $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                     } else {
                                         if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_charge = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc']))) {
                                                 $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                             } else {
                                                 $new__txn_cid = $stripe_customer->id;
                                                 $new__txn_id = $stripe_charge->id;
                                             }
                                         }
                                     }
                                 }
                             }
                             if (!$global_response) {
                                 $old__subscr_cid = get_user_option('optimizemember_subscr_cid');
                                 $old__subscr_id = get_user_option('optimizemember_subscr_id');
                                 $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                                 if (empty($new__txn_cid)) {
                                     $new__txn_cid = strtoupper('free-' . uniqid());
                                 }
                                 if (empty($new__txn_id)) {
                                     $new__txn_id = strtoupper('free-' . uniqid());
                                 }
                                 $ipn['txn_type'] = 'web_accept';
                                 $ipn['txn_cid'] = $new__txn_cid;
                                 $ipn['txn_id'] = $new__txn_id;
                                 $ipn['custom'] = $post_vars['attr']['custom'];
                                 $ipn['mc_gross'] = $cost_calculations['total'];
                                 $ipn['mc_currency'] = $cost_calculations['cur'];
                                 $ipn['tax'] = $cost_calculations['tax'];
                                 $ipn['payer_email'] = $user->user_email;
                                 $ipn['first_name'] = $post_vars['first_name'];
                                 $ipn['last_name'] = $post_vars['last_name'];
                                 $ipn['option_name1'] = 'Referencing Customer ID';
                                 $ipn['option_selection1'] = $old__subscr_or_wp_id;
                                 $ipn['option_name2'] = 'Customer IP Address';
                                 $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                                 $ipn['item_name'] = $cost_calculations['desc'];
                                 $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                                 $ipn['optimizemember_paypal_proxy'] = 'stripe';
                                 $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                                 $ipn['optimizemember_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                                 $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                                 $ipn['optimizemember_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                                 $ipn['optimizemember_stripe_proxy_return_url'] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                 if (!$is_independent_ccaps_sale) {
                                     // Independent?
                                     if ($old__subscr_cid && $old__subscr_id && apply_filters('optimizemember_pro_cancels_old_rp_before_new_rp', TRUE, get_defined_vars())) {
                                         c_ws_plugin__optimizemember_pro_stripe_utilities::cancel_customer_subscription($old__subscr_cid, $old__subscr_id, FALSE);
                                     }
                                 }
                                 c_ws_plugin__optimizemember_list_servers::process_list_servers_against_current_user((bool) @$post_vars['custom_fields']['opt_in'], TRUE, TRUE);
                                 setcookie('optimizemember_tracking', $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('optimizemember_tracking', $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['optimizemember_tracking'] = $optimizemember_tracking);
                                 $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been updated :-)', 's2member-front', 's2member'), esc_attr(wp_login_url())));
                                 if ($post_vars['attr']['success'] && substr($ipn['optimizemember_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['optimizemember_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             }
                         } else {
                             if (!$use_subscription && !is_user_logged_in()) {
                                 if (!$global_response) {
                                     if ($cost_calculations['total'] > 0) {
                                         if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name']))) {
                                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                         } else {
                                             if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                                             } else {
                                                 if (!is_object($stripe_charge = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc']))) {
                                                     $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                                 } else {
                                                     $new__txn_cid = $stripe_customer->id;
                                                     $new__txn_id = $stripe_charge->id;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 if (!$global_response) {
                                     if (empty($new__txn_cid)) {
                                         $new__txn_cid = strtoupper('free-' . uniqid());
                                     }
                                     if (empty($new__txn_id)) {
                                         $new__txn_id = strtoupper('free-' . uniqid());
                                     }
                                     $ipn['txn_type'] = 'web_accept';
                                     $ipn['txn_cid'] = $new__txn_cid;
                                     $ipn['txn_id'] = $new__txn_id;
                                     $ipn['custom'] = $post_vars['attr']['custom'];
                                     $ipn['mc_gross'] = $cost_calculations['total'];
                                     $ipn['mc_currency'] = $cost_calculations['cur'];
                                     $ipn['tax'] = $cost_calculations['tax'];
                                     $ipn['payer_email'] = $post_vars['email'];
                                     $ipn['first_name'] = $post_vars['first_name'];
                                     $ipn['last_name'] = $post_vars['last_name'];
                                     $ipn['option_name1'] = 'Originating Domain';
                                     $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                                     $ipn['option_name2'] = 'Customer IP Address';
                                     $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                                     $ipn['item_name'] = $cost_calculations['desc'];
                                     $ipn['item_number'] = $post_vars['attr']['level_ccaps_eotper'];
                                     $ipn['optimizemember_paypal_proxy'] = 'stripe';
                                     $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                                     $ipn['optimizemember_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                                     $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                                     $ipn['optimizemember_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_user_pass1'] = $post_vars['password1'];
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_first_name'] = $post_vars['first_name'];
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_last_name'] = $post_vars['last_name'];
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                                     if ($GLOBALS['WS_PLUGIN__']['']['o']['custom_reg_fields']) {
                                         foreach (json_decode($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields'], TRUE) as $field) {
                                             $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                             $field_id_class = preg_replace('/_/', '-', $field_var);
                                             if (isset($post_vars['custom_fields'][$field_var])) {
                                                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                                             }
                                         }
                                     }
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_gateway'] = 'stripe';
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_cid'] = $new__txn_cid;
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_id'] = $new__txn_id;
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_level'] = $post_vars['attr']['level'];
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps'] = $post_vars['attr']['ccaps'];
                                     $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_custom'] = $post_vars['attr']['custom'];
                                     @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $post_vars['attr']['level_ccaps_eotper'], 3));
                                     if (!empty($eotper)) {
                                         $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time'] = date('Y-m-d H:i:s', c_ws_plugin__optimizemember_utils_time::auto_eot_time('', '', '', $eotper));
                                     }
                                     $create_user['user_email'] = $post_vars['email'];
                                     // Copy this into a separate array for `wp_create_user()`.
                                     $create_user['user_login'] = $post_vars['username'];
                                     // Copy this into a separate array for `wp_create_user()`.
                                     $create_user['user_pass'] = wp_generate_password();
                                     // Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`.
                                     $has_custom_password = $post_vars['password1'] && $post_vars['password1'] === $create_user['user_pass'];
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                                         update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                                         wp_new_user_notification($new__user_id, $create_user['user_pass']);
                                         $ipn['optimizemember_stripe_proxy_return_url'] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20)));
                                         setcookie('optimizemember_tracking', $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('optimizemember_tracking', $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['optimizemember_tracking'] = $optimizemember_tracking);
                                         if ($has_custom_password) {
                                             $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', 'optimizemember-front', 's2member'), esc_attr(wp_login_url())));
                                         } else {
                                             $global_response = array('response' => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                                         }
                                         if ($post_vars['attr']['success'] && substr($ipn['optimizemember_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['optimizemember_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20));
                                         $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                                     }
                                 }
                             } else {
                                 $global_response = array('response' => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                             }
                         }
                     }
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
예제 #13
0
 /**
  * Handles processing of Pro Form billing updates.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_update()
 {
     if (!empty($_POST["optimizemember_pro_authnet_update"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_authnet_update"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-update")) {
         $GLOBALS["ws_plugin__optimizemember_pro_authnet_update_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_authnet_update_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_authnet_update"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_authnet_update_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_submission_validation_errors("update", $post_vars))) {
                 if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $cur__subscr_id = get_user_option("optimizemember_subscr_id"))) {
                         if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && preg_match("/^(active|suspended)\$/i", $authnet["subscription_status"])) {
                             $authnet = array();
                             /* Reset the Authorize.Net array. */
                             /**/
                             $authnet["x_method"] = "update";
                             $authnet["x_subscription_id"] = $cur__subscr_id;
                             /**/
                             $authnet["x_email"] = $user->user_email;
                             $authnet["x_first_name"] = $user->first_name;
                             $authnet["x_last_name"] = $user->last_name;
                             /**/
                             $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                             $authnet["x_card_code"] = $post_vars["card_verification"];
                             /**/
                             #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                             #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                             #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                             #	else /* Otherwise, we assume they provided an issue number instead. */
                             #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                             /**/
                             $authnet["x_address"] = $post_vars["street"];
                             $authnet["x_city"] = $post_vars["city"];
                             $authnet["x_state"] = $post_vars["state"];
                             $authnet["x_country"] = $post_vars["country"];
                             $authnet["x_zip"] = $post_vars["zip"];
                             /**/
                             if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"])) {
                                 $global_response = array("response" => _x('<strong>Confirmed.</strong> Your billing information has been updated.', "s2member-front", "s2member"));
                                 /**/
                                 if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             } else {
                                 $global_response = array("response" => $authnet["__error"], "error" => true);
                             }
                         } else {
                             if ($authnet && empty($authnet["__error"]) && !preg_match("/^(active|suspended)\$/i", $authnet["subscription_status"])) {
                                 $global_response = array("response" => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
                             } else {
                                 $global_response = array("response" => $authnet["__error"], "error" => true);
                             }
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> No Subscr. ID. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 } else {
                     $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #14
0
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  *
  * @todo Add support for `rrt=""` Attribute.
  * @todo Build in routine to void first payment if Recurring Profile creation fails for some reason? Seems logical, even though highly unlikely.
  */
 public static function authnet_checkout()
 {
     if (!empty($_POST["optimizemember_pro_authnet_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_authnet_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-checkout")) {
         $GLOBALS["ws_plugin__optimizemember_pro_authnet_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_authnet_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_authnet_checkout"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_authnet_checkout_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         if (!c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_submission_validation_errors("checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cost_calculations = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_cost($cp_attr["ta"], $cp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_attr["cc"], $cp_attr["desc"]);
                 /**/
                 $use_recurring_profile = $post_vars["attr"]["rr"] === "BN" || !$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"] ? false : true;
                 $is_independent_ccaps_sale = $post_vars["attr"]["level"] === "*" ? true : false;
                 /* Selling Independent Custom Capabilities? */
                 /**/
                 if ($use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                     $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                     /**/
                     $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_start_time($period1) : c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_start_time($period3);
                     /* Or next billing cycle. */
                     /**/
                     $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                     /**/
                     update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                     /**/
                     if (!($_authnet = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                         $_authnet["x_type"] = "AUTH_CAPTURE";
                         $_authnet["x_method"] = "CC";
                         /**/
                         $_authnet["x_email"] = $user->user_email;
                         $_authnet["x_first_name"] = $post_vars["first_name"];
                         $_authnet["x_last_name"] = $post_vars["last_name"];
                         $_authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                         /**/
                         $_authnet["x_invoice_num"] = "s2-" . uniqid();
                         $_authnet["x_description"] = $cost_calculations["desc"];
                         /**/
                         $_authnet["s2_initial_payment"] = "1";
                         /* Initial. */
                         /**/
                         $_authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                         $_authnet["s2_custom"] = $post_vars["attr"]["custom"];
                         /**/
                         if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                             $_authnet["x_tax"] = $cost_calculations["trial_tax"];
                             $_authnet["x_amount"] = $cost_calculations["trial_total"];
                         } else {
                             $_authnet["x_tax"] = $cost_calculations["tax"];
                             $_authnet["x_amount"] = $cost_calculations["total"];
                         }
                         /**/
                         $_authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                         $_authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                         $_authnet["x_card_code"] = $post_vars["card_verification"];
                         /**/
                         #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                         #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                         #		$_authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                         #	else /* Otherwise, we assume they provided an issue number instead. */
                         #		$_authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                         /**/
                         $_authnet["x_address"] = $post_vars["street"];
                         $_authnet["x_city"] = $post_vars["city"];
                         $_authnet["x_state"] = $post_vars["state"];
                         $_authnet["x_country"] = $post_vars["country"];
                         $_authnet["x_zip"] = $post_vars["zip"];
                     }
                     /**/
                     if (!($authnet = array())) {
                         $authnet["x_method"] = "create";
                         /**/
                         $authnet["x_email"] = $user->user_email;
                         $authnet["x_first_name"] = $post_vars["first_name"];
                         $authnet["x_last_name"] = $post_vars["last_name"];
                         $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                         /**/
                         $authnet["x_invoice_num"] = $_authnet ? $_authnet["x_invoice_num"] : "s2-" . uniqid();
                         $authnet["x_description"] = $cost_calculations["desc"];
                         $authnet["x_description"] .= " ((" . $reference . "))";
                         /**/
                         $authnet["x_amount"] = $cost_calculations["total"];
                         /**/
                         $authnet["x_start_date"] = date("Y-m-d", $start_time);
                         /**/
                         $authnet["x_unit"] = "days";
                         /* Always calculated in days. */
                         $authnet["x_length"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_per_term_2_days($post_vars["attr"]["rp"], $post_vars["attr"]["rt"]);
                         $authnet["x_total_occurrences"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "9999" : "1";
                         /**/
                         $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                         $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                         $authnet["x_card_code"] = $post_vars["card_verification"];
                         /**/
                         #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                         #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                         #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                         #	else /* Otherwise, we assume they provided an issue number instead. */
                         #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                         /**/
                         $authnet["x_address"] = $post_vars["street"];
                         $authnet["x_city"] = $post_vars["city"];
                         $authnet["x_state"] = $post_vars["state"];
                         $authnet["x_country"] = $post_vars["country"];
                         $authnet["x_zip"] = $post_vars["zip"];
                     }
                     /**/
                     if (!$_authnet || ($_authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_aim_response($_authnet)) && empty($_authnet["__error"])) {
                         if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet)) && (empty($authnet["__error"]) || $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")) {
                             /* $authnet["response_reason_code"] === "E00018" ... Card expires before start time. */
                             /**/
                             $new__txn_id = $_authnet && !empty($_authnet["transaction_id"]) ? $_authnet["transaction_id"] : false;
                             $new__subscr_id = $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018" ? $new__txn_id : $authnet["subscription_id"];
                             $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                             $old__subscr_id = get_user_option("optimizemember_subscr_id");
                             /**/
                             if (!($ipn = array())) {
                                 $ipn["txn_type"] = "subscr_signup";
                                 $ipn["subscr_id"] = $new__subscr_id;
                                 $ipn["custom"] = $post_vars["attr"]["custom"];
                                 /**/
                                 $ipn["txn_id"] = $new__txn_id ? $new__txn_id : $new__subscr_id;
                                 /**/
                                 $ipn["period1"] = $period1;
                                 $ipn["period3"] = $period3;
                                 /**/
                                 $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                 $ipn["mc_amount3"] = $cost_calculations["total"];
                                 /**/
                                 $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                 /**/
                                 $ipn["mc_currency"] = $cost_calculations["cur"];
                                 $ipn["tax"] = $cost_calculations["tax"];
                                 /**/
                                 $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                 /**/
                                 $ipn["payer_email"] = $user->user_email;
                                 $ipn["first_name"] = $post_vars["first_name"];
                                 $ipn["last_name"] = $post_vars["last_name"];
                                 /**/
                                 $ipn["option_name1"] = "Referencing Customer ID";
                                 $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                 /**/
                                 $ipn["option_name2"] = "Customer IP Address";
                                 $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                 /**/
                                 $ipn["item_name"] = $cost_calculations["desc"];
                                 $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                 /**/
                                 $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                                 $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                 /* Use as first payment? */
                                 $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                 $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                 /**/
                                 $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                             }
                             /**/
                             if ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") {
                                 update_user_option($user_id, "optimizemember_auto_eot_time", $start_time);
                             }
                             /**/
                             if (($authnet = array("x_method" => "cancel")) && ($authnet["x_subscription_id"] = $old__subscr_id)) {
                                 c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet);
                             }
                             /**/
                             setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                             /**/
                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                             /**/
                             if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                             }
                         } else {
                             $global_response = array("response" => $authnet["__error"], "error" => true);
                         }
                     } else {
                         $global_response = array("response" => $_authnet["__error"], "error" => true);
                     }
                 } else {
                     if ($use_recurring_profile && !is_user_logged_in()) {
                         $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                         $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                         /**/
                         $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_start_time($period1) : c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_start_time($period3);
                         /* Or next billing cycle. */
                         /**/
                         $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                         /**/
                         if (!($_authnet = array()) && (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0)) {
                             $_authnet["x_type"] = "AUTH_CAPTURE";
                             $_authnet["x_method"] = "CC";
                             /**/
                             $_authnet["x_email"] = $post_vars["email"];
                             $_authnet["x_first_name"] = $post_vars["first_name"];
                             $_authnet["x_last_name"] = $post_vars["last_name"];
                             $_authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                             /**/
                             $_authnet["x_invoice_num"] = "s2-" . uniqid();
                             $_authnet["x_description"] = $cost_calculations["desc"];
                             /**/
                             $_authnet["s2_initial_payment"] = "1";
                             /* Initial. */
                             /**/
                             $_authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                             $_authnet["s2_custom"] = $post_vars["attr"]["custom"];
                             /**/
                             if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $_authnet["x_tax"] = $cost_calculations["trial_tax"];
                                 $_authnet["x_amount"] = $cost_calculations["trial_total"];
                             } else {
                                 $_authnet["x_tax"] = $cost_calculations["tax"];
                                 $_authnet["x_amount"] = $cost_calculations["total"];
                             }
                             /**/
                             $_authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $_authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                             $_authnet["x_card_code"] = $post_vars["card_verification"];
                             /**/
                             #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                             #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                             #		$_authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                             #	else /* Otherwise, we assume they provided an issue number instead. */
                             #		$_authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                             /**/
                             $_authnet["x_address"] = $post_vars["street"];
                             $_authnet["x_city"] = $post_vars["city"];
                             $_authnet["x_state"] = $post_vars["state"];
                             $_authnet["x_country"] = $post_vars["country"];
                             $_authnet["x_zip"] = $post_vars["zip"];
                         }
                         /**/
                         if (!($authnet = array())) {
                             $authnet["x_method"] = "create";
                             /**/
                             $authnet["x_email"] = $post_vars["email"];
                             $authnet["x_first_name"] = $post_vars["first_name"];
                             $authnet["x_last_name"] = $post_vars["last_name"];
                             $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                             /**/
                             $authnet["x_invoice_num"] = $_authnet ? $_authnet["x_invoice_num"] : "s2-" . uniqid();
                             $authnet["x_description"] = $cost_calculations["desc"];
                             $authnet["x_description"] .= " ((" . $reference . "))";
                             /**/
                             $authnet["x_amount"] = $cost_calculations["total"];
                             /**/
                             $authnet["x_start_date"] = date("Y-m-d", $start_time);
                             /**/
                             $authnet["x_unit"] = "days";
                             /* Always calculated in days. */
                             $authnet["x_length"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_per_term_2_days($post_vars["attr"]["rp"], $post_vars["attr"]["rt"]);
                             $authnet["x_total_occurrences"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "9999" : "1";
                             /**/
                             $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                             $authnet["x_card_code"] = $post_vars["card_verification"];
                             /**/
                             #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                             #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                             #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                             #	else /* Otherwise, we assume they provided an issue number instead. */
                             #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                             /**/
                             $authnet["x_address"] = $post_vars["street"];
                             $authnet["x_city"] = $post_vars["city"];
                             $authnet["x_state"] = $post_vars["state"];
                             $authnet["x_country"] = $post_vars["country"];
                             $authnet["x_zip"] = $post_vars["zip"];
                         }
                         /**/
                         if (!$_authnet || ($_authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_aim_response($_authnet)) && empty($_authnet["__error"])) {
                             if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet)) && (empty($authnet["__error"]) || $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018")) {
                                 /* $authnet["response_reason_code"] === "E00018" ... Card expires before start time. */
                                 /**/
                                 $new__txn_id = $_authnet && !empty($_authnet["transaction_id"]) ? $_authnet["transaction_id"] : false;
                                 $new__subscr_id = $_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018" ? $new__txn_id : $authnet["subscription_id"];
                                 /**/
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_signup";
                                     $ipn["subscr_id"] = $new__subscr_id;
                                     $ipn["custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $ipn["txn_id"] = $new__txn_id ? $new__txn_id : $new__subscr_id;
                                     /**/
                                     $ipn["period1"] = $period1;
                                     $ipn["period3"] = $period3;
                                     /**/
                                     $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                     $ipn["mc_amount3"] = $cost_calculations["total"];
                                     /**/
                                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                     /**/
                                     $ipn["mc_currency"] = $cost_calculations["cur"];
                                     $ipn["tax"] = $cost_calculations["tax"];
                                     /**/
                                     $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                     /**/
                                     $ipn["payer_email"] = $post_vars["email"];
                                     $ipn["first_name"] = $post_vars["first_name"];
                                     $ipn["last_name"] = $post_vars["last_name"];
                                     /**/
                                     $ipn["option_name1"] = "Originating Domain";
                                     $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $ipn["item_name"] = $cost_calculations["desc"];
                                     $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                     /* Use as first payment? */
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                 }
                                 /**/
                                 if (!($create_user = array())) {
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                     /* Fake this too. */
                                     /**/
                                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                             $field_id_class = preg_replace("/_/", "-", $field_var);
                                             /**/
                                             if (isset($post_vars["custom_fields"][$field_var])) {
                                                 $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                             }
                                         }
                                     }
                                     /**/
                                     $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt("authnet");
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id);
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                     /* Fake this too. */
                                     /**/
                                     $create_user["user_login"] = $post_vars["username"];
                                     /* Copy this into a separate array for `wp_create_user()`. */
                                     $create_user["user_pass"] = wp_generate_password();
                                     /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                                     $create_user["user_email"] = $post_vars["email"];
                                     /* Copy this into a separate array for `wp_create_user()`. */
                                 }
                                 /**/
                                 if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                         /**/
                                         $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         /**/
                                         if ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") {
                                             update_user_option($new__user_id, "optimizemember_auto_eot_time", $start_time);
                                         }
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 } else {
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                         update_user_option($new__user_id, "default_password_nag", true, true);
                                         /* Password nag. */
                                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                         /**/
                                         $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         /**/
                                         if ($_authnet && !empty($_authnet["transaction_id"]) && $authnet["response_reason_code"] === "E00018") {
                                             update_user_option($new__user_id, "optimizemember_auto_eot_time", $start_time);
                                         }
                                         /**/
                                         $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 }
                             } else {
                                 $global_response = array("response" => $authnet["__error"], "error" => true);
                             }
                         } else {
                             $global_response = array("response" => $_authnet["__error"], "error" => true);
                         }
                     } else {
                         if (!$use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                             update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                             /**/
                             if (!($authnet = array())) {
                                 $authnet["x_type"] = "AUTH_CAPTURE";
                                 $authnet["x_method"] = "CC";
                                 /**/
                                 $authnet["x_email"] = $user->user_email;
                                 $authnet["x_first_name"] = $post_vars["first_name"];
                                 $authnet["x_last_name"] = $post_vars["last_name"];
                                 $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                                 /**/
                                 $authnet["x_invoice_num"] = "s2-" . uniqid();
                                 $authnet["x_description"] = $cost_calculations["desc"];
                                 /**/
                                 $authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                                 $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                                 /**/
                                 $authnet["x_tax"] = $cost_calculations["tax"];
                                 $authnet["x_amount"] = $cost_calculations["total"];
                                 /**/
                                 $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                 $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                                 $authnet["x_card_code"] = $post_vars["card_verification"];
                                 /**/
                                 #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                                 #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                                 #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                 #	else /* Otherwise, we assume they provided an issue number instead. */
                                 #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                                 /**/
                                 $authnet["x_address"] = $post_vars["street"];
                                 $authnet["x_city"] = $post_vars["city"];
                                 $authnet["x_state"] = $post_vars["state"];
                                 $authnet["x_country"] = $post_vars["country"];
                                 $authnet["x_zip"] = $post_vars["zip"];
                             }
                             /**/
                             if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                                 $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                                 $old__subscr_id = get_user_option("optimizemember_subscr_id");
                                 $new__subscr_id = $new__txn_id = $authnet["transaction_id"];
                                 /**/
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "web_accept";
                                     $ipn["txn_id"] = $new__subscr_id;
                                     $ipn["custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $ipn["mc_gross"] = $cost_calculations["total"];
                                     $ipn["mc_currency"] = $cost_calculations["cur"];
                                     $ipn["tax"] = $cost_calculations["tax"];
                                     /**/
                                     $ipn["payer_email"] = $user->user_email;
                                     $ipn["first_name"] = $post_vars["first_name"];
                                     $ipn["last_name"] = $post_vars["last_name"];
                                     /**/
                                     $ipn["option_name1"] = "Referencing Customer ID";
                                     $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $ipn["item_name"] = $cost_calculations["desc"];
                                     $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                     /**/
                                     $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                 }
                                 /**/
                                 if (!$is_independent_ccaps_sale) {
                                     /* Independent? */
                                     if (($authnet = array("x_method" => "cancel")) && ($authnet["x_subscription_id"] = $old__subscr_id)) {
                                         c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_arb_response($authnet);
                                     }
                                 }
                                 /**/
                                 setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                                 /**/
                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                 /**/
                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             } else {
                                 $global_response = array("response" => $authnet["__error"], "error" => true);
                             }
                         } else {
                             if (!$use_recurring_profile && !is_user_logged_in()) {
                                 if (!($authnet = array())) {
                                     $authnet["x_type"] = "AUTH_CAPTURE";
                                     $authnet["x_method"] = "CC";
                                     /**/
                                     $authnet["x_email"] = $post_vars["email"];
                                     $authnet["x_first_name"] = $post_vars["first_name"];
                                     $authnet["x_last_name"] = $post_vars["last_name"];
                                     $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $authnet["x_invoice_num"] = "s2-" . uniqid();
                                     $authnet["x_description"] = $cost_calculations["desc"];
                                     /**/
                                     $authnet["s2_invoice"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $authnet["x_tax"] = $cost_calculations["tax"];
                                     $authnet["x_amount"] = $cost_calculations["total"];
                                     /**/
                                     $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                                     $authnet["x_card_code"] = $post_vars["card_verification"];
                                     /**/
                                     #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                                     #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                                     #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                     #	else /* Otherwise, we assume they provided an issue number instead. */
                                     #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                                     /**/
                                     $authnet["x_address"] = $post_vars["street"];
                                     $authnet["x_city"] = $post_vars["city"];
                                     $authnet["x_state"] = $post_vars["state"];
                                     $authnet["x_country"] = $post_vars["country"];
                                     $authnet["x_zip"] = $post_vars["zip"];
                                 }
                                 /**/
                                 if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                                     $new__subscr_id = $authnet["transaction_id"];
                                     /**/
                                     if (!($ipn = array())) {
                                         $ipn["txn_type"] = "web_accept";
                                         $ipn["txn_id"] = $new__subscr_id;
                                         $ipn["custom"] = $post_vars["attr"]["custom"];
                                         /**/
                                         $ipn["mc_gross"] = $cost_calculations["total"];
                                         $ipn["mc_currency"] = $cost_calculations["cur"];
                                         $ipn["tax"] = $cost_calculations["tax"];
                                         /**/
                                         $ipn["payer_email"] = $post_vars["email"];
                                         $ipn["first_name"] = $post_vars["first_name"];
                                         $ipn["last_name"] = $post_vars["last_name"];
                                         /**/
                                         $ipn["option_name1"] = "Originating Domain";
                                         $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                         /**/
                                         $ipn["option_name2"] = "Customer IP Address";
                                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                         /**/
                                         $ipn["item_name"] = $cost_calculations["desc"];
                                         $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                         /**/
                                         $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                                         $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                         $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                     }
                                     /**/
                                     if (!($create_user = array())) {
                                         $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                                         /* Fake this for registration configuration. */
                                         $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                         /* Fake this too. */
                                         /**/
                                         if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                                             foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                                 $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                 $field_id_class = preg_replace("/_/", "-", $field_var);
                                                 /**/
                                                 if (isset($post_vars["custom_fields"][$field_var])) {
                                                     $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                 }
                                             }
                                         }
                                         /**/
                                         $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt("authnet");
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id);
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                         /* Fake this for registration configuration. */
                                         $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                         /* Fake this too. */
                                         /**/
                                         $create_user["user_login"] = $post_vars["username"];
                                         /* Copy this into a separate array for `wp_create_user()`. */
                                         $create_user["user_pass"] = wp_generate_password();
                                         /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                                         $create_user["user_email"] = $post_vars["email"];
                                         /* Copy this into a separate array for `wp_create_user()`. */
                                     }
                                     /**/
                                     if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                         if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                             wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                             /**/
                                             $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                             /**/
                                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                             /**/
                                             if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                             }
                                         } else {
                                             c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                         }
                                     } else {
                                         if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                             update_user_option($new__user_id, "default_password_nag", true, true);
                                             /* Password nag. */
                                             wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                             /**/
                                             $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                             /**/
                                             if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                             }
                                         } else {
                                             c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                             /**/
                                             $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                         }
                                     }
                                 } else {
                                     $global_response = array("response" => $authnet["__error"], "error" => true);
                                 }
                             } else {
                                 $global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                             }
                         }
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form registrations.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_registration()
 {
     if (!empty($_POST['optimizemember_pro_stripe_registration']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_registration']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-registration')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_registration_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_registration_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_registration']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_registration_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email($post_vars['email']), get_defined_vars());
         $post_vars['username'] = is_multisite() ? strtolower($post_vars['username']) : $post_vars['username'];
         // Force lowercase.
         $post_vars['username'] = preg_replace('/\\s+/', '', sanitize_user($post_vars['_o_username'] = $post_vars['username'], is_multisite()));
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('registration', $post_vars))) {
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_user_pass1'] = $post_vars['password1'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_first_name'] = $post_vars['first_name'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_last_name'] = $post_vars['last_name'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
                 if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields']) {
                     foreach (json_decode($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['custom_reg_fields'], TRUE) as $field) {
                         $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                         $field_id_class = preg_replace('/_/', '-', $field_var);
                         if (isset($post_vars['custom_fields'][$field_var])) {
                             $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
                         }
                     }
                 }
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_level'] = $post_vars['attr']['level'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps'] = $post_vars['attr']['ccaps'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_custom'] = $post_vars['attr']['custom'];
                 $GLOBALS['ws_plugin__optimizemember_registration_vars']['ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time'] = $post_vars['attr']['tp'] && $post_vars['attr']['tt'] ? date('Y-m-d H:i:s', c_ws_plugin__optimizemember_utils_time::auto_eot_time('', '', '', $post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt'])) : '';
                 $GLOBALS['ws_plugin__optimizemember_registration_return_url'] = $post_vars['attr']['success'];
                 $create_user['user_email'] = $post_vars['email'];
                 // Copy this into a separate array for `wp_create_user()`.
                 $create_user['user_login'] = $post_vars['username'];
                 // Copy this into a separate array for `wp_create_user()`.
                 $create_user['user_pass'] = wp_generate_password();
                 // Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`.
                 $has_custom_password = $post_vars['password1'] && $post_vars['password1'] === $create_user['user_pass'];
                 if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
                     update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
                     wp_new_user_notification($new__user_id, $create_user['user_pass']);
                     if ($has_custom_password) {
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">login</a>.', 's2member-front', 'optimizemember'), esc_attr(wp_login_url())));
                     } else {
                         $global_response = array('response' => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', 's2member-front', 's2member'));
                     }
                     if ($post_vars['attr']['success'] && substr($GLOBALS['ws_plugin__optimizemember_registration_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $GLOBALS['ws_plugin__optimizemember_registration_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                     }
                 } else {
                     $global_response = array('response' => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
예제 #16
0
 /**
  * Displays Specific Post/Page Tracking Codes.
  *
  * These are stored inside optimizeMember's Transient Queue, by BOTH the IPN & Return-Data processors.
  *
  * Specific Post/Page Tracking Codes are only displayed/processed one time.
  * optimizeMember will display Tracking Codes in the footer of your theme.
  *
  * @package optimizeMember\Tracking
  * @since 3.5
  *
  * @attaches-to ``add_action("login_footer");``
  * @attaches-to ``add_action("wp_footer");``
  * @also-called-by {@link optimizeMember\Tracking\c_ws_plugin__optimizemember_tracking_codes::generate_all_tracking_codes()}
  *
  * @return null After displaying possible Tracking Code(s).
  */
 public static function display_sp_tracking_codes()
 {
     do_action("ws_plugin__optimizemember_before_display_sp_tracking_codes", get_defined_vars());
     /**/
     if (!empty($_COOKIE["optimizemember_sp_tracking"]) && ($txn_id = c_ws_plugin__optimizemember_utils_encryption::decrypt($_COOKIE["optimizemember_sp_tracking"]))) {
         if ($code = get_transient($transient = "s2m_" . md5("optimizemember_transient_sp_tracking_codes_" . $txn_id))) {
             delete_transient($transient);
             /* Only display this ONE time. Delete transient immediately. */
             /**/
             echo '<img src="' . esc_attr(site_url("/?optimizemember_delete_sp_tracking_cookie=1")) . '" alt="." style="width:1px; height:1px; border:0;" />' . "\n";
             /**/
             eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
             do_action("ws_plugin__optimizemember_during_display_sp_tracking_codes", get_defined_vars());
             unset($__refs, $__v);
             /* Unset defined __refs, __v. */
             /**/
             if (is_multisite() && c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() && !is_main_site()) {
                 echo $code . "\n";
                 /* No PHP here. */
             } else {
                 eval("?>" . $code);
             }
         }
     }
     /**/
     do_action("ws_plugin__optimizemember_after_display_sp_tracking_codes", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
예제 #17
0
 /**
  * Handles processing of Pro Form billing updates.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function paypal_update()
 {
     if (!empty($_POST["optimizemember_pro_paypal_update"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_update"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-update")) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_update_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_update_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_paypal_update"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And run a Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_paypal_update_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("update", $post_vars))) {
                 if ($post_vars["card_type"] === "PayPal") {
                     $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                 } else {
                     if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (($paypal = array("METHOD" => "GetRecurringPaymentsProfileDetails")) && ($paypal["PROFILEID"] = $cur__subscr_id = get_user_option("optimizemember_subscr_id"))) {
                             if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                 $paypal = array();
                                 /* Reset the PayPal array. */
                                 /**/
                                 $paypal["METHOD"] = "UpdateRecurringPaymentsProfile";
                                 $paypal["PROFILEID"] = $cur__subscr_id;
                                 /**/
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $user->first_name;
                                 $paypal["LASTNAME"] = $user->last_name;
                                 /**/
                                 $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                 $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                 $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                 $paypal["CVV2"] = $post_vars["card_verification"];
                                 /**/
                                 if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                     if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                         $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                     } else {
                                         /* Otherwise, we assume they provided an issue number instead. */
                                         $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                     }
                                 }
                                 /**/
                                 $paypal["STREET"] = $post_vars["street"];
                                 $paypal["CITY"] = $post_vars["city"];
                                 $paypal["STATE"] = $post_vars["state"];
                                 $paypal["COUNTRYCODE"] = $post_vars["country"];
                                 $paypal["ZIP"] = $post_vars["zip"];
                                 /**/
                                 if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                     $global_response = array("response" => _x('<strong>Confirmed.</strong> Your billing information has been updated.', "s2member-front", "s2member"));
                                     /**/
                                     if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                     }
                                 } else {
                                     $global_response = array("response" => $paypal["__error"], "error" => true);
                                 }
                             } else {
                                 if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     $global_response = array("response" => _x('<strong>Unable to update at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 } else {
                                     if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) === 4 && !preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
                                         $global_response = array("response" => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
                                     } else {
                                         if ($paypal && empty($paypal["__error"]) && strlen($paypal["ACCT"]) !== 4) {
                                             $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                         } else {
                                             if ($paypal && !empty($paypal["__error"]) && $paypal["L_ERRORCODE0"] === "11592") {
                                                 $global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
                                             } else {
                                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Oops.</strong> No Subscr. ID. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         $global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #18
0
 /**
  * Handles processing of Pro Forms for Specific Post/Page checkout.
  *
  * @package optimizeMember\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function stripe_sp_checkout()
 {
     if (!empty($_POST['optimizemember_pro_stripe_sp_checkout']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_sp_checkout']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-sp-checkout')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_sp_checkout_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_sp_checkout_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_sp_checkout']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_sp_checkout_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
         $post_vars['email'] = apply_filters('user_registration_email', sanitize_email($post_vars['email']), get_defined_vars());
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('sp-checkout', $post_vars))) {
                 unset($_POST['optimizemember_pro_stripe_sp_checkout']['card_token']);
                 // These are good one-time only.
                 unset($_POST['optimizemember_pro_stripe_sp_checkout']['card_token_summary']);
                 $cp_attr = c_ws_plugin__optimizemember_pro_stripe_utilities::apply_coupon($post_vars['attr'], $post_vars['coupon'], 'attr', array('affiliates-silent-post'));
                 $cost_calculations = c_ws_plugin__optimizemember_pro_stripe_utilities::cost(NULL, $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc']);
                 if (!$global_response) {
                     if ($cost_calculations['total'] > 0) {
                         if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer(get_current_user_id(), $post_vars['email'], $post_vars['first_name'], $post_vars['last_name']))) {
                             $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                         } else {
                             if (!is_object($stripe_customer = c_ws_plugin__optimizemember_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))) {
                                 $global_response = array('response' => $stripe_customer, 'error' => TRUE);
                             } else {
                                 if (!is_object($stripe_charge = c_ws_plugin__optimizemember_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc']))) {
                                     $global_response = array('response' => $stripe_charge, 'error' => TRUE);
                                 } else {
                                     $new__txn_cid = $stripe_customer->id;
                                     $new__txn_id = $stripe_charge->id;
                                 }
                             }
                         }
                     }
                 }
                 if (!$global_response) {
                     if (empty($new__txn_cid)) {
                         $new__txn_cid = strtoupper('free-' . uniqid());
                     }
                     if (empty($new__txn_id)) {
                         $new__txn_id = strtoupper('free-' . uniqid());
                     }
                     $ipn['txn_type'] = 'web_accept';
                     $ipn['txn_cid'] = $new__txn_cid;
                     $ipn['txn_id'] = $new__txn_id;
                     $ipn['custom'] = $post_vars['attr']['custom'];
                     $ipn['mc_gross'] = $cost_calculations['total'];
                     $ipn['mc_currency'] = $cost_calculations['cur'];
                     $ipn['tax'] = $cost_calculations['tax'];
                     $ipn['payer_email'] = $post_vars['email'];
                     $ipn['first_name'] = $post_vars['first_name'];
                     $ipn['last_name'] = $post_vars['last_name'];
                     if (is_user_logged_in() && ($referencing = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id())) {
                         $ipn['option_name1'] = 'Referencing Customer ID';
                         $ipn['option_selection1'] = $referencing;
                     } else {
                         $ipn['option_name1'] = 'Originating Domain';
                         $ipn['option_selection1'] = $_SERVER['HTTP_HOST'];
                     }
                     $ipn['option_name2'] = 'Customer IP Address';
                     $ipn['option_selection2'] = $_SERVER['REMOTE_ADDR'];
                     $ipn['item_name'] = $cost_calculations['desc'];
                     $ipn['item_number'] = $post_vars['attr']['sp_ids_exp'];
                     $ipn['optimizemember_paypal_proxy'] = 'stripe';
                     $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                     $ipn['optimizemember_paypal_proxy_coupon'] = array('coupon_code' => $cp_attr['_coupon_code'], 'full_coupon_code' => $cp_attr['_full_coupon_code'], 'affiliate_id' => $cp_attr['_coupon_affiliate_id']);
                     $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                     $ipn['optimizemember_paypal_proxy_return_url'] = $post_vars['attr']['success'];
                     $ipn['optimizemember_stripe_proxy_return_url'] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20)));
                     setcookie('optimizemember_sp_tracking', $optimizemember_sp_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('optimizemember_sp_tracking', $optimizemember_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['optimizemember_sp_tracking'] = $optimizemember_sp_tracking);
                     if ($sp_access_url = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($post_vars['attr']['ids'], $post_vars['attr']['exp'])) {
                         $global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', 's2member-front', 'optimizemember'), esc_attr($sp_access_url)));
                         if ($post_vars['attr']['success'] && substr($ipn['optimizemember_stripe_proxy_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['optimizemember_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                     }
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Forms for Specific Post/Page checkout.
  *
  * @package optimizeMember\AuthNet
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection.
  */
 public static function authnet_sp_checkout()
 {
     if (!empty($_POST["optimizemember_pro_authnet_sp_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_authnet_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-sp-checkout")) {
         $GLOBALS["ws_plugin__optimizemember_pro_authnet_sp_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_authnet_sp_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST["optimizemember_pro_authnet_sp_checkout"]));
         $post_vars["attr"] = unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"]));
         /* And Filter. */
         $post_vars["attr"] = apply_filters("ws_plugin__optimizemember_pro_authnet_sp_checkout_post_attr", $post_vars["attr"], get_defined_vars());
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         /**/
         if (!c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_authnet_responses::authnet_form_submission_validation_errors("sp-checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cost_calculations = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_cost(null, $cp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_attr["cc"], $cp_attr["desc"]);
                 /**/
                 if (!($authnet = array())) {
                     $authnet["x_type"] = "AUTH_CAPTURE";
                     $authnet["x_method"] = "CC";
                     /**/
                     $authnet["x_email"] = $post_vars["email"];
                     $authnet["x_first_name"] = $post_vars["first_name"];
                     $authnet["x_last_name"] = $post_vars["last_name"];
                     $authnet["x_customer_ip"] = $_SERVER["REMOTE_ADDR"];
                     /**/
                     $authnet["x_invoice_num"] = "s2-" . uniqid();
                     $authnet["x_description"] = $cost_calculations["desc"];
                     /**/
                     $authnet["s2_invoice"] = $post_vars["attr"]["sp_ids_exp"];
                     $authnet["s2_custom"] = $post_vars["attr"]["custom"];
                     /**/
                     $authnet["x_tax"] = $cost_calculations["tax"];
                     $authnet["x_amount"] = $cost_calculations["total"];
                     /**/
                     $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                     $authnet["x_exp_date"] = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_exp_date($post_vars["card_expiration"]);
                     $authnet["x_card_code"] = $post_vars["card_verification"];
                     /**/
                     #if (in_array ($post_vars["card_type"], array ("Maestro", "Solo")))
                     #	if (preg_match ("/^[0-9]{2}\/[0-9]{4}$/", $post_vars["card_start_date_issue_number"]))
                     #		$authnet["x_card_start_date"] = preg_replace ("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                     #	else /* Otherwise, we assume they provided an issue number instead. */
                     #		$authnet["x_card_issue_number"] = $post_vars["card_start_date_issue_number"];
                     /**/
                     $authnet["x_address"] = $post_vars["street"];
                     $authnet["x_city"] = $post_vars["city"];
                     $authnet["x_state"] = $post_vars["state"];
                     $authnet["x_country"] = $post_vars["country"];
                     $authnet["x_zip"] = $post_vars["zip"];
                 }
                 /**/
                 if (($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) {
                     $new__txn_id = $authnet["transaction_id"];
                     /**/
                     if (!($ipn = array())) {
                         $ipn["txn_type"] = "web_accept";
                         $ipn["txn_id"] = $new__txn_id;
                         $ipn["custom"] = $post_vars["attr"]["custom"];
                         /**/
                         $ipn["mc_gross"] = $cost_calculations["total"];
                         $ipn["mc_currency"] = $cost_calculations["cur"];
                         $ipn["tax"] = $cost_calculations["tax"];
                         /**/
                         $ipn["payer_email"] = $post_vars["email"];
                         $ipn["first_name"] = $post_vars["first_name"];
                         $ipn["last_name"] = $post_vars["last_name"];
                         /**/
                         if (is_user_logged_in() && ($referencing = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id())) {
                             $ipn["option_name1"] = "Referencing Customer ID";
                             $ipn["option_selection1"] = $referencing;
                         } else {
                             $ipn["option_name1"] = "Originating Domain";
                             $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                         }
                         /**/
                         $ipn["option_name2"] = "Customer IP Address";
                         $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                         /**/
                         $ipn["item_name"] = $cost_calculations["desc"];
                         $ipn["item_number"] = $post_vars["attr"]["sp_ids_exp"];
                         /**/
                         $ipn_q = "&optimizemember_paypal_proxy=authnet&optimizemember_paypal_proxy_use=pro-emails";
                         $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                         $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                         /**/
                         $ipn["optimizemember_authnet_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                     }
                     /**/
                     if ($sp_access_url = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) {
                         setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_sp_tracking"] = $optimizemember_sp_tracking);
                         /**/
                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url)));
                         /**/
                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_authnet_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                         }
                     } else {
                         $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                     }
                 } else {
                     $global_response = array("response" => $authnet["__error"], "error" => true);
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #20
0
 /**
  * Handles processing of Pro Forms for Specific Post/Page checkout.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function sp_checkout()
 {
     if (!empty($_POST["optimizemember_pro_paypal_sp_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-sp-checkout") || !empty($_GET["optimizemember_paypal_xco"]) && $_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_sp_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_sp_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = $xco_post_vars ? $xco_post_vars : $_POST["optimizemember_pro_paypal_sp_checkout"];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($post_vars));
         $post_vars["attr"] = !$xco_post_vars ? unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"])) : $post_vars["attr"];
         $post_vars["attr"] = !$xco_post_vars ? apply_filters("ws_plugin__optimizemember_pro_paypal_sp_checkout_post_attr", $post_vars["attr"], get_defined_vars()) : $post_vars["attr"];
         /**/
         if ($xco_post_vars) {
             /* No need to re-validate this upon return from Express Checkout. */
             $post_vars["attr"]["captcha"] = "0";
         }
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         /**/
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])) : null;
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("sp-checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_cost(null, $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 /**/
                 if (empty($_GET["optimizemember_paypal_xco"]) && $post_vars["card_type"] === "PayPal") {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_sp_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_sp_checkout_cancel"), $cancel_url);
                     /**/
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     /**/
                     $post_vars["attr"]["invoice"] = uniqid() . "~" . $_SERVER["REMOTE_ADDR"];
                     /* Unique invoice w/ IP address too. */
                     /**/
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         /**/
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         /**/
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["SOLUTIONTYPE"] = "Sole";
                         $paypal_set_xco["LANDINGPAGE"] = "Billing";
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                         $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                         $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                         $paypal_set_xco["PAYMENTREQUEST_0_INVNUM"] = $post_vars["attr"]["invoice"];
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                         $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                         $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                         $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                         /**/
                         $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                         /* Always (1). */
                         $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                         $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         /**/
                         $paypal_set_xco["EMAIL"] = $post_vars["email"];
                     }
                     /**/
                     if (($paypal_set_xco = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $post_vars, 10800);
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         /**/
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         /**/
                         exit;
                         /* Clean exit. */
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if (empty($post_vars["attr"]["invoice"])) {
                         /* Only if it's empty. */
                         $post_vars["attr"]["invoice"] = uniqid() . "~" . $_SERVER["REMOTE_ADDR"];
                     }
                     /**/
                     if (!($paypal = array())) {
                         if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                             /**/
                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                             /**/
                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             /**/
                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             $paypal["PAYMENTREQUEST_0_INVNUM"] = $post_vars["attr"]["invoice"];
                             /**/
                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             /* Always (1). */
                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         } else {
                             $paypal["METHOD"] = "DoDirectPayment";
                             $paypal["PAYMENTACTION"] = "Sale";
                             /**/
                             $paypal["EMAIL"] = $post_vars["email"];
                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                             $paypal["LASTNAME"] = $post_vars["last_name"];
                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                             /**/
                             $paypal["DESC"] = $cost_calculations["desc"];
                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                             $paypal["INVNUM"] = $post_vars["attr"]["invoice"];
                             /**/
                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                             $paypal["AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal["L_QTY0"] = "1";
                             /* Always (1). */
                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                             $paypal["L_NUMBER0"] = $post_vars["attr"]["sp_ids_exp"];
                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                             /**/
                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                             $paypal["CVV2"] = $post_vars["card_verification"];
                             /**/
                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                 } else {
                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                 }
                             }
                             /**/
                             $paypal["STREET"] = $post_vars["street"];
                             $paypal["CITY"] = $post_vars["city"];
                             $paypal["STATE"] = $post_vars["state"];
                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                             $paypal["ZIP"] = $post_vars["zip"];
                         }
                     }
                     /**/
                     if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                         $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                         $new__txn_id = !$new__txn_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__txn_id;
                         /**/
                         if (!($ipn = array())) {
                             $ipn["txn_type"] = "web_accept";
                             $ipn["txn_id"] = $new__txn_id;
                             $ipn["custom"] = $post_vars["attr"]["custom"];
                             $ipn["invoice"] = $post_vars["attr"]["invoice"];
                             /**/
                             $ipn["mc_gross"] = $cost_calculations["total"];
                             $ipn["mc_currency"] = $cost_calculations["cur"];
                             $ipn["tax"] = $cost_calculations["tax"];
                             /**/
                             $ipn["payer_email"] = $post_vars["email"];
                             $ipn["first_name"] = $post_vars["first_name"];
                             $ipn["last_name"] = $post_vars["last_name"];
                             /**/
                             if (is_user_logged_in() && ($referencing = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id())) {
                                 $ipn["option_name1"] = "Referencing Customer ID";
                                 $ipn["option_selection1"] = $referencing;
                             } else {
                                 $ipn["option_name1"] = "Originating Domain";
                                 $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                             }
                             /**/
                             $ipn["option_name2"] = "Customer IP Address";
                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                             /**/
                             $ipn["item_name"] = $cost_calculations["desc"];
                             $ipn["item_number"] = $post_vars["attr"]["sp_ids_exp"];
                             /**/
                             $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                             $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                             $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                             /**/
                             $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                         }
                         /**/
                         if ($sp_access_url = c_ws_plugin__optimizemember_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) {
                             setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_sp_tracking", $optimizemember_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_sp_tracking"] = $optimizemember_sp_tracking);
                             /**/
                             $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your purchase has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">click here</a> to proceed.', "s2member-front", "s2member"), esc_attr($sp_access_url)));
                             /**/
                             if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Oops.</strong> Unable to generate Access Link. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         $global_response = array("response" => $paypal["__error"], "error" => true);
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
예제 #21
0
 /**
  * Handles processing of Pro Form checkouts.
  *
  * @package optimizeMember\PayPal
  * @since 1.5
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Or exits script execution after a custom URL redirection; or upon Express Checkout redirection.
  */
 public static function paypal_checkout()
 {
     if (!empty($_POST["optimizemember_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["optimizemember_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["optimizemember_paypal_xco"]) && $_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])))) {
         $GLOBALS["ws_plugin__optimizemember_pro_paypal_checkout_response"] = array();
         /* This holds the global response details. */
         $global_response =& $GLOBALS["ws_plugin__optimizemember_pro_paypal_checkout_response"];
         /* This is a shorter reference. */
         /**/
         $post_vars = $xco_post_vars ? $xco_post_vars : $_POST["optimizemember_pro_paypal_checkout"];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($post_vars));
         /* And Filter. */
         $post_vars["attr"] = !$xco_post_vars ? unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars["attr"])) : $post_vars["attr"];
         $post_vars["attr"] = !$xco_post_vars ? apply_filters("ws_plugin__optimizemember_pro_paypal_checkout_post_attr", $post_vars["attr"], get_defined_vars()) : $post_vars["attr"];
         /**/
         if ($xco_post_vars) {
             /* No need to re-validate this upon return from Express Checkout. */
             $post_vars["attr"]["captcha"] = "0";
         }
         /**/
         $post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
         $post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
         /**/
         $post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
         $post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
         $post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["username"], is_multisite()));
         /**/
         !empty($_GET["token"]) ? delete_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $_GET["token"])) : null;
         /**/
         if (!c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) {
             if (!($error = c_ws_plugin__optimizemember_pro_paypal_responses::paypal_form_submission_validation_errors("checkout", $post_vars))) {
                 $cp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post"));
                 $cp_2gbp_attr = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]);
                 $cost_calculations = c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_cost($cp_2gbp_attr["ta"], $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
                 /**/
                 $use_recurring_profile = $post_vars["attr"]["rr"] === "BN" || !$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"] ? false : true;
                 $is_independent_ccaps_sale = $post_vars["attr"]["level"] === "*" ? true : false;
                 /* Selling Independent Custom Capabilities? */
                 /**/
                 if (empty($_GET["optimizemember_paypal_xco"]) && $post_vars["card_type"] === "PayPal") {
                     $return_url = $cancel_url = is_ssl() ? "https://" : "http://";
                     $return_url = $cancel_url = ($return_url = $cancel_url) . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
                     $return_url = $cancel_url = remove_query_arg(array("token", "PayerID"), $return_url = $cancel_url);
                     $return_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_checkout_return"), $return_url);
                     $cancel_url = add_query_arg("optimizemember_paypal_xco", urlencode("optimizemember_pro_paypal_checkout_cancel"), $cancel_url);
                     /**/
                     $user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
                     /**/
                     if (!($paypal_set_xco = array())) {
                         $paypal_set_xco["METHOD"] = "SetExpressCheckout";
                         /**/
                         $paypal_set_xco["RETURNURL"] = $return_url;
                         $paypal_set_xco["CANCELURL"] = $cancel_url;
                         /**/
                         $paypal_set_xco["PAGESTYLE"] = $post_vars["attr"]["ps"];
                         $paypal_set_xco["LOCALECODE"] = $post_vars["attr"]["lc"];
                         $paypal_set_xco["NOSHIPPING"] = $post_vars["attr"]["ns"];
                         $paypal_set_xco["SOLUTIONTYPE"] = "Sole";
                         $paypal_set_xco["LANDINGPAGE"] = "Billing";
                         $paypal_set_xco["ALLOWNOTE"] = "0";
                         /**/
                         if ($use_recurring_profile) {
                             $paypal_set_xco["L_BILLINGTYPE0"] = "RecurringPayments";
                             $paypal_set_xco["L_BILLINGAGREEMENTDESCRIPTION0"] = $cost_calculations["desc"];
                             if ($post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                 $paypal_set_xco["MAXAMT"] = $cost_calculations["trial_total"];
                             } else {
                                 $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                             }
                         } else {
                             $paypal_set_xco["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                             $paypal_set_xco["MAXAMT"] = $cost_calculations["total"];
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                             $paypal_set_xco["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                             /**/
                             $paypal_set_xco["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                             $paypal_set_xco["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                             $paypal_set_xco["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                             $paypal_set_xco["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                             /**/
                             $paypal_set_xco["L_PAYMENTREQUEST_0_QTY0"] = "1";
                             /* Always (1). */
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                             $paypal_set_xco["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                         }
                         /**/
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTONAME"] = $post_vars["name"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTREET"] = $post_vars["street"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCITY"] = $post_vars["city"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOSTATE"] = $post_vars["state"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $post_vars["country"];
                         $paypal_set_xco["PAYMENTREQUEST_0_SHIPTOZIP"] = $post_vars["zip"];
                         /**/
                         $paypal_set_xco["EMAIL"] = $user ? $user->user_email : $post_vars["email"];
                     }
                     /**/
                     if (($paypal_set_xco = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) {
                         set_transient("s2m_" . md5("optimizemember_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $post_vars, 10800);
                         /**/
                         $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com";
                         /**/
                         wp_redirect(add_query_arg("token", urlencode($paypal_set_xco["TOKEN"]), "https://" . $endpoint . "/cgi-bin/webscr?cmd=_express-checkout"));
                         /**/
                         exit;
                         /* Clean exit. */
                     } else {
                         $global_response = array("response" => $paypal_set_xco["__error"], "error" => true);
                     }
                 } else {
                     if ($use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                         if (!($cur__subscr_id = get_user_option("optimizemember_subscr_id")) || !($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                             $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $user->user_email;
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal["INITAMT"] = $post_vars["attr"]["tp"] ? $cost_calculations["trial_total"] : $cost_calculations["total"];
                                     $paypal["FAILEDINITAMTACTION"] = "CancelOnFailure";
                                 }
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__optimizemember_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                 $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                                 $old__subscr_id = get_user_option("optimizemember_subscr_id");
                                 $new__subscr_id = $paypal["PROFILEID"];
                                 /**/
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_signup";
                                     $ipn["subscr_id"] = $new__subscr_id;
                                     $ipn["custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $ipn["txn_id"] = $new__subscr_id;
                                     /**/
                                     $ipn["period1"] = $period1;
                                     $ipn["period3"] = $period3;
                                     /**/
                                     $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                     $ipn["mc_amount3"] = $cost_calculations["total"];
                                     /**/
                                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                     /**/
                                     $ipn["mc_currency"] = $cost_calculations["cur"];
                                     $ipn["tax"] = $cost_calculations["tax"];
                                     /**/
                                     $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                     /**/
                                     $ipn["payer_email"] = $user->user_email;
                                     $ipn["first_name"] = $post_vars["first_name"];
                                     $ipn["last_name"] = $post_vars["last_name"];
                                     /**/
                                     $ipn["option_name1"] = "Referencing Customer ID";
                                     $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $ipn["item_name"] = $cost_calculations["desc"];
                                     $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                     /* Use as first payment? */
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                     /**/
                                     $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                 }
                                 /**/
                                 if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                     $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                     $paypal["ACTION"] = "Cancel";
                                     /**/
                                     c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal);
                                 }
                                 /**/
                                 setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                                 /**/
                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                 /**/
                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                 }
                             } else {
                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                             }
                         } else {
                             $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                         }
                     } else {
                         if ($use_recurring_profile && !is_user_logged_in()) {
                             $period1 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period1($post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"]);
                             $period3 = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_period3($post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"]);
                             /**/
                             $start_time = $post_vars["attr"]["tp"] ? c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period1) : c_ws_plugin__optimizemember_pro_paypal_utilities::paypal_start_time($period3);
                             /* Or next billing cycle. */
                             /**/
                             $reference = $start_time . ":" . $period1 . ":" . $period3 . "~" . $_SERVER["HTTP_HOST"] . "~" . $post_vars["attr"]["level_ccaps_eotper"];
                             /**/
                             if (!($paypal = array())) {
                                 $paypal["METHOD"] = "CreateRecurringPaymentsProfile";
                                 /**/
                                 $paypal["EMAIL"] = $post_vars["email"];
                                 $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                 $paypal["LASTNAME"] = $post_vars["last_name"];
                                 $paypal["SUBSCRIBERNAME"] = $post_vars["name"];
                                 /**/
                                 $paypal["DESC"] = $cost_calculations["desc"];
                                 $paypal["PROFILEREFERENCE"] = $reference;
                                 /**/
                                 if (!$post_vars["attr"]["tp"] || $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
                                     $paypal["INITAMT"] = $post_vars["attr"]["tp"] ? $cost_calculations["trial_total"] : $cost_calculations["total"];
                                     $paypal["FAILEDINITAMTACTION"] = "CancelOnFailure";
                                 }
                                 /**/
                                 $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                 $paypal["AMT"] = $cost_calculations["sub_total"];
                                 $paypal["TAXAMT"] = $cost_calculations["tax"];
                                 /**/
                                 $paypal["MAXFAILEDPAYMENTS"] = $post_vars["attr"]["rra"];
                                 $paypal["AUTOBILLOUTAMT"] = apply_filters("ws_plugin__optimizemember_pro_paypal_auto_bill_op", "AddToNextBilling", get_defined_vars());
                                 /**/
                                 $paypal["PROFILESTARTDATE"] = date("Y-m-d", $start_time) . "T00:00:00Z";
                                 /**/
                                 $paypal["BILLINGPERIOD"] = c_ws_plugin__optimizemember_paypal_utilities::paypal_pro_term($post_vars["attr"]["rt"]);
                                 $paypal["TOTALBILLINGCYCLES"] = $post_vars["attr"]["rr"] ? $post_vars["attr"]["rrt"] ? $post_vars["attr"]["rrt"] : "0" : "1";
                                 $paypal["BILLINGFREQUENCY"] = $post_vars["attr"]["rp"];
                                 /**/
                                 if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                     $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                 } else {
                                     $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                     $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                     $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                     $paypal["CVV2"] = $post_vars["card_verification"];
                                     /**/
                                     if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                         if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                             $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                         } else {
                                             /* Otherwise, we assume they provided an Issue Number instead. */
                                             $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                         }
                                     }
                                     /**/
                                     $paypal["STREET"] = $post_vars["street"];
                                     $paypal["CITY"] = $post_vars["city"];
                                     $paypal["STATE"] = $post_vars["state"];
                                     $paypal["COUNTRYCODE"] = $post_vars["country"];
                                     $paypal["ZIP"] = $post_vars["zip"];
                                 }
                             }
                             /**/
                             if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                 $new__subscr_id = $paypal["PROFILEID"];
                                 /**/
                                 if (!($ipn = array())) {
                                     $ipn["txn_type"] = "subscr_signup";
                                     $ipn["subscr_id"] = $new__subscr_id;
                                     $ipn["custom"] = $post_vars["attr"]["custom"];
                                     /**/
                                     $ipn["txn_id"] = $new__subscr_id;
                                     /**/
                                     $ipn["period1"] = $period1;
                                     $ipn["period3"] = $period3;
                                     /**/
                                     $ipn["mc_amount1"] = $cost_calculations["trial_total"];
                                     $ipn["mc_amount3"] = $cost_calculations["total"];
                                     /**/
                                     $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"];
                                     /**/
                                     $ipn["mc_currency"] = $cost_calculations["cur"];
                                     $ipn["tax"] = $cost_calculations["tax"];
                                     /**/
                                     $ipn["recurring"] = $post_vars["attr"]["rr"] ? "1" : "";
                                     /**/
                                     $ipn["payer_email"] = $post_vars["email"];
                                     $ipn["first_name"] = $post_vars["first_name"];
                                     $ipn["last_name"] = $post_vars["last_name"];
                                     /**/
                                     $ipn["option_name1"] = "Originating Domain";
                                     $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                     /**/
                                     $ipn["option_name2"] = "Customer IP Address";
                                     $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                     /**/
                                     $ipn["item_name"] = $cost_calculations["desc"];
                                     $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                     /**/
                                     $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                     $ipn_q .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : "";
                                     /* Use as first payment? */
                                     $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                     $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                 }
                                 /**/
                                 if (!($create_user = array())) {
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                                     /* Fake this for registration configuration. */
                                     $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                     /* Fake this too. */
                                     /**/
                                     if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                             $field_id_class = preg_replace("/_/", "-", $field_var);
                                             /**/
                                             if (isset($post_vars["custom_fields"][$field_var])) {
                                                 $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                             }
                                         }
                                     }
                                     /**/
                                     $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt("paypal");
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id);
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                     /* Fake this for registration configuration. */
                                     $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                     /* Fake this too. */
                                     /**/
                                     $create_user["user_login"] = $post_vars["username"];
                                     /* Copy this into a separate array for `wp_create_user()`. */
                                     $create_user["user_pass"] = wp_generate_password();
                                     /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                                     $create_user["user_email"] = $post_vars["email"];
                                     /* Copy this into a separate array for `wp_create_user()`. */
                                 }
                                 /**/
                                 if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                         /**/
                                         $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 } else {
                                     if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                         update_user_option($new__user_id, "default_password_nag", true, true);
                                         /* Password nag. */
                                         wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                         /**/
                                         $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                         /**/
                                         $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                     }
                                 }
                             } else {
                                 $global_response = array("response" => $paypal["__error"], "error" => true);
                             }
                         } else {
                             if (!$use_recurring_profile && is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                                 if ($is_independent_ccaps_sale || !($cur__subscr_id = get_user_option("optimizemember_subscr_id")) || !($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response(array("METHOD" => "GetRecurringPaymentsProfileDetails", "PROFILEID" => $cur__subscr_id))) || !empty($paypal["__error"]) || !preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
                                     update_user_meta($user_id, "first_name", $post_vars["first_name"]) . update_user_meta($user_id, "last_name", $post_vars["last_name"]);
                                     /**/
                                     if (!($paypal = array())) {
                                         if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $user->user_email;
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $old__subscr_id = get_user_option("optimizemember_subscr_id");
                                         $old__subscr_or_wp_id = c_ws_plugin__optimizemember_utils_users::get_user_subscr_or_wp_id();
                                         $new__subscr_id = $new__txn_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = $new__txn_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $user->user_email;
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Referencing Customer ID";
                                             $ipn["option_selection1"] = $old__subscr_or_wp_id;
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                             /**/
                                             $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                         }
                                         /**/
                                         if (!$is_independent_ccaps_sale) {
                                             /* Independent? */
                                             if (!($paypal = array()) && ($paypal["PROFILEID"] = $old__subscr_id)) {
                                                 $paypal["METHOD"] = "ManageRecurringPaymentsProfileStatus";
                                                 $paypal["ACTION"] = "Cancel";
                                                 /**/
                                                 c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal);
                                             }
                                         }
                                         /**/
                                         setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking);
                                         /**/
                                         $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been updated.<br />&mdash; Please <a href="%s" rel="nofollow">log back in</a> now.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                         /**/
                                         if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Sorry.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
                                 }
                             } else {
                                 if (!$use_recurring_profile && !is_user_logged_in()) {
                                     if (!($paypal = array())) {
                                         if ($_GET["optimizemember_paypal_xco"] === "optimizemember_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal_xco_details)) && empty($paypal_xco_details["__error"])) {
                                             $paypal["METHOD"] = "DoExpressCheckoutPayment";
                                             /**/
                                             $paypal["TOKEN"] = $paypal_xco_details["TOKEN"];
                                             $paypal["PAYERID"] = $paypal_xco_details["PAYERID"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_DESC"] = $cost_calculations["desc"];
                                             $paypal["PAYMENTREQUEST_0_CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["PAYMENTREQUEST_0_CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["PAYMENTREQUEST_0_ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["PAYMENTREQUEST_0_TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["PAYMENTREQUEST_0_AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_PAYMENTREQUEST_0_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_PAYMENTREQUEST_0_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_PAYMENTREQUEST_0_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_PAYMENTREQUEST_0_AMT0"] = $cost_calculations["sub_total"];
                                         } else {
                                             $paypal["METHOD"] = "DoDirectPayment";
                                             $paypal["PAYMENTACTION"] = "Sale";
                                             /**/
                                             $paypal["EMAIL"] = $post_vars["email"];
                                             $paypal["FIRSTNAME"] = $post_vars["first_name"];
                                             $paypal["LASTNAME"] = $post_vars["last_name"];
                                             $paypal["IPADDRESS"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $paypal["DESC"] = $cost_calculations["desc"];
                                             $paypal["CUSTOM"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $paypal["CURRENCYCODE"] = $cost_calculations["cur"];
                                             $paypal["ITEMAMT"] = $cost_calculations["sub_total"];
                                             $paypal["TAXAMT"] = $cost_calculations["tax"];
                                             $paypal["AMT"] = $cost_calculations["total"];
                                             /**/
                                             $paypal["L_QTY0"] = "1";
                                             /* Always (1). */
                                             $paypal["L_NAME0"] = $cost_calculations["desc"];
                                             $paypal["L_NUMBER0"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             $paypal["L_AMT0"] = $cost_calculations["sub_total"];
                                             /**/
                                             $paypal["CREDITCARDTYPE"] = $post_vars["card_type"];
                                             $paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
                                             $paypal["EXPDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_expiration"]);
                                             $paypal["CVV2"] = $post_vars["card_verification"];
                                             /**/
                                             if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
                                                 if (preg_match("/^[0-9]{2}\\/[0-9]{4}\$/", $post_vars["card_start_date_issue_number"])) {
                                                     $paypal["STARTDATE"] = preg_replace("/[^0-9]/", "", $post_vars["card_start_date_issue_number"]);
                                                 } else {
                                                     /* Otherwise, we assume they provided an Issue Number instead. */
                                                     $paypal["ISSUENUMBER"] = $post_vars["card_start_date_issue_number"];
                                                 }
                                             }
                                             /**/
                                             $paypal["STREET"] = $post_vars["street"];
                                             $paypal["CITY"] = $post_vars["city"];
                                             $paypal["STATE"] = $post_vars["state"];
                                             $paypal["COUNTRYCODE"] = $post_vars["country"];
                                             $paypal["ZIP"] = $post_vars["zip"];
                                         }
                                     }
                                     /**/
                                     if (($paypal = c_ws_plugin__optimizemember_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
                                         $new__subscr_id = !empty($paypal["PAYMENTINFO_0_TRANSACTIONID"]) ? $paypal["PAYMENTINFO_0_TRANSACTIONID"] : false;
                                         $new__subscr_id = !$new__subscr_id && !empty($paypal["TRANSACTIONID"]) ? $paypal["TRANSACTIONID"] : $new__subscr_id;
                                         /**/
                                         if (!($ipn = array())) {
                                             $ipn["txn_type"] = "web_accept";
                                             $ipn["txn_id"] = $new__subscr_id;
                                             $ipn["custom"] = $post_vars["attr"]["custom"];
                                             /**/
                                             $ipn["mc_gross"] = $cost_calculations["total"];
                                             $ipn["mc_currency"] = $cost_calculations["cur"];
                                             $ipn["tax"] = $cost_calculations["tax"];
                                             /**/
                                             $ipn["payer_email"] = $post_vars["email"];
                                             $ipn["first_name"] = $post_vars["first_name"];
                                             $ipn["last_name"] = $post_vars["last_name"];
                                             /**/
                                             $ipn["option_name1"] = "Originating Domain";
                                             $ipn["option_selection1"] = $_SERVER["HTTP_HOST"];
                                             /**/
                                             $ipn["option_name2"] = "Customer IP Address";
                                             $ipn["option_selection2"] = $_SERVER["REMOTE_ADDR"];
                                             /**/
                                             $ipn["item_name"] = $cost_calculations["desc"];
                                             $ipn["item_number"] = $post_vars["attr"]["level_ccaps_eotper"];
                                             /**/
                                             $ipn_q = "&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=pro-emails";
                                             $ipn_q .= "&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen());
                                             $ipn_q .= "&optimizemember_paypal_proxy_return_url=" . rawurlencode($post_vars["attr"]["success"]);
                                         }
                                         /**/
                                         if (!($create_user = array())) {
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_user_pass1"] = $post_vars["password1"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_first_name"] = $post_vars["first_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_last_name"] = $post_vars["last_name"];
                                             /* Fake this for registration configuration. */
                                             $_POST["ws_plugin__optimizemember_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
                                             /* Fake this too. */
                                             /**/
                                             if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"]) {
                                                 foreach (json_decode($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_fields"], true) as $field) {
                                                     $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                     $field_id_class = preg_replace("/_/", "-", $field_var);
                                                     /**/
                                                     if (isset($post_vars["custom_fields"][$field_var])) {
                                                         $_POST["ws_plugin__optimizemember_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
                                                     }
                                                 }
                                             }
                                             /**/
                                             $_COOKIE["optimizemember_subscr_gateway"] = c_ws_plugin__optimizemember_utils_encryption::encrypt("paypal");
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["optimizemember_subscr_id"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($new__subscr_id);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["optimizemember_custom"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["custom"]);
                                             /* Fake this for registration configuration. */
                                             $_COOKIE["optimizemember_item_number"] = c_ws_plugin__optimizemember_utils_encryption::encrypt($post_vars["attr"]["level_ccaps_eotper"]);
                                             /* Fake this too. */
                                             /**/
                                             $create_user["user_login"] = $post_vars["username"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                             $create_user["user_pass"] = wp_generate_password();
                                             /* Which may fire `c_ws_plugin__optimizemember_registrations::generate_password()`. */
                                             $create_user["user_email"] = $post_vars["email"];
                                             /* Copy this into a separate array for `wp_create_user()`. */
                                         }
                                         /**/
                                         if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         } else {
                                             if ((is_multisite() && ($new__user_id = c_ws_plugin__optimizemember_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
                                                 update_user_option($new__user_id, "default_password_nag", true, true);
                                                 /* Password nag. */
                                                 wp_new_user_notification($new__user_id, $create_user["user_pass"]);
                                                 /**/
                                                 $ipn["optimizemember_paypal_proxy_return_url"] = trim(c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
                                                 /**/
                                                 if ($post_vars["attr"]["success"] && substr($ipn["optimizemember_paypal_proxy_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["optimizemember_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
                                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, "s2p-v")) . exit;
                                                 }
                                             } else {
                                                 c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
                                                 /**/
                                                 $global_response = array("response" => _x('<strong>Oops.</strong> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                             }
                                         }
                                     } else {
                                         $global_response = array("response" => $paypal["__error"], "error" => true);
                                     }
                                 } else {
                                     $global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
                                 }
                             }
                         }
                     }
                 }
             } else {
                 $global_response = $error;
             }
         }
     }
 }
 /**
  * Handles processing of Pro Form cancellations.
  *
  * @package s2Member\Stripe
  * @since 140617
  *
  * @attaches-to ``add_action('init');``
  */
 public static function stripe_cancellation()
 {
     if (!empty($_POST['optimizemember_pro_stripe_cancellation']['nonce']) && ($nonce = $_POST['optimizemember_pro_stripe_cancellation']['nonce']) && wp_verify_nonce($nonce, 'optimizemember-pro-stripe-cancellation')) {
         $GLOBALS['ws_plugin__optimizemember_pro_stripe_cancellation_response'] = array();
         // This holds the global response details.
         $global_response =& $GLOBALS['ws_plugin__optimizemember_pro_stripe_cancellation_response'];
         $post_vars = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_POST['optimizemember_pro_stripe_cancellation']));
         $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__optimizemember_utils_encryption::decrypt($post_vars['attr'])) : array();
         $post_vars['attr'] = apply_filters('ws_plugin__optimizemember_pro_stripe_cancellation_post_attr', $post_vars['attr'], get_defined_vars());
         $post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
         $post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
         if (!c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) {
             if (!($form_submission_validation_errors = c_ws_plugin__optimizemember_pro_stripe_responses::stripe_form_submission_validation_errors('cancellation', $post_vars))) {
                 if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
                     if (($cur__subscr_cid = get_user_option('optimizemember_subscr_cid')) && ($cur__subscr_id = get_user_option('optimizemember_subscr_id'))) {
                         if (is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id))) {
                             if (!preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
                                 if (is_object(c_ws_plugin__optimizemember_pro_stripe_utilities::cancel_customer_subscription($cur__subscr_cid, $cur__subscr_id))) {
                                     if (is_array($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars())) {
                                         $ipn['txn_type'] = 'subscr_cancel';
                                         $ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid'];
                                         $ipn['subscr_id'] = $ipn_signup_vars['subscr_id'];
                                         $ipn['custom'] = $ipn_signup_vars['custom'];
                                         $ipn['period1'] = $ipn_signup_vars['period1'];
                                         $ipn['period3'] = $ipn_signup_vars['period3'];
                                         $ipn['payer_email'] = $ipn_signup_vars['payer_email'];
                                         $ipn['first_name'] = $ipn_signup_vars['first_name'];
                                         $ipn['last_name'] = $ipn_signup_vars['last_name'];
                                         $ipn['option_name1'] = $ipn_signup_vars['option_name1'];
                                         $ipn['option_selection1'] = $ipn_signup_vars['option_selection1'];
                                         $ipn['option_name2'] = $ipn_signup_vars['option_name2'];
                                         $ipn['option_selection2'] = $ipn_signup_vars['option_selection2'];
                                         $ipn['item_name'] = $ipn_signup_vars['item_name'];
                                         $ipn['item_number'] = $ipn_signup_vars['item_number'];
                                         $ipn['optimizemember_paypal_proxy'] = 'stripe';
                                         $ipn['optimizemember_paypal_proxy_use'] = 'pro-emails';
                                         $ipn['optimizemember_paypal_proxy_verification'] = c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen();
                                         c_ws_plugin__optimizemember_utils_urls::remote(site_url('/?optimizemember_paypal_notify=1'), $ipn, array('timeout' => 20));
                                     }
                                     $global_response = array('response' => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                                     if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                         wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                     }
                                 } else {
                                     $global_response = array('response' => _x('API failure. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
                                 }
                             } else {
                                 $global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                                 if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                     wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                                 }
                             }
                         } else {
                             $global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                             if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                                 wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                             }
                         }
                     } else {
                         $global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
                         if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__optimizemember_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
                             wp_redirect(c_ws_plugin__optimizemember_utils_urls::add_optimizemember_sig($custom_success_url, 's2p-v')) . exit;
                         }
                     }
                 } else {
                     $global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
                 }
             } else {
                 // Input form field validation errors.
                 $global_response = $form_submission_validation_errors;
             }
         }
     }
 }