/** * 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; } } } }
/** * 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 />— 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; } } } }
/** * Handles ClickBank® IPN URL processing. * * @package optimizeMember\ClickBank * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling the Notification. */ public static function clickbank_notify() { global $current_site, $current_blog; if (!empty($_GET["optimizemember_pro_clickbank_notify"]) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_clickbank_username"]) { @ignore_user_abort(true); // Continue processing even if/when connection is broken by the sender. if (is_array($clickbank = c_ws_plugin__optimizemember_pro_clickbank_utilities::clickbank_postvars()) && ($_clickbank = $clickbank)) { $clickbank["optimizemember_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $clickbank["optimizemember_log"][] = "optimizeMember POST vars verified with ClickBank®."; $s2vars = c_ws_plugin__optimizemember_pro_clickbank_utilities::clickbank_parse_s2vars($clickbank["cvendthru"], $clickbank["ctransaction"]); if (isset($s2vars["s2_p1"], $s2vars["s2_p3"]) && $s2vars["s2_p1"] === "0 D") { $s2vars["s2_p1"] = $s2vars["s2_p3"]; } $clickbank["s2vars"] = $s2vars; if (strcasecmp($clickbank["ccustfirstname"] . " " . $clickbank["ccustlastname"], $clickbank["ccustfullname"]) !== 0 && preg_match("/(?:[^ ]+)(?: +)(?:[^ ]+)/", $clickbank["ccustfullname"])) { list($clickbank["ccustfirstname"], $clickbank["ccustlastname"]) = preg_split("/ +/", $clickbank["ccustfullname"], 2); } if (preg_match("/^(?:TEST_)?SALE\$/i", $clickbank["ctransaction"]) && preg_match("/^STANDARD\$/i", $clickbank["cprodtype"])) { $clickbank["optimizemember_log"][] = "ClickBank® transaction identified as ( `SALE/STANDARD` )."; $clickbank["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal® processor as `txn_type` ( `web_accept` )."; $clickbank["optimizemember_log"][] = "Please check PayPal® IPN logs for further processing details."; $processing = $processed = true; $ipn = array(); // Reset. $ipn["txn_type"] = "web_accept"; $ipn["txn_id"] = $clickbank["ctransreceipt"]; $ipn["custom"] = $s2vars["s2_custom"]; $ipn["mc_gross"] = number_format($clickbank["corderamount"] / 100, 2, ".", ""); $ipn["mc_currency"] = strtoupper($clickbank["ccurrency"]); $ipn["tax"] = number_format("0.00", 2, ".", ""); $ipn["payer_email"] = $clickbank["ccustemail"]; $ipn["first_name"] = ucwords(strtolower($clickbank["ccustfirstname"])); $ipn["last_name"] = ucwords(strtolower($clickbank["ccustlastname"])); $ipn["option_name1"] = $s2vars["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars["s2_referencing"] ? $s2vars["s2_referencing"] : $_SERVER["HTTP_HOST"]; $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $s2vars["s2_customer_ip"]; $ipn["item_number"] = $s2vars["s2_invoice"]; $ipn["item_name"] = $s2vars["s2_desc"]; $ipn["optimizemember_paypal_proxy"] = "clickbank"; $ipn["optimizemember_paypal_proxy_use"] = "standard-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)); } else { if (preg_match("/^(?:TEST_)?SALE\$/i", $clickbank["ctransaction"]) && preg_match("/^RECURRING\$/i", $clickbank["cprodtype"])) { $clickbank["optimizemember_log"][] = "ClickBank® transaction identified as ( `SALE/RECURRING` )."; $clickbank["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal® processor as `txn_type` ( `subscr_signup` )."; $clickbank["optimizemember_log"][] = "Please check PayPal® IPN logs for further processing details."; $processing = $processed = true; $ipn = array(); // Reset. $ipn["txn_type"] = "subscr_signup"; $ipn["subscr_id"] = $s2vars["s2_subscr_id"]; $ipn["recurring"] = $clickbank["cfuturepayments"] > 1 ? "1" : "0"; $ipn["txn_id"] = $clickbank["ctransreceipt"]; $ipn["custom"] = $s2vars["s2_custom"]; $ipn["period1"] = $s2vars["s2_p1"]; $ipn["period3"] = $s2vars["s2_p3"]; $ipn["mc_amount1"] = number_format($clickbank["corderamount"] / 100, 2, ".", ""); $ipn["mc_amount3"] = number_format($clickbank["crebillamnt"] / 100, 2, ".", ""); $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"]; $ipn["mc_currency"] = strtoupper($clickbank["ccurrency"]); $ipn["tax"] = number_format("0.00", 2, ".", ""); $ipn["payer_email"] = $clickbank["ccustemail"]; $ipn["first_name"] = ucwords(strtolower($clickbank["ccustfirstname"])); $ipn["last_name"] = ucwords(strtolower($clickbank["ccustlastname"])); $ipn["option_name1"] = $s2vars["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars["s2_referencing"] ? $s2vars["s2_referencing"] : $_SERVER["HTTP_HOST"]; $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $s2vars["s2_customer_ip"]; $ipn["item_number"] = $s2vars["s2_invoice"]; $ipn["item_name"] = $s2vars["s2_desc"]; $ipn["optimizemember_paypal_proxy"] = "clickbank"; $ipn["optimizemember_paypal_proxy_use"] = "standard-emails"; $ipn["optimizemember_paypal_proxy_use"] .= $ipn["mc_gross"] > 0 ? ",subscr-signup-as-subscr-payment" : ""; $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)); } else { if (preg_match("/^(?:TEST_)?BILL\$/i", $clickbank["ctransaction"]) && preg_match("/^RECURRING\$/i", $clickbank["cprodtype"])) { $clickbank["optimizemember_log"][] = "ClickBank® transaction identified as ( `BILL/RECURRING` )."; $clickbank["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal® processor as `txn_type` ( `subscr_payment` )."; $clickbank["optimizemember_log"][] = "Please check PayPal® IPN logs for further processing details."; $processing = $processed = true; $ipn = array(); // Reset. $ipn["txn_type"] = "subscr_payment"; $ipn["subscr_id"] = $s2vars["s2_subscr_id"]; $ipn["txn_id"] = $clickbank["ctransreceipt"]; $ipn["custom"] = $s2vars["s2_custom"]; $ipn["mc_gross"] = number_format($clickbank["corderamount"] / 100, 2, ".", ""); $ipn["mc_currency"] = strtoupper($clickbank["ccurrency"]); $ipn["tax"] = number_format("0.00", 2, ".", ""); $ipn["payer_email"] = $clickbank["ccustemail"]; $ipn["first_name"] = ucwords(strtolower($clickbank["ccustfirstname"])); $ipn["last_name"] = ucwords(strtolower($clickbank["ccustlastname"])); $ipn["option_name1"] = $s2vars["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars["s2_referencing"] ? $s2vars["s2_referencing"] : $_SERVER["HTTP_HOST"]; $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $s2vars["s2_customer_ip"]; $ipn["item_number"] = $s2vars["s2_invoice"]; $ipn["item_name"] = $s2vars["s2_desc"]; $ipn["optimizemember_paypal_proxy"] = "clickbank"; $ipn["optimizemember_paypal_proxy_use"] = "standard-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)); } else { if (preg_match("/^(?:TEST_)?(?:RFND|CGBK|INSF)\$/i", $clickbank["ctransaction"])) { $clickbank["optimizemember_log"][] = "ClickBank® transaction identified as ( `RFND|CGBK|INSF` )."; $clickbank["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal® processor as `payment_status` ( `refunded|reversed` )."; $clickbank["optimizemember_log"][] = "Please check PayPal® IPN logs for further processing details."; $processing = $processed = true; $ipn = array(); // Reset. $ipn["payment_status"] = preg_match("/^(?:TEST_)?RFND\$/", $clickbank["ctransaction"]) ? "refunded" : "reversed"; $ipn["parent_txn_id"] = preg_match("/^RECURRING\$/i", $clickbank["cprodtype"]) && $s2vars["s2_subscr_id"] ? $s2vars["s2_subscr_id"] : $clickbank["ctransreceipt"]; $ipn["custom"] = $s2vars["s2_custom"]; $ipn["mc_fee"] = "-" . number_format("0.00", 2, ".", ""); $ipn["mc_gross"] = "-" . number_format(abs($clickbank["corderamount"]) / 100, 2, ".", ""); $ipn["mc_currency"] = strtoupper($clickbank["ccurrency"]); $ipn["tax"] = "-" . number_format("0.00", 2, ".", ""); $ipn["payer_email"] = $clickbank["ccustemail"]; $ipn["first_name"] = ucwords(strtolower($clickbank["ccustfirstname"])); $ipn["last_name"] = ucwords(strtolower($clickbank["ccustlastname"])); $ipn["option_name1"] = $s2vars["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars["s2_referencing"] ? $s2vars["s2_referencing"] : $_SERVER["HTTP_HOST"]; $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $s2vars["s2_customer_ip"]; $ipn["item_number"] = $s2vars["s2_invoice"]; $ipn["item_name"] = $s2vars["s2_desc"]; $ipn["optimizemember_paypal_proxy"] = "clickbank"; $ipn["optimizemember_paypal_proxy_use"] = "standard-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)); } } } } if (preg_match("/^(?:TEST_)?(?:SALE|BILL)\$/i", $clickbank["ctransaction"]) && preg_match("/^RECURRING\$/i", $clickbank["cprodtype"]) && (preg_match("/^COMPLETED\$/i", $clickbank["crebillstatus"]) || $clickbank["cfuturepayments"] <= 0) || preg_match("/^(?:TEST_)?CANCEL-REBILL\$/i", $clickbank["ctransaction"]) && preg_match("/^RECURRING\$/i", $clickbank["cprodtype"])) { $clickbank["optimizemember_log"][] = "ClickBank® transaction identified as ( `RECURRING/COMPLETED` or `CANCEL-REBILL` )."; $clickbank["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal® processor as `txn_type` ( `subscr_cancel` )."; $clickbank["optimizemember_log"][] = "Please check PayPal® IPN logs for further processing details."; $processing = $processed = true; $ipn = array(); // Reset. $ipn["txn_type"] = "subscr_cancel"; $ipn["subscr_id"] = $s2vars["s2_subscr_id"]; $ipn["custom"] = $s2vars["s2_custom"]; $ipn["period1"] = $s2vars["s2_p1"]; $ipn["period3"] = $s2vars["s2_p3"]; $ipn["payer_email"] = $clickbank["ccustemail"]; $ipn["first_name"] = ucwords(strtolower($clickbank["ccustfirstname"])); $ipn["last_name"] = ucwords(strtolower($clickbank["ccustlastname"])); $ipn["option_name1"] = $s2vars["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars["s2_referencing"] ? $s2vars["s2_referencing"] : $_SERVER["HTTP_HOST"]; $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $s2vars["s2_customer_ip"]; $ipn["item_number"] = $s2vars["s2_invoice"]; $ipn["item_name"] = $s2vars["s2_desc"]; $ipn["optimizemember_paypal_proxy"] = "clickbank"; $ipn["optimizemember_paypal_proxy_use"] = "standard-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)); } if (!$processed) { // If nothing was processed, here we add a message to the logs indicating the IPN was ignored. $clickbank["optimizemember_log"][] = "Ignoring this IPN request. The transaction does NOT require any action on the part of optimizeMember."; } } else { $clickbank["optimizemember_log"][] = "Unable to verify POST vars. This is most likely related to an invalid ClickBank® configuration. Please check: optimizeMember -› ClickBank® Options."; $clickbank["optimizemember_log"][] = "If you're absolutely SURE that your ClickBank® configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to ClickBank® over an HTTPS connection."; $clickbank["optimizemember_log"][] = "optimizeMember uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows® server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows® server."; $clickbank["optimizemember_log"][] = var_export($_REQUEST, true); // Recording _POST + _GET vars for analysis and debugging. } /* If debugging/logging is enabled; we need to append $clickbank to the log file. Logging now supports Multisite Networking as well. */ $logt = c_ws_plugin__optimizemember_utilities::time_details(); $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "clickbank-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "clickbank-ipn.log"; if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__optimizemember_utils_logs::conceal_private_info(var_export($clickbank, true)) . "\n\n", FILE_APPEND); } } } 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. exit; // Exit now. } }
/** * Handles Authorize.Net IPN URL processing. * * @package optimizeMember\AuthNet * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling IPN processing. */ public static function authnet_notify() { global $current_site, $current_blog; /* For Multisite support. */ /**/ if (!empty($_GET["optimizemember_pro_authnet_notify"]) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_authnet_api_login_id"]) { @ignore_user_abort(true); /* Continue processing even if/when connection is broken by the sender. */ /**/ if (is_array($authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_postvars()) && ($_authnet = $authnet)) { $authnet["optimizemember_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $authnet["optimizemember_log"][] = "optimizeMember POST vars verified with Authorize.Net."; /**/ if ($authnet["x_subscription_id"] && $authnet["x_subscription_paynum"] && $authnet["x_response_code"] === "1") { if (($_authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) { $authnet["optimizemember_log"][] = "Authorize.Net transaction identified as ( `ARB / PAYMENT #" . $authnet["x_subscription_paynum"] . "` )."; $authnet["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_payment` )."; $authnet["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_payment"; $ipn["subscr_id"] = $authnet["x_subscription_id"]; $ipn["txn_id"] = $authnet["x_trans_id"]; /**/ $ipn["custom"] = $authnet["s2_custom"]; /**/ $ipn["mc_gross"] = number_format($authnet["x_amount"], 2, ".", ""); $ipn["mc_currency"] = strtoupper("USD"); /* Auth.Net uses USD. */ $ipn["tax"] = number_format($authnet["x_tax"], 2, ".", ""); /**/ $ipn["payer_email"] = $authnet["x_email"]; $ipn["first_name"] = $authnet["x_first_name"]; $ipn["last_name"] = $authnet["x_last_name"]; /**/ $ipn["option_name1"] = "Referencing Customer ID"; $ipn["option_selection1"] = $authnet["x_subscription_id"]; /**/ $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = null; /**/ $ipn["item_number"] = $authnet["s2_invoice"]; $ipn["item_name"] = $authnet["x_description"]; /**/ $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)); } else { $authnet["optimizemember_log"][] = "Authorize.Net transaction identified as ( `ARB / PAYMENT #" . $authnet["x_subscription_paynum"] . "` )."; $authnet["optimizemember_log"][] = "Ignoring this IPN. The transaction does NOT contain a valid reference value/desc."; } } else { if ($authnet["x_subscription_id"] && $authnet["x_subscription_paynum"] && preg_match("/^(2|3)\$/", $authnet["x_response_code"])) { if (($_authnet = c_ws_plugin__optimizemember_pro_authnet_utilities::authnet_parse_arb_desc($authnet)) && ($authnet = $_authnet)) { $authnet["optimizemember_log"][] = "Authorize.Net transaction identified as ( `ARB / FAILED PAYMENT` )."; $authnet["optimizemember_log"][] = "optimizeMember does NOT respond to individual failed payment notifications."; $authnet["optimizemember_log"][] = "When multiple consecutive payments fail, optimizeMember is notified via ARB services."; $authnet["optimizemember_log"][] = "This does not require any action ( at the moment ) on the part of optimizeMember."; } else { $authnet["optimizemember_log"][] = "Authorize.Net transaction identified as ( `ARB / FAILED PAYMENT` )."; $authnet["optimizemember_log"][] = "Ignoring this IPN. The transaction does NOT contain a valid reference value/desc."; } } else { if (!$processed) { /* If nothing was processed, here we add a message to the logs indicating the IPN was ignored. */ $authnet["optimizemember_log"][] = "Ignoring this IPN. The transaction does NOT require any action on the part of optimizeMember."; } } } } else { $authnet["optimizemember_log"][] = "Unable to verify POST vars. This is most likely related to an invalid Authorize.Net configuration. Please check: optimizeMember -> Authorize.Net Options."; $authnet["optimizemember_log"][] = "If you're absolutely SURE that your Authorize.Net configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to Authorize.Net over an HTTPS connection."; $authnet["optimizemember_log"][] = "optimizeMember uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows server."; $authnet["optimizemember_log"][] = var_export($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */ } /* If debugging/logging is enabled; we need to append $authnet to the log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "authnet-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "authnet-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($authnet, true) . "\n\n", FILE_APPEND); } } } /**/ 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. */ /**/ exit; /* Exit now. */ } }
/** * 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 />— 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 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&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; } } } }
/** * Handles Google IPN URL processing. * * @package optimizeMember\Google * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling the Notification. */ public static function google_notify() { global $current_site, $current_blog; /* For Multisite support. */ /**/ if (!empty($_GET["optimizemember_pro_google_notify"]) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_google_merchant_id"]) { @ignore_user_abort(true); /* Continue processing even if/when connection is broken by the sender. */ /**/ if (is_array($google = c_ws_plugin__optimizemember_pro_google_utilities::google_postvars()) && ($_google = $google)) { $google["optimizemember_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $google["optimizemember_log"][] = "optimizeMember POST vars verified with Google."; /**/ if (preg_match("/^new-order-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__optimizemember_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && !$s2vars_item1["s2_subscr_id"]) { $google["optimizemember_log"][] = "Google transaction identified as ( `SALE/BUY-NOW` )."; $google["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `web_accept` )."; $google["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "web_accept"; /**/ $ipn["txn_id"] = $s2vars_item1["s2_txn_id"] ? $s2vars_item1["s2_txn_id"] : $google["order-summary_google-order-number"]; /**/ $ipn["custom"] = $s2vars_item1["s2_custom"]; /**/ $ipn["mc_gross"] = number_format($google["order-summary_order-total"], 2, ".", ""); $ipn["mc_currency"] = strtoupper($google["order-summary_order-total_currency"]); $ipn["tax"] = number_format($google["order-summary_order-adjustment_total-tax"], 2, ".", ""); /**/ $ipn["payer_email"] = $google["buyer-billing-address_email"]; $ipn["first_name"] = $google["buyer-billing-address_structured-name_first-name"]; $ipn["last_name"] = $google["buyer-billing-address_structured-name_last-name"]; /**/ $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; /* IP Address. */ $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"]; /**/ $ipn["item_number"] = $s2vars_item1["s2_item_number"]; $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=google&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^new-order-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__optimizemember_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && $s2vars_item1["s2_subscr_id"] && !$s2vars_item1["s2_subscr_payment"]) { $google["optimizemember_log"][] = "Google transaction identified as ( `SALE/SUBSCRIPTION` )."; $google["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_signup` )."; $google["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_signup"; $ipn["subscr_id"] = $s2vars_item1["s2_subscr_id"]; /**/ $ipn["recurring"] = !($times = $google["order-summary_shopping-cart_items_item-2_subscription_payments_subscription-payment-1_times"]) || $times > 1 ? "1" : "0"; /**/ $ipn["txn_id"] = $google["order-summary_google-order-number"]; /**/ $ipn["custom"] = $s2vars_item1["s2_custom"]; /**/ $ipn["period1"] = $s2vars_item1["s2_period1"]; /* Just use optimizeMember's period calculations to make this easier. */ $ipn["period3"] = $s2vars_item1["s2_period3"]; /* Just use optimizeMember's period calculations to make this easier. */ /**/ $ipn["mc_amount1"] = number_format($google["order-summary_shopping-cart_items_item-1_unit-price"], 2, ".", ""); $ipn["mc_amount3"] = number_format($google["order-summary_shopping-cart_items_item-2_subscription_recurrent-item_unit-price"], 2, ".", ""); /**/ $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"]; /**/ $ipn["mc_currency"] = strtoupper($google["order-summary_order-total_currency"]); $ipn["tax"] = number_format($google["order-summary_order-adjustment_total-tax"], 2, ".", ""); /**/ $ipn["payer_email"] = $google["buyer-billing-address_email"]; $ipn["first_name"] = $google["buyer-billing-address_structured-name_first-name"]; $ipn["last_name"] = $google["buyer-billing-address_structured-name_last-name"]; /**/ $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; /* IP Address. */ $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"]; /**/ $ipn["item_number"] = $s2vars_item1["s2_item_number"]; $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=google&optimizemember_paypal_proxy_use=standard-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()); /**/ c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)); } else { if (preg_match("/^new-order-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__optimizemember_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && $s2vars_item1["s2_subscr_id"] && $s2vars_item1["s2_subscr_payment"]) { $google["optimizemember_log"][] = "Google transaction identified as ( `SUBSCRIPTION PAYMENT` )."; $google["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_payment` )."; $google["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_payment"; $ipn["subscr_id"] = $s2vars_item1["s2_subscr_id"]; /**/ $ipn["txn_id"] = $google["order-summary_google-order-number"]; /**/ $ipn["custom"] = $s2vars_item1["s2_custom"]; /**/ $ipn["mc_gross"] = number_format($google["order-summary_order-total"], 2, ".", ""); $ipn["mc_currency"] = strtoupper($google["order-summary_order-total_currency"]); $ipn["tax"] = number_format($google["order-summary_order-adjustment_total-tax"], 2, ".", ""); /**/ $ipn["payer_email"] = $google["buyer-billing-address_email"]; $ipn["first_name"] = $google["buyer-billing-address_structured-name_first-name"]; $ipn["last_name"] = $google["buyer-billing-address_structured-name_last-name"]; /**/ $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; /* IP Address. */ $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"]; /**/ $ipn["item_number"] = $s2vars_item1["s2_item_number"]; $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=google&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^cancelled-subscription-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__optimizemember_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && $s2vars_item1["s2_subscr_id"]) { $google["optimizemember_log"][] = "Google transaction identified as ( `SUBSCRIPTION CANCELLATION` )."; $google["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_cancel` )."; $google["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_cancel"; $ipn["subscr_id"] = $s2vars_item1["s2_subscr_id"]; /**/ $ipn["custom"] = $s2vars_item1["s2_custom"]; /**/ $ipn["period1"] = $s2vars_item1["s2_period1"]; $ipn["period3"] = $s2vars_item1["s2_period3"]; /**/ $ipn["payer_email"] = $google["order-summary_risk-information_billing-address_email"]; $ipn["first_name"] = preg_replace("/( )(.+)/", "", $google["order-summary_risk-information_billing-address_contact-name"]); $ipn["last_name"] = preg_replace("/(.+?)( )/", "", $google["order-summary_risk-information_billing-address_contact-name"]); /**/ $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; /* IP Address. */ $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"]; /**/ $ipn["item_number"] = $s2vars_item1["s2_item_number"]; $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=google&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^(refund|chargeback)-amount-notification\$/i", $google["_type"]) && is_array($s2vars_item1 = c_ws_plugin__optimizemember_pro_google_utilities::google_parse_s2vars($google["order-summary_shopping-cart_items_item-1_merchant-private-item-data"])) && (preg_match("/^refund/", $google["_type"]) && $google["latest-fee-refund-amount"] >= $google["order-summary_total-charge-amount"] || preg_match("/^chargeback/", $google["_type"]) && $google["latest-chargeback-amount"] >= $google["order-summary_total-charge-amount"])) { $google["optimizemember_log"][] = "Google transaction identified as ( `REFUND|CHARGEBACK` )."; $google["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `payment_status` ( `refunded|reversed` )."; $google["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["custom"] = $s2vars_item1["s2_custom"]; /**/ if ($s2vars_item1["s2_subscr_id"] && !$s2vars_item1["s2_txn_id"]) { $ipn["parent_txn_id"] = $s2vars_item1["s2_subscr_id"]; } else { if ($s2vars_item1["s2_txn_id"] && !$s2vars_item1["s2_subscr_id"]) { $ipn["parent_txn_id"] = $s2vars_item1["s2_txn_id"]; } else { /* Default to Google's Order #. */ $ipn["parent_txn_id"] = $google["order-summary_google-order-number"]; } } /**/ if (preg_match("/^refund/", $google["_type"])) { $ipn["payment_status"] = "refunded"; /* Refunding. */ $ipn["mc_fee"] = "-" . number_format($google["latest-fee-refund-amount"], 2, ".", ""); $ipn["mc_gross"] = "-" . number_format($google["latest-refund-amount"], 2, ".", ""); $ipn["mc_currency"] = strtoupper($google["latest-refund-amount_currency"]); $ipn["tax"] = "-" . number_format("0.00", 2, ".", ""); } else { if (preg_match("/^chargeback/", $google["_type"])) { $ipn["payment_status"] = "reversed"; /* Reversed/chargeback. */ $ipn["mc_fee"] = "-" . number_format($google["latest-chargeback-fee-amount"], 2, ".", ""); $ipn["mc_gross"] = "-" . number_format($google["latest-chargeback-amount"], 2, ".", ""); $ipn["mc_currency"] = strtoupper($google["latest-chargeback-amount_currency"]); $ipn["tax"] = "-" . number_format("0.00", 2, ".", ""); } } /**/ $ipn["payer_email"] = $google["order-summary_risk-information_billing-address_email"]; $ipn["first_name"] = preg_replace("/( )(.+)/", "", $google["order-summary_risk-information_billing-address_contact-name"]); $ipn["last_name"] = preg_replace("/(.+?)( )/", "", $google["order-summary_risk-information_billing-address_contact-name"]); /**/ $ipn["option_name1"] = $s2vars_item1["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $s2vars_item1["s2_referencing"] ? $s2vars_item1["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; /* IP Address. */ $ipn["option_selection2"] = $s2vars_item1["s2_customer_ip"]; /**/ $ipn["item_number"] = $s2vars_item1["s2_item_number"]; $ipn["item_name"] = $google["order-summary_shopping-cart_items_item-1_item-name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=google&optimizemember_paypal_proxy_use=standard-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)); } else { if (!$processed) { /* If nothing was processed, here we add a message to the logs indicating the IPN was ignored. */ $google["optimizemember_log"][] = "Ignoring this IPN request. The transaction does NOT require any action on the part of optimizeMember."; } } } } } } } else { $google["optimizemember_log"][] = "Unable to verify POST vars. This is most likely related to an invalid Google configuration. Please check: optimizeMember -> Google Options."; $google["optimizemember_log"][] = "If you're absolutely SURE that your Google configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to Google over an HTTPS connection."; $google["optimizemember_log"][] = "optimizeMember uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows server."; $google["optimizemember_log"][] = var_export($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */ } /* We need to log this final event before it occurs, so that is makes it into the log entry. */ $google["optimizemember_log"][] = "Sending Google an XML Notification Acknowlegment w/ original serial number."; /* If debugging/logging is enabled; we need to append $google to the log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "google-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "google-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($google, true) . "\n\n", FILE_APPEND); } } } /**/ $confirmation = '<?xml version="1.0" encoding="UTF-8"?>'; $confirmation .= '<notification-acknowledgment xmlns="http://checkout.google.com/schema/2"'; $confirmation .= ' serial-number="' . esc_attr(trim(stripslashes($_REQUEST["serial-number"]))) . '" />'; /**/ status_header(200); /* Send a 200 OK status header. */ header("Content-Type: application/xml"); /* Google expects application/xml here. */ eval('while (@ob_end_clean ());'); /* End/clean all output buffers that may or may not exist. */ /**/ exit($confirmation); /* Exit w/ serial number confirmation. */ } }
/** * Handles AliPay IPN URL processing. * * @package optimizeMember\AliPay * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling the Notification. */ public static function alipay_notify() { global $current_site, $current_blog; /* For Multisite support. */ /**/ if (!empty($_POST["notify_type"]) && preg_match("/^trade_status_sync\$/i", $_POST["notify_type"]) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_alipay_seller_email"]) { @ignore_user_abort(true); /* Continue processing even if/when connection is broken by the sender. */ /**/ if (is_array($alipay = c_ws_plugin__optimizemember_pro_alipay_utilities::alipay_postvars()) && ($_alipay = $alipay)) { $alipay["optimizemember_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $alipay["optimizemember_log"][] = "optimizeMember POST vars verified through a POST back to AliPay."; /**/ if (!is_array($alipay_already_p = get_transient("s2m_" . md5("optimizemember_pro_alipay_notify_ids"))) || !in_array($alipay["notify_id"], $alipay_already_p)) { $alipay_already_p = is_array($alipay_already_p) ? array_push($alipay_already_p, $alipay["notify_id"]) : array($alipay["notify_id"]); set_transient("s2m_" . md5("optimizemember_pro_alipay_notify_ids"), array_slice(array_unique($alipay_already_p), 0, 1000), 31556926); /**/ if (preg_match("/^(TRADE_FINISHED|TRADE_SUCCESS)\$/i", $alipay["trade_status"]) && !$alipay["refund_status"]) { $alipay["optimizemember_log"][] = "AliPay transaction identified as ( `TRADE_FINISHED|TRADE_SUCCESS` )."; $alipay["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `web_accept` )."; $alipay["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ list($alipay["invoice"], $alipay["item_number"], $alipay["referencing"], $alipay["customer_ip"]) = preg_split("/~/", $alipay["out_trade_no"]); list($alipay["first_name"], $alipay["last_name"]) = preg_split("/@/", $alipay["buyer_email"], 2); /**/ $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "web_accept"; /**/ $ipn["txn_id"] = $alipay["trade_no"]; /**/ $ipn["custom"] = $alipay["extra_common_param"]; /**/ $ipn["mc_gross"] = number_format($alipay["total_fee"], 2, ".", ""); $ipn["mc_currency"] = strtoupper("CNY"); /* Yuan. */ $ipn["tax"] = number_format("0.00", 2, ".", ""); /**/ $ipn["payer_email"] = $alipay["buyer_email"]; $ipn["first_name"] = $alipay["first_name"]; $ipn["last_name"] = $alipay["last_name"]; /**/ $ipn["option_name1"] = $alipay["referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $alipay["referencing"] ? $alipay["referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $alipay["customer_ip"]; /**/ $ipn["item_number"] = $alipay["item_number"]; $ipn["item_name"] = $alipay["body"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=alipay&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^(TRADE_CLOSED|TRADE_SUCCESS)\$/i", $alipay["trade_status"]) && $alipay["refund_status"]) { $alipay["optimizemember_log"][] = "AliPay transaction identified as ( `REFUND_SUCCESS` )."; $alipay["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `payment_status` ( `refunded` )."; $alipay["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ list($alipay["invoice"], $alipay["item_number"], $alipay["referencing"], $alipay["customer_ip"]) = preg_split("/~/", $alipay["out_trade_no"]); list($alipay["first_name"], $alipay["last_name"]) = preg_split("/@/", $alipay["buyer_email"], 2); /**/ $ipn = array(); /* Reset. */ /**/ $ipn["payment_status"] = "refunded"; /**/ $ipn["parent_txn_id"] = $alipay["trade_no"]; /**/ $ipn["custom"] = $alipay["extra_common_param"]; /**/ $ipn["mc_fee"] = "-" . number_format("0.00", 2, ".", ""); $ipn["mc_gross"] = "-" . number_format(abs($alipay["total_fee"]), 2, ".", ""); $ipn["mc_currency"] = strtoupper("CNY"); /* Yuan. */ $ipn["tax"] = "-" . number_format("0.00", 2, ".", ""); /**/ $ipn["payer_email"] = $alipay["buyer_email"]; $ipn["first_name"] = $alipay["first_name"]; $ipn["last_name"] = $alipay["last_name"]; /**/ $ipn["option_name1"] = $alipay["referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $alipay["referencing"] ? $alipay["referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $alipay["customer_ip"]; /**/ $ipn["item_number"] = $alipay["item_number"]; $ipn["item_name"] = $alipay["body"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=alipay&optimizemember_paypal_proxy_use=standard-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)); } else { $alipay["optimizemember_log"][] = "Ignoring this IPN request. The status does NOT require any action on the part of optimizeMember."; } } } else { $alipay["optimizemember_log"][] = "Ignoring duplicate IPN. optimizeMember has already processed AliPay Notification ID: " . $alipay["notify_id"] . "."; } } else { $alipay["optimizemember_log"][] = "Unable to verify POST vars. This is most likely related to an invalid AliPay configuration. Please check: optimizeMember -> AliPay Options."; $alipay["optimizemember_log"][] = "If you're absolutely SURE that your AliPay configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to AliPay over an HTTPS connection."; $alipay["optimizemember_log"][] = "optimizeMember uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows server."; $alipay["optimizemember_log"][] = var_export($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */ } /* If debugging/logging is enabled; we need to append $alipay to the log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "alipay-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "alipay-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($alipay, true) . "\n\n", FILE_APPEND); } } } /**/ status_header(200); /* 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. */ /**/ exit("success"); /* Exit now with "success". */ } }
/** * Connect to and process cancellations/refunds/chargebacks/etc via Payflow. * * optimizeMember's Auto EOT System must be enabled for this to work properly. * * If you have a HUGE userbase, increase the max IPNs per process. * But NOTE, this runs ``$per_process`` *( per Blog )* on a Multisite Network. * To increase, use: ``add_filter ("ws_plugin__optimizemember_pro_payflow_ipns_per_process");``. * * @package optimizeMember\PayPal * @since 120514 * * @attaches-to ``add_action("ws_plugin__optimizemember_after_auto_eot_system");`` * * @param array $vars Expects an array of defined variables to be passed in by the Action Hook. * @return null */ public static function payflow_service($vars = FALSE) { global $wpdb; /* Need global DB obj. */ global $current_site, $current_blog; /* For Multisite support. */ /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_username"]) { $scan_time = apply_filters("ws_plugin__optimizemember_pro_payflow_status_scan_time", strtotime("-1 day"), get_defined_vars()); $per_process = apply_filters("ws_plugin__optimizemember_pro_payflow_ipns_per_process", $vars["per_process"], get_defined_vars()); /**/ if (is_array($objs = $wpdb->get_results("SELECT `user_id` AS `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "optimizemember_subscr_gateway' AND `meta_value` = 'paypal' AND `user_id` NOT IN(SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "optimizemember_last_status_scan' AND `meta_value` > '" . esc_sql($scan_time) . "')"))) { foreach ($objs as $obj) { if (($user_id = $obj->ID) && ($counter = (int) $counter + 1)) { unset($paypal, $subscr_id, $ipn_sv, $processing, $processed, $ipn, $ipn_q, $log4, $_log4, $log2, $logs_dir); /**/ if (($subscr_id = get_user_option("optimizemember_subscr_id", $user_id)) && !get_user_option("optimizemember_auto_eot_time", $user_id)) { if (is_array($ipn_sv = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars(false, $subscr_id)) && ($paypal = c_ws_plugin__optimizemember_pro_paypal_utilities::payflow_get_profile($subscr_id)) && is_array($paypal["ipn_signup_vars"] = $ipn_sv)) { if (preg_match("/expired/i", $paypal["STATUS"])) { $paypal["optimizemember_log"][] = "Payflow IPN via polling, processed on: " . date("D M j, Y g:i:s a T"); /**/ $paypal["optimizemember_log"][] = "Payflow transaction identified as ( `SUBSCRIPTION EXPIRATION` )."; $paypal["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_eot` )."; $paypal["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_eot"; $ipn["subscr_id"] = $paypal["ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $paypal["ipn_signup_vars"]["custom"]; /**/ $ipn["period1"] = $paypal["ipn_signup_vars"]["period1"]; $ipn["period3"] = $paypal["ipn_signup_vars"]["period3"]; /**/ $ipn["payer_email"] = $paypal["ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $paypal["ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $paypal["ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $paypal["ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $paypal["ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $paypal["ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $paypal["ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $paypal["ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $paypal["ipn_signup_vars"]["item_name"]; /**/ $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)); } else { if (preg_match("/(suspended|canceled|terminated|deactivated)/i", $paypal["STATUS"])) { $paypal["optimizemember_log"][] = "Payflow IPN via polling, processed on: " . date("D M j, Y g:i:s a T"); /**/ $paypal["optimizemember_log"][] = "Payflow transaction identified as ( `SUBSCRIPTION " . strtoupper($paypal["STATUS"]) . "` )."; $paypal["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_cancel` )."; $paypal["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_cancel"; $ipn["subscr_id"] = $paypal["ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $paypal["ipn_signup_vars"]["custom"]; /**/ $ipn["period1"] = $paypal["ipn_signup_vars"]["period1"]; $ipn["period3"] = $paypal["ipn_signup_vars"]["period3"]; /**/ $ipn["payer_email"] = $paypal["ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $paypal["ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $paypal["ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $paypal["ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $paypal["ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $paypal["ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $paypal["ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $paypal["ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $paypal["ipn_signup_vars"]["item_name"]; /**/ $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)); } else { if (!$processed) { /* If nothing was processed, here we add a message to the logs indicating the status; which is being ignored. */ $paypal["optimizemember_log"][] = "Ignoring this status ( `" . $paypal["STATUS"] . "` ). It does NOT require any action on the part of optimizeMember."; } } } /**/ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "paypal-payflow-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "paypal-payflow-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($paypal, true) . "\n\n", FILE_APPEND); } } } } } /**/ update_user_option($user_id, "optimizemember_last_status_scan", time()); /**/ if ($counter >= $per_process) { /* Only this many. */ break; } /* Break the loop now. */ } } } } /**/ return; /* Return for uniformity. */ }
/** * Configures all new Users. * * The Hook `user_register` is also fired by calling: * ``c_ws_plugin__optimizemember_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``. * * This function also receives hand-offs from optimizeMember's handlers for these two Hooks: * `wpmu_activate_user` and `wpmu_activate_blog`. * * @package optimizeMember\Registrations * @since 3.5 * * @attaches-to ``add_action("user_register");`` * * @param int|str $user_id A numeric WordPress User ID. * @param str $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources. * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member. * @return null No return value. Returns `null` in possible every scenario. * * @todo Impossible to delete cookies when fired inside: `/wp-activate.php`? */ public static function configure_user_registration($user_id = FALSE, $password = FALSE, $meta = FALSE) { global $wpdb; /* Global database object reference. */ global $pagenow; /* We need this to detect the current administration page. */ global $current_site, $current_blog; /* Adds support for Multisite Networking. */ static $email_config, $processed; /* Static vars prevent duplicate processing. */ /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_before_configure_user_registration", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ /* With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`. */ if (!isset($email_config) && ($email_config = true)) { /* Anytime this routine is fired; we configure email. */ c_ws_plugin__optimizemember_email_configs::email_config(); } /* Configures `From:` email header. */ /**/ $_p = isset($_POST) ? $_POST : null; $rvs = isset($GLOBALS["ws_plugin__optimizemember_registration_vars"]) ? $GLOBALS["ws_plugin__optimizemember_registration_vars"] : null; /**/ if (!$processed) { /**/ if (is_array($_p) || is_array($meta) || is_array($rvs)) { /**/ if (!(is_multisite() && is_blog_admin() && $pagenow === "user-new.php" && isset($_p["noconfirmation"]) && is_super_admin() && !is_array($meta))) { if (!(preg_match("/\\/wp-activate\\.php/", $_SERVER["REQUEST_URI"]) && !is_array($meta))) { if (!(c_ws_plugin__optimizemember_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) { if (!(c_ws_plugin__optimizemember_utils_conds::pro_is_installed() && c_ws_plugin__optimizemember_pro_remote_ops::is_remote_op("create_user") && !is_array($rvs))) { /**/ if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = true)) { settype($_p, "array") . settype($meta, "array") . settype($rvs, "array"); /**/ $_p = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($_p)); $meta = c_ws_plugin__optimizemember_utils_strings::trim_deep(stripslashes_deep($meta)); $rvs = c_ws_plugin__optimizemember_utils_strings::trim_deep($rvs); /**/ foreach ($_p as $_key => $_value) { /* Scan ``$_p`` vars; adding `custom_reg_field` keys. */ if (preg_match("/^ws_plugin__optimizemember_user_new_/", $_key)) { /* Look for keys. */ if ($_key = str_replace("_user_new_", "_custom_reg_field_", $_key)) { $_p[$_key] = $_value; } } } /* Add each of these key conversions. */ unset($_key, $_value); /**/ if (!is_admin() && (isset($_p["ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_gateway"]) || isset($_p["ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_id"]) || isset($_p["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"]) || isset($_p["ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps"]) || isset($_p["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"]) || isset($_p["ws_plugin__optimizemember_custom_reg_field_optimizemember_notes"]))) { exit(_x("optimizeMember security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!", "s2member-front", "s2member")); } /**/ $_pmr = array_merge($_p, $meta, $rvs); /* Merge all of these arrays together now, in this specific order. */ unset($_p, $meta, $rvs); /* These variables can all be unset now; we have them all in the ``$_pmr`` array. */ /**/ $custom_reg_display_name = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_display_name"]; /* Can be configured by the site owner. */ /**/ if (!is_admin() && (!c_ws_plugin__optimizemember_utils_conds::pro_is_installed() || !c_ws_plugin__optimizemember_pro_remote_ops::is_remote_op("create_user")) && ($reg_cookies = c_ws_plugin__optimizemember_register_access::reg_cookies_ok()) && extract($reg_cookies)) { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`. This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`. If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */ /**/ $processed = "yes"; /* Mark this as yes. */ /**/ $current_role = c_ws_plugin__optimizemember_user_access::user_access_role($user); @(list($level, $ccaps, $eotper) = preg_split("/\\:/", $item_number, 3)); $role = "optimizemember_level" . $level; /* Membership Level. */ /**/ $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_registration_ip"]; $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip; /* Else use environment variable. */ $cv = preg_split("/\\|/", $custom); /**/ if (!($auto_eot_time = "") && $eotper) { /* If a specific EOT Period is included. */ $auto_eot_time = c_ws_plugin__optimizemember_utils_time::auto_eot_time("", "", "", $eotper); } /**/ $notes = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_notes"]; /**/ $opt_in = !$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] ? true : false; $opt_in = !$opt_in && !empty($_pmr["ws_plugin__optimizemember_custom_reg_field_opt_in"]) ? true : $opt_in; /**/ if (!($fname = $user->first_name)) { if (!empty($_pmr["ws_plugin__optimizemember_custom_reg_field_first_name"])) { $fname = (string) $_pmr["ws_plugin__optimizemember_custom_reg_field_first_name"]; } } /**/ if (!$fname) { /* Also try BuddyPress. */ if (!empty($_pmr["field_1"])) { /* BuddyPress? */ $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"])); } } /**/ if (!($lname = $user->last_name)) { if (!empty($_pmr["ws_plugin__optimizemember_custom_reg_field_last_name"])) { $lname = (string) $_pmr["ws_plugin__optimizemember_custom_reg_field_last_name"]; } } /**/ if (!$lname) { /* Also try BuddyPress. */ if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) { $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"])); } } /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_names"] && !$fname) { if ($login) { /* Username and empty Last Name. */ eval('$fname = trim ($login); $lname = "";'); } } /**/ $name = trim($fname . " " . $lname); /* Both names. */ /**/ if (!($pass = $password)) { /* Try optimizeMember's generator. */ if (!empty($GLOBALS["ws_plugin__optimizemember_generate_password_return"])) { $pass = (string) $GLOBALS["ws_plugin__optimizemember_generate_password_return"]; } } /**/ if (!$pass) { /* Also try BuddyPress Password. */ if (!empty($_pmr["signup_password"])) { /* BuddyPress? */ $pass = (string) $_pmr["signup_password"]; } } /**/ if ($pass) { !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null; update_user_option($user_id, "default_password_nag", false, true); } /**/ update_user_option($user_id, "optimizemember_registration_ip", $ip); update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time); update_user_option($user_id, "optimizemember_subscr_gateway", $subscr_gateway); update_user_option($user_id, "optimizemember_subscr_id", $subscr_id); update_user_option($user_id, "optimizemember_custom", $custom); update_user_option($user_id, "optimizemember_notes", $notes); /**/ if (!$user->first_name && $fname) { update_user_meta($user_id, "first_name", $fname); } /**/ if (!$user->last_name && $lname) { update_user_meta($user_id, "last_name", $lname); } /**/ if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === "full" && $name) { wp_update_user(array("ID" => $user_id, "display_name" => $name)); } else { if ($custom_reg_display_name === "first" && $fname) { wp_update_user(array("ID" => $user_id, "display_name" => $fname)); } else { if ($custom_reg_display_name === "last" && $lname) { wp_update_user(array("ID" => $user_id, "display_name" => $lname)); } else { if ($custom_reg_display_name === "login" && $login) { wp_update_user(array("ID" => $user_id, "display_name" => $login)); } } } } } /**/ if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) { remove_user_from_blog($user_id, $current_site->blog_id); } /* No Main Site Role. */ /**/ if (!get_user_meta($user_id, "optimizemember_originating_blog", true)) { /* Recorded yet? */ update_user_meta($user_id, "optimizemember_originating_blog", $current_blog->blog_id); } } /**/ if ($current_role !== $role) { /* Only if NOT the current Role. */ $user->set_role($role); } /* optimizeMember. */ /**/ if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_optimizemember_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } /**/ if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_optimizemember_ccap_" . $ccap); } } } /**/ if (!($fields = array()) && $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($_pmr["ws_plugin__optimizemember_custom_reg_field_" . $field_var])) { $fields[$field_var] = $_pmr["ws_plugin__optimizemember_custom_reg_field_" . $field_var]; } } } /**/ if (!empty($fields)) { /* Only if NOT empty. */ update_user_option($user_id, "optimizemember_custom_fields", $fields); } /**/ if ($level > 0) { $pr_times = get_user_option("optimizemember_paid_registration_times", $user_id); $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"]; $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level]; update_user_option($user_id, "optimizemember_paid_registration_times", $pr_times); /* Update now. */ } /**/ if (($transient = "s2m_" . md5("optimizemember_transient_ipn_signup_vars_" . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) { update_user_option($user_id, "optimizemember_ipn_signup_vars", $ipn_signup_vars); /* For future reference. */ delete_transient($transient); /* This can be deleted now. */ } if (($transient = "s2m_" . md5("optimizemember_transient_ipn_subscr_payment_" . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment["subscr_gateway"])) { $proxy = array("optimizemember_paypal_notify" => "1", "optimizemember_paypal_proxy" => stripslashes((string) $subscr_payment["subscr_gateway"]), "optimizemember_paypal_proxy_verification" => c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen()); c_ws_plugin__optimizemember_utils_urls::remote(add_query_arg(urlencode_deep($proxy), site_url("/")), stripslashes_deep($subscr_payment), array("timeout" => 20)); delete_transient($transient); /* This can be deleted now. */ } if (($transient = "s2m_" . md5("optimizemember_transient_ipn_subscr_eot_" . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot["subscr_gateway"])) { $proxy = array("optimizemember_paypal_notify" => "1", "optimizemember_paypal_proxy" => stripslashes((string) $subscr_eot["subscr_gateway"]), "optimizemember_paypal_proxy_verification" => c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen()); c_ws_plugin__optimizemember_utils_urls::remote(add_query_arg(urlencode_deep($proxy), site_url("/")), stripslashes_deep($subscr_eot), array("timeout" => 20)); delete_transient($transient); /* This can be deleted now. */ } /**/ if (!headers_sent()) { /* Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies. */ @setcookie("optimizemember_tracking", $optimizemember_tracking = c_ws_plugin__optimizemember_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("optimizemember_tracking", $optimizemember_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["optimizemember_tracking"] = $optimizemember_tracking); } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_during_configure_user_registration_front_side_paid", get_defined_vars()); do_action("ws_plugin__optimizemember_during_configure_user_registration_front_side", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { if (!is_admin() && (!c_ws_plugin__optimizemember_utils_conds::pro_is_installed() || !c_ws_plugin__optimizemember_pro_remote_ops::is_remote_op("create_user"))) { /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`. This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`. If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */ /**/ $processed = "yes"; /* Mark this as yes. */ /**/ $current_role = c_ws_plugin__optimizemember_user_access::user_access_role($user); $role = ""; /* Initialize ``$role`` to an empty string here, before processing. */ $role = !$role && ($level = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"]) > 0 ? "optimizemember_level" . $level : $role; $role = !$role && ($level = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"]) === "0" ? "subscriber" : $role; $role = !$role && $current_role ? $current_role : $role; /* Use existing Role? */ $role = !$role ? get_option("default_role") : $role; /* Otherwise default. */ /**/ $level = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"]; $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"] : $level; $level = !$level && preg_match("/^optimizemember_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^optimizemember_level/", "", $role) : $level; $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level; $level = !$level ? "0" : $level; /**/ $ccaps = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps"]; /**/ $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_registration_ip"]; $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip; /* Else use environment variable. */ $custom = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"]; $subscr_id = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_id"]; $subscr_gateway = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_gateway"]; $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"]); /**/ $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"]) ? strtotime($eot) : ""; $notes = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_notes"]; /**/ $opt_in = !$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_opt_in"] ? true : false; $opt_in = !$opt_in && !empty($_pmr["ws_plugin__optimizemember_custom_reg_field_opt_in"]) ? true : $opt_in; /**/ if (!($fname = $user->first_name)) { if (!empty($_pmr["ws_plugin__optimizemember_custom_reg_field_first_name"])) { $fname = (string) $_pmr["ws_plugin__optimizemember_custom_reg_field_first_name"]; } } /**/ if (!$fname) { /* Also try BuddyPress. */ if (!empty($_pmr["field_1"])) { /* BuddyPress? */ $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"])); } } /**/ if (!($lname = $user->last_name)) { if (!empty($_pmr["ws_plugin__optimizemember_custom_reg_field_last_name"])) { $lname = (string) $_pmr["ws_plugin__optimizemember_custom_reg_field_last_name"]; } } /**/ if (!$lname) { /* Also try BuddyPress. */ if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) { $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"])); } } /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_names"] && !$fname) { if ($login) { /* Username and empty Last Name. */ eval('$fname = trim ($login); $lname = "";'); } } /**/ $name = trim($fname . " " . $lname); /* Both names. */ /**/ if (!($pass = $password)) { /* Try optimizeMember's generator. */ if (!empty($GLOBALS["ws_plugin__optimizemember_generate_password_return"])) { $pass = (string) $GLOBALS["ws_plugin__optimizemember_generate_password_return"]; } } /**/ if (!$pass) { /* Also try BuddyPress Password. */ if (!empty($_pmr["signup_password"])) { /* BuddyPress? */ $pass = (string) $_pmr["signup_password"]; } } /**/ if ($pass) { !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null; update_user_option($user_id, "default_password_nag", false, true); } /**/ update_user_option($user_id, "optimizemember_registration_ip", $ip); update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time); update_user_option($user_id, "optimizemember_subscr_gateway", $subscr_gateway); update_user_option($user_id, "optimizemember_subscr_id", $subscr_id); update_user_option($user_id, "optimizemember_custom", $custom); update_user_option($user_id, "optimizemember_notes", $notes); /**/ if (!$user->first_name && $fname) { update_user_meta($user_id, "first_name", $fname); } /**/ if (!$user->last_name && $lname) { update_user_meta($user_id, "last_name", $lname); } /**/ if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === "full" && $name) { wp_update_user(array("ID" => $user_id, "display_name" => $name)); } else { if ($custom_reg_display_name === "first" && $fname) { wp_update_user(array("ID" => $user_id, "display_name" => $fname)); } else { if ($custom_reg_display_name === "last" && $lname) { wp_update_user(array("ID" => $user_id, "display_name" => $lname)); } else { if ($custom_reg_display_name === "login" && $login) { wp_update_user(array("ID" => $user_id, "display_name" => $login)); } } } } } /**/ if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) { remove_user_from_blog($user_id, $current_site->blog_id); } /**/ if (!get_user_meta($user_id, "optimizemember_originating_blog", true)) { update_user_meta($user_id, "optimizemember_originating_blog", $current_blog->blog_id); } } /**/ if ($current_role !== $role) { /* Only if NOT the current Role. */ $user->set_role($role); } /* optimizeMember. */ /**/ if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_optimizemember_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } /**/ if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_optimizemember_ccap_" . $ccap); } } } /**/ if (!($fields = array()) && $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($_pmr["ws_plugin__optimizemember_custom_reg_field_" . $field_var])) { $fields[$field_var] = $_pmr["ws_plugin__optimizemember_custom_reg_field_" . $field_var]; } } } /**/ if (!empty($fields)) { /* Only if NOT empty. */ update_user_option($user_id, "optimizemember_custom_fields", $fields); } /**/ if ($level > 0) { $pr_times = get_user_option("optimizemember_paid_registration_times", $user_id); $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"]; $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level]; update_user_option($user_id, "optimizemember_paid_registration_times", $pr_times); /* Update now. */ } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_during_configure_user_registration_front_side_free", get_defined_vars()); do_action("ws_plugin__optimizemember_during_configure_user_registration_front_side", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } else { if (is_blog_admin() && $pagenow === "user-new.php" || c_ws_plugin__optimizemember_utils_conds::pro_is_installed() && c_ws_plugin__optimizemember_pro_remote_ops::is_remote_op("create_user")) { /* Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`. */ /**/ $processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */ /**/ $current_role = c_ws_plugin__optimizemember_user_access::user_access_role($user); $role = ""; /* Initialize $role to an empty string here, before processing. */ $role = !$role && ($level = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"]) > 0 ? "optimizemember_level" . $level : $role; $role = !$role && ($level = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"]) === "0" ? "subscriber" : $role; $role = !$role && $current_role ? $current_role : $role; /* Use existing Role? */ $role = !$role ? get_option("default_role") : $role; /* Otherwise default. */ /**/ $level = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_level"]; $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["levels"] : $level; $level = !$level && preg_match("/^optimizemember_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^optimizemember_level/", "", $role) : $level; $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level; $level = !$level ? "0" : $level; /**/ $ccaps = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_ccaps"]; /**/ $email = $user->user_email; $login = $user->user_login; $ip = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_registration_ip"]; $custom = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"]; $subscr_id = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_id"]; $subscr_gateway = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_subscr_gateway"]; $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_custom"]); /**/ $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_auto_eot_time"]) ? strtotime($eot) : ""; $notes = (string) @$_pmr["ws_plugin__optimizemember_custom_reg_field_optimizemember_notes"]; /**/ $opt_in = !empty($_pmr["ws_plugin__optimizemember_custom_reg_field_opt_in"]) ? true : false; /**/ if (!($fname = $user->first_name)) { /* `Users -> Add New`. */ if (!empty($_pmr["ws_plugin__optimizemember_custom_reg_field_first_name"])) { $fname = (string) $_pmr["ws_plugin__optimizemember_custom_reg_field_first_name"]; } } /**/ if (!($lname = $user->last_name)) { /* `Users -> Add New`. */ if (!empty($_pmr["ws_plugin__optimizemember_custom_reg_field_last_name"])) { $lname = (string) $_pmr["ws_plugin__optimizemember_custom_reg_field_last_name"]; } } /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["custom_reg_names"] && !$fname) { if ($login) { /* Username and empty Last Name. */ eval('$fname = trim ($login); $lname = "";'); } } /**/ $name = trim($fname . " " . $lname); /* Both names. */ /**/ if (!($pass = $password)) { /* Try optimizeMember's generator. */ if (!empty($GLOBALS["ws_plugin__optimizemember_generate_password_return"])) { $pass = (string) $GLOBALS["ws_plugin__optimizemember_generate_password_return"]; } } /**/ if (!$pass) { /* Also try the `Users -> Add New` form. */ if (!empty($_pmr["pass1"])) { /* Field in `/user-new.php`. */ $pass = (string) $_pmr["pass1"]; } } /**/ if ($pass) { !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null; update_user_option($user_id, "default_password_nag", false, true); } /**/ update_user_option($user_id, "optimizemember_registration_ip", $ip); update_user_option($user_id, "optimizemember_auto_eot_time", $auto_eot_time); update_user_option($user_id, "optimizemember_subscr_gateway", $subscr_gateway); update_user_option($user_id, "optimizemember_subscr_id", $subscr_id); update_user_option($user_id, "optimizemember_custom", $custom); update_user_option($user_id, "optimizemember_notes", $notes); /**/ if (!$user->first_name && $fname) { update_user_meta($user_id, "first_name", $fname); } /**/ if (!$user->last_name && $lname) { update_user_meta($user_id, "last_name", $lname); } /**/ if (!$user->display_name || $user->display_name === $user->user_login) { if ($custom_reg_display_name === "full" && $name) { wp_update_user(array("ID" => $user_id, "display_name" => $name)); } else { if ($custom_reg_display_name === "first" && $fname) { wp_update_user(array("ID" => $user_id, "display_name" => $fname)); } else { if ($custom_reg_display_name === "last" && $lname) { wp_update_user(array("ID" => $user_id, "display_name" => $lname)); } else { if ($custom_reg_display_name === "login" && $login) { wp_update_user(array("ID" => $user_id, "display_name" => $login)); } } } } } /**/ if (is_multisite()) { if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) { remove_user_from_blog($user_id, $current_site->blog_id); } /* No Main Site Role. */ /**/ if (!get_user_meta($user_id, "optimizemember_originating_blog", true)) { /* Recorded yet? */ update_user_meta($user_id, "optimizemember_originating_blog", $current_blog->blog_id); } } /**/ if ($current_role !== $role) { /* Only if NOT the current Role. */ $user->set_role($role); } /* optimizeMember. */ /**/ if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) { foreach ($user->allcaps as $cap => $cap_enabled) { if (preg_match("/^access_optimizemember_ccap_/", $cap)) { $user->remove_cap($ccap = $cap); } } } /**/ if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) { foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) { if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) { $user->add_cap("access_optimizemember_ccap_" . $ccap); } } } /**/ if (!($fields = array()) && $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($_pmr["ws_plugin__optimizemember_custom_reg_field_" . $field_var])) { $fields[$field_var] = $_pmr["ws_plugin__optimizemember_custom_reg_field_" . $field_var]; } } } /**/ if (!empty($fields)) { /* Only if NOT empty. */ update_user_option($user_id, "optimizemember_custom_fields", $fields); } /**/ if ($level > 0) { $pr_times = get_user_option("optimizemember_paid_registration_times", $user_id); $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"]; $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level]; update_user_option($user_id, "optimizemember_paid_registration_times", $pr_times); /* Update now. */ } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_during_configure_user_registration_admin_side", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } } } /**/ if ($processed === "yes") { if ($urls = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["registration_notification_urls"]) { /**/ foreach (preg_split("/[\r\n\t]+/", $urls) as $url) { /* Notify each of the URLs. */ /**/ if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) { if ($url = preg_replace("/%%role%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($role)), $url)) { if ($url = preg_replace("/%%level%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($level)), $url)) { if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($ccaps)), $url)) { if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) { if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($fname)), $url)) { if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($lname)), $url)) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($name)), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($login)), $url)) { if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($pass)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($user_id)), $url)) { foreach ($fields as $var => $val) { /* Custom Fields. */ if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) { break; } } /**/ if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__optimizemember_utils_urls::remote($url); } } } } } } } } } } } } } } } } /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["registration_notification_recipients"]) { $email_configs_were_on = c_ws_plugin__optimizemember_email_configs::email_config_status(); c_ws_plugin__optimizemember_email_configs::email_config_release(); /**/ $msg = $sbj = "( optimizeMember / API Notification Email ) - Registration"; $msg .= "\n\n"; /* Spacing in the message body. */ /**/ $msg .= "role: %%role%%\n"; $msg .= "level: %%level%%\n"; $msg .= "ccaps: %%ccaps%%\n"; $msg .= "auto_eot_time: %%auto_eot_time%%\n"; $msg .= "user_first_name: %%user_first_name%%\n"; $msg .= "user_last_name: %%user_last_name%%\n"; $msg .= "user_full_name: %%user_full_name%%\n"; $msg .= "user_email: %%user_email%%\n"; $msg .= "user_login: %%user_login%%\n"; $msg .= "user_pass: %%user_pass%%\n"; $msg .= "user_ip: %%user_ip%%\n"; $msg .= "user_id: %%user_id%%\n"; /**/ foreach ($fields as $var => $val) { $msg .= $var . ": %%" . $var . "%%\n"; } /**/ $msg .= "cv0: %%cv0%%\n"; $msg .= "cv1: %%cv1%%\n"; $msg .= "cv2: %%cv2%%\n"; $msg .= "cv3: %%cv3%%\n"; $msg .= "cv4: %%cv4%%\n"; $msg .= "cv5: %%cv5%%\n"; $msg .= "cv6: %%cv6%%\n"; $msg .= "cv7: %%cv7%%\n"; $msg .= "cv8: %%cv8%%\n"; $msg .= "cv9: %%cv9%%"; /**/ if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) { if ($msg = preg_replace("/%%role%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($role), $msg)) { if ($msg = preg_replace("/%%level%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($level), $msg)) { if ($msg = preg_replace("/%%ccaps%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($ccaps), $msg)) { if ($msg = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($auto_eot_time), $msg)) { if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($fname), $msg)) { if ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($lname), $msg)) { if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($name), $msg)) { if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($email), $msg)) { if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($login), $msg)) { if ($msg = preg_replace("/%%user_pass%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($pass), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($ip), $msg)) { if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs($user_id), $msg)) { foreach ($fields as $var => $val) { /* Custom Fields. */ if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(maybe_serialize($val)), $msg))) { break; } } /**/ if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { /* Still have a ``$sbj`` and a ``$msg``? */ /**/ foreach (c_ws_plugin__optimizemember_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["registration_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__optimizemember_registration_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__optimizemember_registration_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=utf-8"); } } } } } } } } } } } } } } } /**/ if ($email_configs_were_on) { /* Back on? */ c_ws_plugin__optimizemember_email_configs::email_config(); } } /**/ if (!empty($GLOBALS["ws_plugin__optimizemember_registration_return_url"]) && ($url = $GLOBALS["ws_plugin__optimizemember_registration_return_url"])) { /**/ if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) { if ($url = preg_replace("/%%role%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($role)), $url)) { if ($url = preg_replace("/%%level%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($level)), $url)) { if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($ccaps)), $url)) { if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) { if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($fname)), $url)) { if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($lname)), $url)) { if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($name)), $url)) { if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($email)), $url)) { if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($login)), $url)) { if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($pass)), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($ip)), $url)) { if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode($user_id)), $url)) { foreach ($fields as $var => $val) { /* Custom Fields. */ if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__optimizemember_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) { break; } } /**/ if ($url = trim($url)) { /* Preserve remaining Replacements; because the parent routine may perform replacements too. */ $GLOBALS["ws_plugin__optimizemember_registration_return_url"] = $url; } } } } } } } } } } } } } } } /**/ c_ws_plugin__optimizemember_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, true, $user_id); /* Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques. @todo It may also be impossible to delete cookies when fired inside: `/wp-activate.php`. */ if (!headers_sent()) { @setcookie("optimizemember_subscr_gateway", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("optimizemember_subscr_gateway", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie("optimizemember_subscr_id", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("optimizemember_subscr_id", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie("optimizemember_custom", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("optimizemember_custom", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); @setcookie("optimizemember_item_number", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("optimizemember_item_number", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN); } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_during_configure_user_registration", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ } } } } } } } } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_after_configure_user_registration", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return; /* Return for uniformity. */ }
/** * 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 />— 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 />— 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 />— 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 />— 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; } } } }
public function __construct() { echo '<div class="wrap ws-menu-page op-bsw-wizard op-bsw-content">' . "\n"; /**/ echo '<div class="op-bsw-header">'; echo '<div class="op-logo"><img src="' . $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["dir_url"] . "/images/" . 'logo-optimizepress.png" alt="OptimizePress" height="50" class="animated flipInY"></div>'; echo '</div>'; echo '<div class="op-bsw-main-content">'; echo '<h2>PayPal Options</h2>' . "\n"; /**/ echo '<table class="ws-menu-page-table">' . "\n"; echo '<tbody class="ws-menu-page-table-tbody">' . "\n"; echo '<tr class="ws-menu-page-table-tr">' . "\n"; echo '<td class="ws-menu-page-table-l">' . "\n"; /**/ echo '<form method="post" name="ws_plugin__optimizemember_options_form" id="ws-plugin--optimizemember-options-form">' . "\n"; echo '<input type="hidden" name="ws_plugin__optimizemember_options_save" id="ws-plugin--optimizemember-options-save" value="' . esc_attr(wp_create_nonce("ws-plugin--optimizemember-options-save")) . '" />' . "\n"; echo '<input type="hidden" name="ws_plugin__optimizemember_configured" id="ws-plugin--optimizemember-configured" value="1" />' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_before_left_sections", get_defined_vars()); /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_paypal_account_details", true, get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_paypal_account_details", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="PayPal Account Details">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-paypal-account-details-section">' . "\n"; echo '<a href="http://www.optimizepress.com/paypal" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["dir_url"]) . '/images/paypal-logo.png" class="ws-menu-page-right" style="width:125px; height:125px; border:0;" alt="." /></a>' . "\n"; echo '<h3>PayPal Account Details ( required, if using PayPal )</h3>' . "\n"; echo '<p>This plugin works in conjunction with <a href="http://www.optimizepress.com/paypal" target="_blank" rel="external">PayPal Website Payments Standard</a>, for businesses. You do NOT need a PayPal Pro account. You just need to upgrade your Personal PayPal account to a Business status, which is free. A PayPal account can be <a href="http://pages.ebay.com/help/buy/questions/upgrade-paypal-account.html" target="_blank" rel="external">upgraded</a> from a Personal account to a Business account, simply by going to the `Profile` button under the `My Account` tab, selecting the `Personal Business Information` button, and then clicking the `Upgrade Your Account` button. </p>' . "\n"; echo '<p><em><strong>*PayPal API Credentials*</strong> Once you have a PayPal Business account, you\'ll need access to your <a href="http://www.optimizepress.com/paypal-profile-api-access" target="_blank" rel="external">PayPal API Credentials</a>. Log into your PayPal account, and navigate to <code>Profile -> API Access (or Request API Credentials)</code>. You\'ll choose <code>( PayPal / Request API Signature )</code>.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_account_details", get_defined_vars()); /**/ echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-business">' . "\n"; echo 'Your PayPal EMail Address:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_paypal_business" id="ws-plugin--optimizemember-paypal-business" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_business"]) . '" /><br />' . "\n"; echo 'Enter the email address you\'ve associated with your PayPal Business account.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-api-username">' . "\n"; echo 'Your PayPal API Username:'******'</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_paypal_api_username" id="ws-plugin--optimizemember-paypal-api-username" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_api_username"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials)</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-api-password">' . "\n"; echo 'Your PayPal API Password:'******'</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="password" autocomplete="off" name="ws_plugin__optimizemember_paypal_api_password" id="ws-plugin--optimizemember-paypal-api-password" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_api_password"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials)</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-api-signature">' . "\n"; echo 'Your PayPal API Signature:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="password" autocomplete="off" name="ws_plugin__optimizemember_paypal_api_signature" id="ws-plugin--optimizemember-paypal-api-signature" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_api_signature"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials)</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_account_detail_rows", get_defined_vars()); echo '</tbody>' . "\n"; echo '</table>' . "\n"; /**/ echo '<div class="ws-menu-page-hr"></div>' . "\n"; /**/ echo '<table class="form-table" style="margin:0;">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th style="padding-top:0;">' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-sandbox">' . "\n"; echo 'Developer/Sandbox Testing?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="radio" name="ws_plugin__optimizemember_paypal_sandbox" id="ws-plugin--optimizemember-paypal-sandbox-0" value="0"' . (!$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--optimizemember-paypal-sandbox-0">No</label> <input type="radio" name="ws_plugin__optimizemember_paypal_sandbox" id="ws-plugin--optimizemember-paypal-sandbox-1" value="1"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--optimizemember-paypal-sandbox-1">Yes, enable support for Sandbox testing.</label><br />' . "\n"; echo '<em>Only enable this if you\'ve provided Sandbox credentials above.<br />This puts the API, IPN, PDT and Form/Button Generators all into Sandbox mode.<br />See: <a href="http://www.optimizepress.com/paypal-developers" target="_blank" rel="external">PayPal Developers</a></em>' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-btn-encryption">' . "\n"; echo 'Enable Button Encryption?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="radio" name="ws_plugin__optimizemember_paypal_btn_encryption" id="ws-plugin--optimizemember-paypal-btn-encryption-0" value="0"' . (!$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_btn_encryption"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--optimizemember-paypal-btn-encryption-0">No</label> <input type="radio" name="ws_plugin__optimizemember_paypal_btn_encryption" id="ws-plugin--optimizemember-paypal-btn-encryption-1" value="1"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_btn_encryption"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--optimizemember-paypal-btn-encryption-1">Yes, enable PayPal Button encryption.</label><br />' . "\n"; echo '<em>If enabled, all of your PayPal Button Shortcodes will produce *encrypted* PayPal Buttons. This improves security against fraudulent transactions. For extra security, you should update your PayPal account too, under: <code>My Profile -> Website Payment Preferences</code>. You\'ll want to block all non-encrypted payments. <strong>*Note*</strong> this will NOT work until you\'ve supplied optimizeMember with your PayPal Email Address, and also with your API Username/Password/Signature.</em>' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; /**/ if (!is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site()) { echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-gateway-debug-logs">' . "\n"; echo 'Enable Logging Routines?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="radio" name="ws_plugin__optimizemember_gateway_debug_logs" id="ws-plugin--optimizemember-gateway-debug-logs-0" value="0"' . (!$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--optimizemember-gateway-debug-logs-0">No</label> <input type="radio" name="ws_plugin__optimizemember_gateway_debug_logs" id="ws-plugin--optimizemember-gateway-debug-logs-1" value="1"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"] ? ' checked="checked"' : '') . ' /> <label for="ws-plugin--optimizemember-gateway-debug-logs-1">Yes, enable debugging, with API, IPN & Return Page logging.</label><br />' . "\n"; echo '<em>This enables API, IPN and Return Page logging. The log files are stored here:<br /><code>' . esc_html(c_ws_plugin__optimizemember_utils_dirs::doc_root_path($GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) . '</code></em>' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; } /**/ echo '</tbody>' . "\n"; echo '</table>' . "\n"; /**/ echo '<div class="ws-menu-page-hr"></div>' . "\n"; /**/ echo '<p><em><strong>*Sandbox Tip*</strong> If you\'re testing your site through a PayPal Sandbox account, please remember that Email Confirmations from optimizeMember will NOT be received after a test purchase. optimizeMember sends its Confirmation Emails to the PayPal Email Address of the Customer. Since PayPal Sandbox addresses are usually bogus ( for testing ), you will have to run live transactions before Email Confirmations from optimizeMember are received. That being said, all other optimizeMember functionality CAN be tested through a PayPal Sandbox account. Email Confirmations are the only hang-up.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_account_details_after_sandbox_tip", get_defined_vars()); echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_paypal_account_details", get_defined_vars()); } /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_paypal_payflow_account_details", c_ws_plugin__optimizemember_utils_conds::pro_is_installed(), get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_paypal_payflow_account_details", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="Payflow™ Account Details">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-paypal-payflow-account-details-section">' . "\n"; echo '<a href="http://www.optimizepress.com/paypal" target="_blank"><img src="' . esc_attr($GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["dir_url"]) . '/images/paypal-logo.png" class="ws-menu-page-right" style="width:125px; height:125px; border:0;" alt="." /></a>' . "\n"; echo '<h3>Payflow Account Details ( required, if using Payflow )</h3>' . "\n"; echo '<p>Newer PayPal Pro accounts come with the Payflow API for Recurring Billing service. If you have a newer PayPal Pro account, and you wish to integrate PayPal\'s Recurring Billing service with optimizeMember Pro Forms, you will need to fill in the details here. Providing Payflow API Credentials here, automatically puts optimizeMember\'s Recurring Billing integration through Pro Forms, into Payflow mode. Just fill in the details below, and you\'re ready to generate Pro Forms that charge customers on a recurring basis. optimizeMember will use the Payflow API instead of the standard PayPal Pro API, which is being slowly phased out in favor of Payflow.</p>' . "\n"; echo '<p><em><strong>*Payflow API Credentials*</strong> Once you have a PayPal Pro account, you\'ll need access to your <a href="http://www.optimizepress.com/paypal-profile-api-access" target="_blank" rel="external">Payflow API Credentials</a>. Log into your PayPal account, and navigate to <code>Profile -> API Access (or Request API Credentials)</code>. You\'ll choose <code>( Payflow / API Access )</code>.</em></p>' . "\n"; echo '<p><em><strong>*Important Note*</strong> optimizeMember always uses the PayPal Pro API. It can also use the Payflow API (if details are supplied here). But please note... supplying Payflow API Credentials here, does NOT mean you can bypass other sections. Please supply optimizeMember with ALL of your PayPal account details.</em></p>' . "\n"; //echo '<p><strong>See also:</strong> This KB article: <a href="http://www.optimizepress.com/kb/paypal-pro-payflow-edition/" target="_blank" rel="external">PayPal Pro (PayFlow Edition)</a>.</p>'."\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_payflow_account_details", get_defined_vars()); /**/ echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-payflow-api-username">' . "\n"; echo 'Your Payflow API Username:'******'</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_paypal_payflow_api_username" id="ws-plugin--optimizemember-paypal-payflow-api-username" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_username"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials) -> Payflow API Access</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-payflow-api-password">' . "\n"; echo 'Your Payflow API Password:'******'</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="password" autocomplete="off" name="ws_plugin__optimizemember_paypal_payflow_api_password" id="ws-plugin--optimizemember-paypal-payflow-api-password" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_password"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials) -> Payflow API Access</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-payflow-api-partner">' . "\n"; echo 'Your Payflow API Partner:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" name="ws_plugin__optimizemember_paypal_payflow_api_partner" id="ws-plugin--optimizemember-paypal-payflow-api-partner" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_partner"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials) -> Payflow API Access</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-payflow-api-vendor">' . "\n"; echo 'Your Payflow API Vendor:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" name="ws_plugin__optimizemember_paypal_payflow_api_vendor" id="ws-plugin--optimizemember-paypal-payflow-api-vendor" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_payflow_api_vendor"]) . '" /><br />' . "\n"; echo 'At PayPal, see: <code>Profile -> API Access (or Request API Credentials) -> Payflow API Access</code>.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_payflow_account_detail_rows", get_defined_vars()); echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_paypal_payflow_account_details", get_defined_vars()); } /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_paypal_ipn", true, get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_paypal_ipn", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="PayPal IPN Integration">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-paypal-ipn-section">' . "\n"; echo '<h3>PayPal IPN / Instant Payment Notifications ( required, please enable )</h3>' . "\n"; echo '<p>Log into your PayPal account and navigate to this section:<br /><code>Account Profile -> Instant Payment Notification Preferences</code></p>' . "\n"; echo '<p>Edit your IPN settings & turn IPN Notifications: <strong><code>On</code></strong></p>' . "\n"; echo '<p>You\'ll need your IPN URL, which is:<br /><code>' . esc_html(site_url("/?optimizemember_paypal_notify=1")) . '</code></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_ipn", get_defined_vars()); /**/ echo '<h3>More Information ( <a href="#" onclick="jQuery(\'div#ws-plugin--optimizemember-paypal-ipn-details\').toggle(); return false;" class="ws-dotted-link">click here</a> )</h3>' . "\n"; echo '<div id="ws-plugin--optimizemember-paypal-ipn-details" style="display:none;">' . "\n"; echo '<p><em><strong>*Quick Tip*</strong> In addition to the <a href="http://www.optimizepress.com/paypal-ipn-setup" target="_blank" rel="external">default IPN settings inside your PayPal account</a>, the IPN URL is also set on a per-transaction basis by the special PayPal Button Code that optimizeMember provides you with. In other words, if you have multiple sites operating on one PayPal account, that\'s OK. optimizeMember dynamically sets the IPN URL for each transaction. The result is that the IPN URL configured from within your PayPal account, becomes the default, which is then overwritten on a per-transaction basis. In fact, PayPal recently updated their system to support IPN URL preservation. One PayPal account can handle multiple sites, all using different IPN URLs.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_ipn_after_quick_tip", get_defined_vars()); echo '<p><em><strong>*IPN Communications*</strong> You\'ll be happy to know that optimizeMember handles cancellations, expirations, failed payments, terminations ( e.g. refunds & chargebacks ) for you automatically. If you log into your PayPal account and cancel a Member\'s Subscription, or, if the Member logs into their PayPal account and cancels their own Subscription, optimizeMember will be notified of these important changes and react accordingly through the PayPal IPN service that runs silently behind-the-scene. The PayPal IPN service will notify optimizeMember whenever a Member\'s payments have been failing, and/or whenever a Member\'s Subscription has expired for any reason. Even refunds & chargeback reversals are supported through the IPN service. If you issue a refund to an unhappy Customer through PayPal, optimizeMember will be notified, and the account for that Customer will either be demoted to a Free Subscriber, or deleted automatically ( based on your configuration ). The communication from PayPal -> optimizeMember is seamless.</em></p>' . "\n"; echo '</div>' . "\n"; /**/ echo '<div class="ws-menu-page-hr"></div>' . "\n"; /**/ echo '<h3>IPN w/ Proxy Key ( <a href="#" onclick="jQuery(\'div#ws-plugin--optimizemember-paypal-ipn-proxy-details\').toggle(); return false;" class="ws-dotted-link">optional, for 3rd-party integrations</a> )</h3>' . "\n"; echo '<div id="ws-plugin--optimizemember-paypal-ipn-proxy-details" style="display:none;">' . "\n"; echo '<p>If you\'re using a 3rd-party application that needs to POST simulated IPN transactions to your optimizeMember installation, you can use this alternate IPN URL, which includes a Proxy Key. This encrypted Proxy Key verifies incoming data being received by optimizeMember\'s IPN processor. You can change <em>[proxy-gateway]</em> to whatever you like. The <em>[proxy-gateway]</em> value is required. It will be stored by optimizeMember as the Customer\'s Paid Subscr. Gateway. Your [proxy-gateway] value will also be reflected in optimizeMember\'s IPN log.</p>' . "\n"; echo '<input type="text" autocomplete="off" value="' . format_to_edit(site_url("/?optimizemember_paypal_notify=1&optimizemember_paypal_proxy=[proxy-gateway]&optimizemember_paypal_proxy_verification=" . urlencode(c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen()))) . '" style="width:99%;" />' . "\n"; echo '<p><em>Any 3rd-party application that is sending IPN transactions to your optimizeMember installation, must ALWAYS include the <code>custom</code> POST variable, and that variable must always start with your installation domain ( i.e. custom=<code>' . esc_html($_SERVER["HTTP_HOST"]) . '</code> ). In addition, the <code>item_number</code> variable, must always match a format that optimizeMember looks for. Generally speaking, the <code>item_number</code> should be <code>1, 2, 3, or 4</code>, indicating a specific optimizeMember Level #. However, optimizeMember also uses some advanced formats in this field. Just to be sure, we suggest creating a PayPal Button with the optimizeMember Button Generator, and then taking a look at the Full Button Code to see how optimizeMember expects <code>item_number</code> to be formatted. Other than the aforementioned exceptions; all other POST variables should follow PayPal standards. Please see: <a href="http://www.optimizepress.com/paypal-ipn-pdt-vars" target="_blank" rel="external">PayPal\'s IPN/PDT reference guide</a> for full documentation.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_ipn_after_proxy", get_defined_vars()); echo '</div>' . "\n"; echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_paypal_ipn", get_defined_vars()); } /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_paypal_pdt", true, get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_paypal_pdt", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="PayPal PDT/Auto-Return Integration">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-paypal-pdt-section">' . "\n"; echo '<h3>PayPal PDT Identity Token ( required, please enable )</h3>' . "\n"; echo '<p>Log into your PayPal account and navigate to this section:<br /><code>Account Profile -> Website Payment Preferences</code></p>' . "\n"; echo '<p>Turn the Auto-Return feature: <strong><code>On</code></strong></p>' . "\n"; echo '<p>You\'ll need your <a href="' . esc_attr(site_url("/?optimizemember_paypal_return=1&optimizemember_paypal_proxy=paypal&optimizemember_paypal_proxy_use=x-preview")) . '" target="_blank" rel="external">Auto-Return URL</a>, which is:<br /><code>' . esc_html(site_url("/?optimizemember_paypal_return=1")) . '</code></p>' . "\n"; echo '<p>You MUST also enable PDT ( Payment Data Transfer ): <strong><code>On</code></strong><br /><em>You\'ll be issued an Identity Token that you MUST enter below.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_pdt", get_defined_vars()); /**/ echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-paypal-identity-token">' . "\n"; echo 'PayPal PDT Identity Token:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="password" autocomplete="off" name="ws_plugin__optimizemember_paypal_identity_token" id="ws-plugin--optimizemember-paypal-identity-token" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_identity_token"]) . '" /><br />' . "\n"; echo 'Your PDT Identity Token will appear under <em>Profile -> Website Payment Preferences</em> in your PayPal account.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; /**/ echo '<div class="ws-menu-page-hr"></div>' . "\n"; /**/ echo '<h3>More Information ( <a href="#" onclick="jQuery(\'div#ws-plugin--optimizemember-paypal-pdt-details\').toggle(); return false;" class="ws-dotted-link">click here</a> )</h3>' . "\n"; echo '<div id="ws-plugin--optimizemember-paypal-pdt-details" style="display:none;">' . "\n"; echo '<p><em><strong>*Quick Tip*</strong> In addition to the <a href="http://www.optimizepress.com/paypal-pdt-setup" target="_blank" rel="external">default Auto-Return/PDT configuration inside your PayPal account</a>, the Auto-Return URL is also set on a per-transaction basis from within the special PayPal Button Code that optimizeMember provides you with. In other words, if you have multiple sites operating on one PayPal account, that\'s OK. optimizeMember dynamically sets the Auto-Return URL for each transaction. The result is that the Auto-Return URL configured from within your PayPal account, becomes the default, which is then overwritten on a per-transaction basis.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_pdt_after_quick_tip", get_defined_vars()); echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_paypal_pdt_after_more_info", get_defined_vars()); /**/ echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_paypal_pdt", get_defined_vars()); } /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_signup_confirmation_email", true, get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_signup_confirmation_email", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="Signup Confirmation Email ( Standard )">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-signup-confirmation-email-section">' . "\n"; echo '<h3>Signup Confirmation Email ( required, but the default works fine )</h3>' . "\n"; echo '<p>This email is sent to new Customers after they return from a successful signup at PayPal. The <strong>primary</strong> purpose of this email, is to provide the Customer with instructions, along with a link to register a Username for their Membership. You may also customize this further, by providing details that are specifically geared to your site.</p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_signup_confirmation_email", get_defined_vars()); /**/ echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-signup-email-recipients">' . "\n"; echo 'Signup Confirmation Recipients:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_signup_email_recipients" id="ws-plugin--optimizemember-signup-email-recipients" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["signup_email_recipients"]) . '" /><br />' . "\n"; echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n"; echo '<code>"%%full_name%%" <%%payer_email%%>; admin@example.com; "Webmaster" <webmaster@example.com></code>' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-signup-email-subject">' . "\n"; echo 'Signup Confirmation Email Subject:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_signup_email_subject" id="ws-plugin--optimizemember-signup-email-subject" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["signup_email_subject"]) . '" /><br />' . "\n"; echo 'Subject Line used in the email sent to a Customer after a successful signup has occurred through PayPal.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-signup-email-message">' . "\n"; echo 'Signup Confirmation Email Message:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<textarea name="ws_plugin__optimizemember_signup_email_message" id="ws-plugin--optimizemember-signup-email-message" rows="10">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["signup_email_message"]) . '</textarea><br />' . "\n"; echo 'Message Body used in the email sent to a Customer after a successful signup has occurred through PayPal.<br /><br />' . "\n"; echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n"; echo '<ul>' . "\n"; echo '<li><code>%%registration_url%%</code> = The full URL ( generated by optimizeMember ) where the Customer can get registered.</li>' . "\n"; echo '<li><code>%%subscr_id%%</code> = The PayPal Subscription ID, which remains constant throughout any & all future payments. [ <a href="#" onclick="alert(\'There is one exception. If you are selling Lifetime or Fixed-Term ( non-recurring ) access, using Buy Now functionality; the %%subscr_id%% is actually set to the Transaction ID for the purchase. PayPal does not provide a specific Subscription ID for Buy Now purchases. Since Lifetime & Fixed-Term Subscriptions are NOT recurring ( i.e. there is only ONE payment ), using the Transaction ID as the Subscription ID is a graceful way to deal with this minor conflict.\'); return false;">?</a> ]</li>' . "\n"; echo '<li><code>%%initial%%</code> = The Initial Fee charged during signup. If you offered a 100% Free Trial, this will be <code>0</code>. [ <a href="#" onclick="alert(\'This will always represent the amount of money the Customer spent, whenever they initially signed up, no matter what. If a Customer signs up, under the terms of a 100% Free Trial Period, this will be 0.\'); return false;">?</a> ]</li>' . "\n"; echo '<li><code>%%regular%%</code> = The Regular Amount of the Subscription. This value is <code>always > 0</code>, no matter what. [ <a href="#" onclick="alert(\'This is how much the Subscription costs after an Initial Period expires. The %%regular%% rate is always > 0. If you did NOT offer an Initial Period at a different price, %%initial%% and %%regular%% will be equal to the same thing.\'); return false;">?</a> ]</li>' . "\n"; echo '<li><code>%%recurring%%</code> = This is the amount that will be charged on a recurring basis, or <code>0</code> if non-recurring. [ <a href="#" onclick="alert(\'If Recurring Payments have not been required, this will be equal to 0. That being said, %%regular%% & %%recurring%% are usually the same value. This variable can be used in two different ways. You can use it to determine what the Regular Recurring Rate is, or to determine whether the Subscription will recur or not. If it is going to recur, %%recurring%% will be > 0.\'); return false;">?</a> ]</li>' . "\n"; echo '<li><code>%%first_name%%</code> = The First Name of the Customer who purchased the Membership Subscription.</li>' . "\n"; echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who purchased the Membership Subscription.</li>' . "\n"; echo '<li><code>%%full_name%%</code> = The Full Name ( First & Last ) of the Customer who purchased the Membership Subscription.</li>' . "\n"; echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who purchased the Membership Subscription.</li>' . "\n"; echo '<li><code>%%user_ip%%</code> = The Customer\'s IP Address, detected during checkout via <code>$_SERVER["REMOTE_ADDR"]</code>.</li>' . "\n"; echo '<li><code>%%item_number%%</code> = The Item Number ( colon separated <code><em>level:custom_capabilities:fixed term</em></code> ) that the Subscription is for.</li>' . "\n"; echo '<li><code>%%item_name%%</code> = The Item Name ( as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number ).</li>' . "\n"; echo '<li><code>%%initial_term%%</code> = This is the term length of the Initial Period. This will be a numeric value, followed by a space, then a single letter. [ <a href="#" onclick="alert(\'Here are some examples:\\n\\n%%initial_term%% = 1 D ( this means 1 Day )\\n%%initial_term%% = 1 W ( this means 1 Week )\\n%%initial_term%% = 1 M ( this means 1 Month )\\n%%initial_term%% = 1 Y ( this means 1 Year )\\n\\nThe Initial Period never recurs, so this only lasts for the term length specified, then it is over.\'); return false;">?</a> ]</li>' . "\n"; echo '<li><code>%%initial_cycle%%</code> = This is the <code>%%initial_term%%</code> from above, converted to a cycle representation of: <code><em>X days/weeks/months/years</em></code>.</li>' . "\n"; echo '<li><code>%%regular_term%%</code> = This is the term length of the Regular Period. This will be a numeric value, followed by a space, then a single letter. [ <a href="#" onclick="alert(\'Here are some examples:\\n\\n%%regular_term%% = 1 D ( this means 1 Day )\\n%%regular_term%% = 1 W ( this means 1 Week )\\n%%regular_term%% = 1 M ( this means 1 Month )\\n%%regular_term%% = 1 Y ( this means 1 Year )\\n%%regular_term%% = 1 L ( this means 1 Lifetime )\\n\\nThe Regular Term is usually recurring. So the Regular Term value represents the period ( or duration ) of each recurring period. If %%recurring%% = 0, then the Regular Term only applies once, because it is not recurring. So if it is not recurring, the value of %%regular_term%% simply represents how long their Membership privileges are going to last after the %%initial_term%% has expired, if there was an Initial Term. The value of this variable ( %%regular_term%% ) will never be empty, it will always be at least: 1 D, meaning 1 day. No exceptions.\'); return false;">?</a> ]</li>' . "\n"; echo '<li><code>%%regular_cycle%%</code> = This is the <code>%%regular_term%%</code> from above, converted to a cycle representation of: <code><em>[every] X days/weeks/months/years — OR daily, weekly, bi-weekly, monthly, bi-monthly, quarterly, yearly, or lifetime</em></code>. This is a very useful Replacment Code. Its value is dynamic; depending on term length, recurring status, and period/term lengths configured.</li>' . "\n"; echo '<li><code>%%recurring/regular_cycle%%</code> = Example ( <code>14.95 / Monthly</code> ), or ... ( <code>0 / non-recurring</code> ); depending on the value of <code>%%recurring%%</code>.</li>' . "\n"; echo '</ul>' . "\n"; /**/ echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n"; echo '<ul>' . "\n"; echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n"; echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute; inside your Shortcode, like this: <code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables. Obviously, this is for advanced webmasters; but the functionality has been made available for those who need it.</li>' . "\n"; echo '</ul>' . "\n"; echo '<strong>This example uses cv1 to record a special marketing campaign:</strong><br />' . "\n"; echo '<em>( The campaign ( i.e. christmas-promo ) could be referenced using <code>%%cv1%%</code> )</em><br />' . "\n"; echo '<code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|christmas-promo"</code>' . "\n"; /**/ echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_signup_confirmation_email", get_defined_vars()); } /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_sp_confirmation_email", true, get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_sp_confirmation_email", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="Specific Post/Page Confirmation Email ( Standard )">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-sp-confirmation-email-section">' . "\n"; echo '<h3>Specific Post/Page Confirmation Email ( required, but the default works fine )</h3>' . "\n"; echo '<p>This email is sent to new Customers after they return from a successful purchase at PayPal, for Specific Post/Page Access. ( see: <code>optimizeMember -> Restriction Options -> Specific Post/Page Access</code> ). This is NOT used for Membership sales, only for Specific Post/Page Access. The <strong>primary</strong> purpose of this email, is to provide the Customer with instructions, along with a link to access the Specific Post/Page they\'ve purchased access to. If you\'ve created a Specific Post/Page Package ( with multiple Posts/Pages bundled together into one transaction ), this ONE link ( <code>%%sp_access_url%%</code> ) will automatically authenticate them for access to ALL of the Posts/Pages included in their transaction. You may customize this email further, by providing details that are specifically geared to your site.</p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_sp_confirmation_email", get_defined_vars()); /**/ echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-sp-email-recipients">' . "\n"; echo 'Specific Post/Page Confirmation Recipients:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_sp_email_recipients" id="ws-plugin--optimizemember-sp-email-recipients" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["sp_email_recipients"]) . '" /><br />' . "\n"; echo 'This is a semicolon ( ; ) delimited list of Recipients. Here is an example:<br />' . "\n"; echo '<code>"%%full_name%%" <%%payer_email%%>; admin@example.com; "Webmaster" <webmaster@example.com></code>' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-sp-email-subject">' . "\n"; echo 'Specific Post/Page Confirmation Email Subject:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<input type="text" autocomplete="off" name="ws_plugin__optimizemember_sp_email_subject" id="ws-plugin--optimizemember-sp-email-subject" value="' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["sp_email_subject"]) . '" /><br />' . "\n"; echo 'Subject Line used in the email sent to a Customer after a successful purchase has occurred through PayPal, for Specific Post/Page Access.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-sp-email-message">' . "\n"; echo 'Specific Post/Page Confirmation Email Message:' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<textarea name="ws_plugin__optimizemember_sp_email_message" id="ws-plugin--optimizemember-sp-email-message" rows="10">' . format_to_edit($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["sp_email_message"]) . '</textarea><br />' . "\n"; echo 'Message Body used in the email sent to a Customer after a successful purchase has occurred through PayPal, for Specific Post/Page Access.<br /><br />' . "\n"; echo '<strong>You can also use these special Replacement Codes if you need them:</strong>' . "\n"; echo '<ul>' . "\n"; echo '<li><code>%%sp_access_url%%</code> = The full URL ( generated by optimizeMember ) where the Customer can gain access.</li>' . "\n"; echo '<li><code>%%sp_access_exp%%</code> = Human readable expiration for <code>%%sp_access_url%%</code>. Ex: <em>( link expires in <code>%%sp_access_exp%%</code> )</em>.</li>' . "\n"; echo '<li><code>%%txn_id%%</code> = The PayPal Transaction ID. PayPal assigns a unique identifier for every purchase.</li>' . "\n"; echo '<li><code>%%amount%%</code> = The full Amount that you charged for Specific Post/Page Access. This value will <code>always be > 0</code>.</li>' . "\n"; echo '<li><code>%%first_name%%</code> = The First Name of the Customer who purchased Specific Post/Page Access.</li>' . "\n"; echo '<li><code>%%last_name%%</code> = The Last Name of the Customer who purchased Specific Post/Page Access.</li>' . "\n"; echo '<li><code>%%full_name%%</code> = The Full Name ( First & Last ) of the Customer who purchased Specific Post/Page Access.</li>' . "\n"; echo '<li><code>%%payer_email%%</code> = The Email Address of the Customer who purchased Specific Post/Page Access.</li>' . "\n"; echo '<li><code>%%user_ip%%</code> = The Customer\'s IP Address, detected during checkout via <code>$_SERVER["REMOTE_ADDR"]</code>.</li>' . "\n"; echo '<li><code>%%item_number%%</code> = The Item Number. Ex: <code><em>sp:13,24,36:72</em></code> ( translates to: <code><em>sp:comma-delimited IDs:expiration hours</em></code> ).</li>' . "\n"; echo '<li><code>%%item_name%%</code> = The Item Name ( as provided by the <code>desc=""</code> attribute in your Shortcode, which briefly describes the Item Number ).</li>' . "\n"; echo '</ul>' . "\n"; /**/ echo '<strong>Custom Replacement Codes can also be inserted using these instructions:</strong>' . "\n"; echo '<ul>' . "\n"; echo '<li><code>%%cv0%%</code> = The domain of your site, which is passed through the `custom` attribute in your Shortcode.</li>' . "\n"; echo '<li><code>%%cv1%%</code> = If you need to track additional custom variables, you can pipe delimit them into the `custom` attribute; inside your Shortcode, like this: <code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|cv1|cv2|cv3"</code>. You can have an unlimited number of custom variables. Obviously, this is for advanced webmasters; but the functionality has been made available for those who need it.</li>' . "\n"; echo '</ul>' . "\n"; echo '<strong>This example uses cv1 to record a special marketing campaign:</strong><br />' . "\n"; echo '<em>( The campaign ( i.e. christmas-promo ) could be referenced using <code>%%cv1%%</code> )</em><br />' . "\n"; echo '<code>custom="' . esc_html($_SERVER["HTTP_HOST"]) . '|christmas-promo"</code>' . "\n"; /**/ echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_sp_confirmation_email", get_defined_vars()); } /**/ if (apply_filters("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_display_eot_behavior", true, get_defined_vars())) { do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_before_eot_behavior", get_defined_vars()); /**/ echo '<div class="ws-menu-page-group" title="Automatic EOT Behavior">' . "\n"; /**/ echo '<div class="ws-menu-page-section ws-plugin--optimizemember-eot-behavior-section">' . "\n"; echo '<h3>PayPal EOT Behavior ( required, please choose )</h3>' . "\n"; echo '<p>EOT = End Of Term. By default, optimizeMember will demote a paid Member to a Free Subscriber whenever their Subscription term has ended ( i.e. expired ), been cancelled, refunded, charged back to you, etc. optimizeMember demotes them to a Free Subscriber, so they will no longer have Member Level Access to your site. However, in some cases, you may prefer to have Customer accounts deleted completely, instead of just being demoted. This is where you choose which method works best for your site. If you don\'t want optimizeMember to take ANY action at all, you can disable optimizeMember\'s EOT System temporarily, or even completely.</p>' . "\n"; echo '<p>The PayPal IPN service will notify optimizeMember whenever a Member\'s payments have been failing, and/or whenever a Member\'s Subscription has expired for any reason. Even refunds & chargeback reversals are supported through the IPN service. For example, if you issue a refund to an unhappy Customer through PayPal, optimizeMember will eventually be notified, and the account for that Customer will either be demoted to a Free Subscriber, or deleted automatically ( based on your configuration ). The communication from PayPal -> optimizeMember is seamless.</p>' . "\n"; echo '<p><em><strong>*Some Hairy Details*</strong> There might be times whenever you notice that a Member\'s Subscription has been cancelled through PayPal... but, optimizeMember continues allowing the User access to your site as a paid Member. Please don\'t be confused by this... in 99.9% of these cases, the reason for this is legitimate. optimizeMember will only remove the User\'s Membership privileges when an EOT ( End Of Term ) is processed, a refund occurs, a chargeback occurs, or when a cancellation occurs - which would later result in a delayed Auto-EOT by optimizeMember.</em></p>' . "\n"; echo '<p><em>optimizeMember will not process an EOT until the User has completely used up the time they paid for. In other words, if a User signs up for a monthly Subscription on Jan 1st, and then cancels their Subscription on Jan 15th; technically, they should still be allowed to access the site for another 15 days, and then on Feb 1st, the time they paid for has completely elapsed. At that time, optimizeMember will remove their Membership privileges; by either demoting them to a Free Subscriber, or deleting their account from the system ( based on your configuration ). optimizeMember also calculates one extra day ( 24 hours ) into its equation, just to make sure access is not removed sooner than a Customer might expect.</em></p>' . "\n"; do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_during_eot_behavior", get_defined_vars()); /**/ echo '<p id="ws-plugin--optimizemember-auto-eot-system-enabled-via-cron"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] == 2 && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule")) ? '' : ' style="display:none;"') . '>If you\'d like to run optimizeMember\'s Auto-EOT System through a more traditional Cron Job; instead of through <code>WP-Cron</code>, you will need to configure a Cron Job through your server control panel; provided by your hosting company. Set the Cron Job to run <code>once about every 10 minutes to an hour</code>. You\'ll want to configure an HTTP Cron Job that loads this URL:<br /><code>' . esc_html(site_url("/?optimizemember_auto_eot_system_via_cron=1")) . '</code></p>' . "\n"; /**/ echo '<table class="form-table">' . "\n"; echo '<tbody>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-auto-eot-system-enabled">' . "\n"; echo 'Enable optimizeMember\'s Auto-EOT System?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<select name="ws_plugin__optimizemember_auto_eot_system_enabled" id="ws-plugin--optimizemember-auto-eot-system-enabled">' . "\n"; /* Very advanced conditionals here. If the Auto-EOT System is NOT running, or NOT fully configured, this will indicate that no option is set - as sort of a built-in acknowledgment/warning in the UI panel. */ echo $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] == 1 && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule")) || $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] == 2 && (function_exists("wp_cron") && wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule")) || !$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] && (function_exists("wp_cron") && wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule")) ? '<option value=""></option>' . "\n" : ''; echo '<option value="1"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] == 1 && function_exists("wp_cron") && wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule") ? ' selected="selected"' : '') . '>Yes ( enable the Auto-EOT System through WP-Cron )</option>' . "\n"; echo !is_multisite() || !c_ws_plugin__optimizemember_utils_conds::is_multisite_farm() || is_main_site() ? '<option value="2"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] == 2 && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule")) ? ' selected="selected"' : '') . '>Yes ( but, I\'ll run it with my own Cron Job )</option>' . "\n" : ''; echo '<option value="0"' . (!$GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["auto_eot_system_enabled"] && (!function_exists("wp_cron") || !wp_get_schedule("ws_plugin__optimizemember_auto_eot_system__schedule")) ? ' selected="selected"' : '') . '>No ( disable the Auto-EOT System )</option>' . "\n"; echo '</select><br />' . "\n"; echo 'Recommended setting: ( <code>Yes / enable via WP-Cron</code> )' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-membership-eot-behavior">' . "\n"; echo 'Membership EOT Behavior ( demote or delete )?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<select name="ws_plugin__optimizemember_membership_eot_behavior" id="ws-plugin--optimizemember-membership-eot-behavior">' . "\n"; echo '<option value="demote"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_eot_behavior"] === "demote" ? ' selected="selected"' : '') . '>Demote ( convert them to a Free Subscriber )</option>' . "\n"; echo '<option value="delete"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["membership_eot_behavior"] === "delete" ? ' selected="selected"' : '') . '>Delete ( erase their account completely )</option>' . "\n"; echo '</select>' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-triggers-immediate-eot">' . "\n"; echo 'Refunds/Reversals ( trigger immediate EOT )?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<select name="ws_plugin__optimizemember_triggers_immediate_eot" id="ws-plugin--optimizemember-triggers-immediate-eot">' . "\n"; echo '<option value="none"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["triggers_immediate_eot"] === "none" ? ' selected="selected"' : '') . '>Neither ( I\'ll review these two events manually )</option>' . "\n"; echo '<option value="refunds"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["triggers_immediate_eot"] === "refunds" ? ' selected="selected"' : '') . '>Refunds ( refunds ALWAYS trigger an immediate EOT action )</option>' . "\n"; echo '<option value="reversals"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["triggers_immediate_eot"] === "reversals" ? ' selected="selected"' : '') . '>Reversals ( chargebacks ALWAYS trigger an immediate EOT action )</option>' . "\n"; echo '<option value="refunds,reversals"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["triggers_immediate_eot"] === "refunds,reversals" ? ' selected="selected"' : '') . '>Refunds/Reversals ( ALWAYS trigger an immediate EOT action )</option>' . "\n"; echo '</select><br />' . "\n"; echo 'This setting will <a href="#" onclick="alert(\'A Refund/Reversal Notification will ALWAYS be processed internally by optimizeMember, even if no action is taken by optimizeMember. This way you\\\'ll have the full ability to listen for these two events on your own; if you prefer ( optional ). For more information, check your Dashboard under: `optimizeMember -> API Notifications -> Refunds/Reversals`.\'); return false;">NOT affect</a> optimizeMember\'s internal API Notifications for Refund/Reversal events.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<th>' . "\n"; echo '<label for="ws-plugin--optimizemember-eot-time-ext-behavior">' . "\n"; echo 'Fixed-Term Extensions ( auto-extend )?' . "\n"; echo '</label>' . "\n"; echo '</th>' . "\n"; /**/ echo '</tr>' . "\n"; echo '<tr>' . "\n"; /**/ echo '<td>' . "\n"; echo '<select name="ws_plugin__optimizemember_eot_time_ext_behavior" id="ws-plugin--optimizemember-eot-time-ext-behavior">' . "\n"; echo '<option value="extend"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["eot_time_ext_behavior"] === "extend" ? ' selected="selected"' : '') . '>Yes ( default, automatically extend any existing EOT Time )</option>' . "\n"; echo '<option value="reset"' . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["eot_time_ext_behavior"] === "reset" ? ' selected="selected"' : '') . '>No ( do NOT extend; optimizeMember should reset EOT Time completely )</option>' . "\n"; echo '</select><br />' . "\n"; echo 'This setting will only affect Buy Now transactions for fixed-term lengths. By default, optimizeMember will automatically extend any existing EOT Time that a Customer may have.' . "\n"; echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; echo '</div>' . "\n"; /**/ echo '</div>' . "\n"; /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_during_left_sections_after_eot_behavior", get_defined_vars()); } /**/ do_action("ws_plugin__optimizemember_during_paypal_ops_page_after_left_sections", get_defined_vars()); /**/ //echo '<div class="ws-menu-page-hr"></div>'."\n"; /**/ echo '<p class="submit"><input type="submit" class="op-pb-button green" value="Save All Changes" /></p>' . "\n"; /**/ echo '</form>' . "\n"; /**/ echo '</td>' . "\n"; /**/ echo '<td class="ws-menu-page-table-r">' . "\n"; c_ws_plugin__optimizemember_menu_pages_rs::display(); echo '</td>' . "\n"; /**/ echo '</tr>' . "\n"; echo '</tbody>' . "\n"; echo '</table>' . "\n"; /**/ echo '</div>' . "\n"; echo '</div>' . "\n"; }
/** * Handles ccBill IPN URL processing. * * @package optimizeMember\ccBill * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after handling the Notification. */ public static function ccbill_notify() { global $current_site, $current_blog; /* For Multisite support. */ /**/ if (isset($_GET["optimizemember_pro_ccbill_notify"]) && strlen($_GET["optimizemember_pro_ccbill_notify"]) && $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_client_id"]) { @ignore_user_abort(true); /* Continue processing even if/when connection is broken by the sender. */ /**/ if (is_array($ccbill = c_ws_plugin__optimizemember_pro_ccbill_utilities::ccbill_postvars()) && ($_ccbill = $ccbill)) { $ccbill["optimizemember_log"][] = "IPN received on: " . date("D M j, Y g:i:s a T"); $ccbill["optimizemember_log"][] = "optimizeMember POST vars verified with ccBill."; /**/ if (!$ccbill["denialId"] && $ccbill["subscription_id"] && !$ccbill["recurringPeriod"]) { $ccbill["optimizemember_log"][] = "ccBill transaction identified as ( `NON-RECURRING/BUY-NOW` )."; $ccbill["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `web_accept` )."; $ccbill["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "web_accept"; /**/ $ipn["txn_id"] = $ccbill["subscription_id"]; /**/ $ipn["custom"] = $ccbill["s2_custom"]; /**/ $ipn["mc_gross"] = number_format($ccbill["initialPrice"], 2, ".", ""); $ipn["mc_currency"] = c_ws_plugin__optimizemember_pro_ccbill_utilities::ccbill_currency_code($ccbill["currencyCode"]); $ipn["tax"] = number_format("0.00", 2, ".", ""); /**/ $ipn["payer_email"] = $ccbill["email"]; $ipn["first_name"] = $ccbill["customer_fname"]; $ipn["last_name"] = $ccbill["customer_lname"]; /**/ $ipn["option_name1"] = $ccbill["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $ccbill["s2_referencing"] ? $ccbill["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $ccbill["s2_customer_ip"]; /**/ $ipn["item_number"] = $ccbill["s2_invoice"]; $ipn["item_name"] = $ccbill["s2_desc"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=ccbill&optimizemember_paypal_proxy_use=standard-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)); } else { if (!$ccbill["denialId"] && $ccbill["subscription_id"] && $ccbill["recurringPeriod"]) { $ccbill["optimizemember_log"][] = "ccBill transaction identified as ( `RECURRING/SUBSCRIPTION` )."; $ccbill["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as `txn_type` ( `subscr_signup` )."; $ccbill["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /* Reset. */ /**/ $ipn["txn_type"] = "subscr_signup"; $ipn["subscr_id"] = $ccbill["subscription_id"]; $ipn["recurring"] = "1"; /* Yes, recurring. */ /**/ $ipn["txn_id"] = $ccbill["subscription_id"]; /**/ $ipn["custom"] = $ccbill["s2_custom"]; /**/ $ipn["period1"] = $ccbill["s2_p1"]; $ipn["period3"] = $ccbill["s2_p3"]; /**/ $ipn["mc_amount1"] = number_format($ccbill["initialPrice"], 2, ".", ""); $ipn["mc_amount3"] = number_format($ccbill["recurringPrice"], 2, ".", ""); /**/ $ipn["mc_gross"] = preg_match("/^[1-9]/", $ipn["period1"]) ? $ipn["mc_amount1"] : $ipn["mc_amount3"]; /**/ $ipn["mc_currency"] = c_ws_plugin__optimizemember_pro_ccbill_utilities::ccbill_currency_code($ccbill["currencyCode"]); $ipn["tax"] = number_format("0.00", 2, ".", ""); /**/ $ipn["payer_email"] = $ccbill["email"]; $ipn["first_name"] = $ccbill["customer_fname"]; $ipn["last_name"] = $ccbill["customer_lname"]; /**/ $ipn["option_name1"] = $ccbill["s2_referencing"] ? "Referencing Customer ID" : "Originating Domain"; $ipn["option_selection1"] = $ccbill["s2_referencing"] ? $ccbill["s2_referencing"] : $_SERVER["HTTP_HOST"]; /**/ $ipn["option_name2"] = "Customer IP Address"; $ipn["option_selection2"] = $ccbill["s2_customer_ip"]; /**/ $ipn["item_number"] = $ccbill["s2_invoice"]; $ipn["item_name"] = $ccbill["s2_desc"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=ccbill&optimizemember_paypal_proxy_use=standard-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()); /**/ c_ws_plugin__optimizemember_utils_urls::remote(site_url("/?optimizemember_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20)); } else { if (!$processed) { /* If nothing was processed, here we add a message to the logs indicating the IPN was ignored. */ $ccbill["optimizemember_log"][] = "Ignoring this IPN request. The transaction does NOT require any action on the part of optimizeMember."; } } } } else { $ccbill["optimizemember_log"][] = "Unable to verify POST vars. This is most likely related to an invalid ccBill configuration. Please check: optimizeMember -> ccBill Options."; $ccbill["optimizemember_log"][] = "If you're absolutely SURE that your ccBill configuration is valid, you may want to run some tests on your server, just to be sure \$_POST variables are populated, and that your server is able to connect to ccBill over an HTTPS connection."; $ccbill["optimizemember_log"][] = "optimizeMember uses the WP_Http class for remote connections; which will try to use cURL first, and then fall back on the FOPEN method when cURL is not available. On a Windows server, you may have to disable your cURL extension. Instead, set allow_url_fopen = yes in your php.ini file. The cURL extension (usually) does NOT support SSL connections on a Windows server."; $ccbill["optimizemember_log"][] = var_export($_REQUEST, true); /* Recording _POST + _GET vars for analysis and debugging. */ } /* If debugging/logging is enabled; we need to append $ccbill to the log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "ccbill-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "ccbill-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($ccbill, true) . "\n\n", FILE_APPEND); } } } /**/ 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. */ /**/ exit; /* Exit now. */ } }
/** * 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 />— 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 />— 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 />— 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 />— 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 />— 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 />— 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; } } } }
/** * Connect to and process DataLink information for ccBill. * * optimizeMember's Auto EOT System must be enabled for this to work properly. * * If you have a HUGE userbase, increase the max IPNs per process. * But NOTE, this runs ``$per_process`` *( per Blog )* on a Multisite Network. * To increase, use: ``add_filter ("ws_plugin__optimizemember_pro_ccbill_datalink_ipns_per_process");``. * * @package optimizeMember\ccBill * @since 1.5 * * @attaches-to ``add_action("ws_plugin__optimizemember_after_auto_eot_system");`` * * @param array $vars Expects an array of defined variables passed in by the Action Hook. * @return null */ public static function ccbill_datalink($vars = FALSE) { global $wpdb; global $current_site, $current_blog; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_client_id"]) { $mst_time_10m_ago = time() - 6 * 3600 - 600; $datalink = "https://datalink.ccbill.com/data/main.cgi"; /**/ if (!($last = get_transient("s2m_" . md5("optimizemember_pro_ccbill_last_datalink"))) || $last < $mst_time_10m_ago - 86400) { $start = $last && $last >= $mst_time_10m_ago - (86400 + 43200) ? $last : $mst_time_10m_ago - 86400; $end = $last = $start + 86400 <= $mst_time_10m_ago ? $start + 86400 : $mst_time_10m_ago; /**/ $dl_types = "REBILL" . ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_dl_cancellations"] || apply_filters("ws_plugin__optimizemember_pro_ccbill_datalink_pulls_cancellations", false) ? ",CANCELLATION" : "") . ",EXPIRE,REFUND,CHARGEBACK"; $qvrs = array("startTime" => date("YmdHis", $start), "endTime" => date("YmdHis", $end), "transactionTypes" => $dl_types, "clientAccnum" => $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_client_id"], "clientSubacc" => $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_client_sid"], "username" => $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_dl_user"], "password" => $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["pro_ccbill_dl_pass"]); /**/ if (($unprocessed_ipn_lines = trim(c_ws_plugin__optimizemember_utils_urls::remote($datalink = add_query_arg(urlencode_deep($qvrs), $datalink)))) && !preg_match("/^Error\\:/i", $unprocessed_ipn_lines)) { $ccbill["optimizemember_log"][] = "Storing last DataLink time: " . date("D M j, Y g:i:s a T", $last); /**/ set_transient("s2m_" . md5("optimizemember_pro_ccbill_last_datalink"), $last, 31556926); /**/ $ccbill["optimizemember_log"][] = "Storing new DataLink IPNs into a Transient Queue."; $ccbill["optimizemember_log"][] = $datalink; $ccbill["optimizemember_log"][] = $unprocessed_ipn_lines; /**/ set_transient("s2m_" . md5("optimizemember_pro_ccbill_datalink_ipns"), trim(trim(get_transient("s2m_" . md5("optimizemember_pro_ccbill_datalink_ipns"))) . "\n" . $unprocessed_ipn_lines), 31556926); } else { if (!preg_match("/^Error\\:/i", $unprocessed_ipn_lines)) { $ccbill["optimizemember_log"][] = "Storing last DataLink time: " . date("D M j, Y g:i:s a T", $last); /**/ set_transient("s2m_" . md5("optimizemember_pro_ccbill_last_datalink"), $last, 31556926); /**/ $ccbill["optimizemember_log"][] = "No new Datalink IPNs at this time: " . date("D M j, Y g:i:s a T"); $ccbill["optimizemember_log"][] = $datalink; $ccbill["optimizemember_log"][] = $unprocessed_ipn_lines; } else { $ccbill["optimizemember_log"][] = "Storing last DataLink time: " . date("D M j, Y g:i:s a T", $last); /**/ set_transient("s2m_" . md5("optimizemember_pro_ccbill_last_datalink"), $last, 31556926); /**/ $ccbill["optimizemember_log"][] = "Recording DataLink error at: " . date("D M j, Y g:i:s a T"); $ccbill["optimizemember_log"][] = "Recording server IP address: " . $_SERVER["SERVER_ADDR"]; $ccbill["optimizemember_log"][] = $datalink; $ccbill["optimizemember_log"][] = $unprocessed_ipn_lines; } } /**/ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "ccbill-dl-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "ccbill-dl.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($ccbill, true) . "\n\n", FILE_APPEND); } } } } else { if ($unprocessed_ipn_lines = trim(get_transient("s2m_" . md5("optimizemember_pro_ccbill_datalink_ipns")))) { $per_process = apply_filters("ws_plugin__optimizemember_pro_ccbill_datalink_ipns_per_process", $vars["per_process"], get_defined_vars()); /**/ foreach ($unprocessed_lines = preg_split("/[\r\n]+/", $unprocessed_ipn_lines) as $line => $unprocessed_line) { unset($ccbill, $processing, $processed, $ipn, $ipn_q, $log4, $_log4, $log2, $logs_dir); /**/ if (($unprocessed_line = trim($unprocessed_line)) && ($counter = (int) $counter + 1)) { $ccbill["optimizemember_log"][] = "DataLink IPN processed on: " . date("D M j, Y g:i:s a T"); /**/ $ccbill["dl_ipn"] = c_ws_plugin__optimizemember_utils_strings::trim_dq_deep(preg_split("/\",\"/", $unprocessed_line)); /**/ if (is_array($ccbill["dl_ipn_signup_vars"] = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars(false, $ccbill["dl_ipn"][3]))) { if (preg_match("/^REBILL\$/i", $ccbill["dl_ipn"][0])) { $ccbill["optimizemember_log"][] = "ccBill transaction identified as (SUBSCRIPTION PAYMENT)."; $ccbill["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as txn_type (subscr_payment)."; $ccbill["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /**/ $ipn["txn_type"] = "subscr_payment"; $ipn["subscr_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"]; /**/ $ipn["txn_id"] = $ccbill["dl_ipn"][5]; /**/ $ipn["mc_gross"] = number_format($ccbill["dl_ipn"][6], 2, ".", ""); $ipn["mc_currency"] = strtoupper("USD"); $ipn["tax"] = number_format("0.00", 2, ".", ""); /**/ $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=ccbill&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^CANCELLATION\$/i", $ccbill["dl_ipn"][0])) { $ccbill["optimizemember_log"][] = "ccBill transaction identified as (SUBSCRIPTION CANCELLATION)."; $ccbill["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as txn_type (subscr_cancel)."; $ccbill["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /**/ $ipn["txn_type"] = "subscr_cancel"; $ipn["subscr_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"]; /**/ $ipn["period1"] = $ccbill["dl_ipn_signup_vars"]["period1"]; $ipn["period3"] = $ccbill["dl_ipn_signup_vars"]["period3"]; /**/ $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=ccbill&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^EXPIRE\$/i", $ccbill["dl_ipn"][0])) { $ccbill["optimizemember_log"][] = "ccBill transaction identified as (SUBSCRIPTION EXPIRATION)."; $ccbill["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as txn_type (subscr_eot)."; $ccbill["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /**/ $ipn["txn_type"] = "subscr_eot"; $ipn["subscr_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"]; /**/ $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"]; /**/ $ipn["period1"] = $ccbill["dl_ipn_signup_vars"]["period1"]; $ipn["period3"] = $ccbill["dl_ipn_signup_vars"]["period3"]; /**/ $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=ccbill&optimizemember_paypal_proxy_use=standard-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)); } else { if (preg_match("/^(REFUND|CHARGEBACK)\$/i", $ccbill["dl_ipn"][0])) { $ccbill["optimizemember_log"][] = "ccBill transaction identified as (REFUND|CHARGEBACK)."; $ccbill["optimizemember_log"][] = "IPN reformulated. Piping through optimizeMember's core/standard PayPal processor as payment_status (refunded|reversed)."; $ccbill["optimizemember_log"][] = "Please check PayPal IPN logs for further processing details."; /**/ $processing = $processed = true; $ipn = array(); /**/ $ipn["custom"] = $ccbill["dl_ipn_signup_vars"]["custom"]; /**/ $ipn["parent_txn_id"] = $ccbill["dl_ipn_signup_vars"]["subscr_id"]; /**/ $ipn["payment_status"] = preg_match("/^CHARGEBACK\$/i", $ccbill["dl_ipn"][0]) ? "reversed" : "refunded"; $ipn["mc_fee"] = "-" . number_format("0.00", 2, ".", ""); $ipn["mc_gross"] = "-" . number_format($ccbill["dl_ipn"][5], 2, ".", ""); $ipn["mc_currency"] = strtoupper("USD"); $ipn["tax"] = "-" . number_format("0.00", 2, ".", ""); /**/ $ipn["payer_email"] = $ccbill["dl_ipn_signup_vars"]["payer_email"]; $ipn["first_name"] = $ccbill["dl_ipn_signup_vars"]["first_name"]; $ipn["last_name"] = $ccbill["dl_ipn_signup_vars"]["last_name"]; /**/ $ipn["option_name1"] = $ccbill["dl_ipn_signup_vars"]["option_name1"]; $ipn["option_selection1"] = $ccbill["dl_ipn_signup_vars"]["option_selection1"]; /**/ $ipn["option_name2"] = $ccbill["dl_ipn_signup_vars"]["option_name2"]; $ipn["option_selection2"] = $ccbill["dl_ipn_signup_vars"]["option_selection2"]; /**/ $ipn["item_number"] = $ccbill["dl_ipn_signup_vars"]["item_number"]; $ipn["item_name"] = $ccbill["dl_ipn_signup_vars"]["item_name"]; /**/ $ipn_q = "&optimizemember_paypal_proxy=ccbill&optimizemember_paypal_proxy_use=standard-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)); } else { if (!$processed) { /* Here we add a message to the logs indicating the IPN was ignored; no action taken. */ $ccbill["optimizemember_log"][] = "Ignoring this DataLink IPN. It does NOT require any action on the part of optimizeMember."; } } } } } } else { if (!$processed) { /* Here we add a message to the logs indicating that no IPN vars are available. */ $ccbill["optimizemember_log"][] = "Ignoring this DataLink IPN. No IPN signup vars for Subscr. ID: " . $ccbill["dl_ipn"][3] . "."; } } /**/ $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"]; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? "ccbill-dl-ipn-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "ccbill-dl-ipn.log"; /**/ if ($GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["gateway_debug_logs"]) { if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["c"]["logs_dir"])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . "/" . $log2, $logv . "\n" . $logm . "\n" . $log4 . "\n" . var_export($ccbill, true) . "\n\n", FILE_APPEND); } } } } /**/ unset($unprocessed_lines[$line]); /* Remove this line and update the list of unprocessed IPN lines. */ set_transient("s2m_" . md5("optimizemember_pro_ccbill_datalink_ipns"), implode("\n", $unprocessed_lines), 31556926); /**/ if ($counter >= $per_process) { break; } /* Break the loop now. */ } } } } /**/ return; /* Return for uniformity. */ }
/** * Handles Stripe Webhook/IPN event processing. * * @package optimizeMember\Stripe * @since 140617 * * @attaches-to ``add_action('init');`` */ public static function stripe_notify() { global $current_site, $current_blog; if (!empty($_GET['optimizemember_pro_stripe_notify']) && $GLOBALS['WS_PLUGIN__']['optimizemember']['o']['pro_stripe_api_secret_key']) { $stripe = array(); // Initialize array of Webhook/IPN event data and s2Member log details. @ignore_user_abort(TRUE); // Continue processing even if/when connection is broken. require_once dirname(__FILE__) . '/stripe-sdk/lib/Stripe.php'; Stripe::setApiKey($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['pro_stripe_api_secret_key']); if (is_object($event = c_ws_plugin__optimizemember_pro_stripe_utilities::get_event()) && ($stripe['event'] = $event)) { switch ($event->type) { case 'invoice.payment_succeeded': // Subscription payments. if (!empty($event->data->object) && ($stripe_invoice = $event->data->object) instanceof Stripe_Invoice && !empty($stripe_invoice->customer) && !empty($stripe_invoice->subscription) && ($stripe_invoice_total = number_format(c_ws_plugin__optimizemember_pro_stripe_utilities::cents_to_dollar_amount($stripe_invoice->total, $stripe_invoice->currency), 2, '.', '')) && is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer_subscription($stripe_invoice->customer, $stripe_invoice->subscription)) && ($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars(0, $stripe_subscription->id))) { $processing = TRUE; $ipn['txn_type'] = 'subscr_payment'; $ipn['txn_id'] = $stripe_invoice->id; $ipn['txn_cid'] = $ipn_signup_vars['subscr_cid']; $ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid']; $ipn['subscr_id'] = $ipn_signup_vars['subscr_id']; $ipn['custom'] = $ipn_signup_vars['custom']; $ipn['mc_gross'] = $stripe_invoice_total; $ipn['mc_currency'] = strtoupper($stripe_invoice->currency); $ipn['tax'] = number_format(0, 2, '.', ''); $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)); $stripe['optimizemember_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T'); if ($maybe_end_subscription = self::_maybe_end_subscription_after_payment($stripe_invoice->customer, $stripe_subscription)) { $stripe['optimizemember_log'][] = $maybe_end_subscription; } $stripe['optimizemember_log'][] = 'Webhook/IPN event `' . $event->type . '` reformulated. Piping through optimizeMember\'s core gateway processor as `txn_type` (`' . $ipn['txn_type'] . '`).'; $stripe['optimizemember_log'][] = 'Please check core IPN logs for further processing details.'; } break; // Break switch handler. // Break switch handler. case 'invoice.payment_failed': // Subscription payment failures. if (!empty($event->data->object) && ($stripe_invoice = $event->data->object) instanceof Stripe_Invoice && !empty($stripe_invoice->customer) && !empty($stripe_invoice->subscription) && ($stripe_invoice_total = number_format(c_ws_plugin__optimizemember_pro_stripe_utilities::cents_to_dollar_amount($stripe_invoice->total, $stripe_invoice->currency), 2, '.', '')) && is_object($stripe_subscription = c_ws_plugin__optimizemember_pro_stripe_utilities::get_customer_subscription($stripe_invoice->customer, $stripe_invoice->subscription)) && ($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars(0, $stripe_subscription->id))) { $processing = TRUE; $stripe['optimizemember_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T'); if ($maybe_end_subscription = self::_maybe_end_subscription_after_payment($stripe_invoice->customer, $stripe_subscription)) { $stripe['optimizemember_log'][] = $maybe_end_subscription; } $stripe['optimizemember_log'][] = 'Ignoring `' . $event->type . '`. optimizeMember does NOT respond to individual payment failures; only to subscription cancellations.'; $stripe['optimizemember_log'][] = 'You may control the behavior(s) associated w/ subscription payment failures from your Stripe Dashboard please.'; } break; // Break switch handler. // Break switch handler. case 'customer.deleted': // Customer deletions. if (!empty($event->data->object) && ($stripe_customer = $event->data->object) instanceof Stripe_Customer && ($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars(0, $stripe_customer->id))) { $processing = TRUE; $ipn['txn_type'] = 'subscr_eot'; $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)); $stripe['optimizemember_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T'); $stripe['optimizemember_log'][] = 'Webhook/IPN event `' . $event->type . '` reformulated. Piping through optimizeMember\'s core gateway processor as `txn_type` (`' . $ipn['txn_type'] . '`).'; $stripe['optimizemember_log'][] = 'Please check core IPN logs for further processing details.'; } break; // Break switch handler. // Break switch handler. case 'customer.subscription.deleted': // Customer subscription deletion. if (!empty($event->data->object) && ($stripe_subscription = $event->data->object) instanceof Stripe_Subscription && ($ipn_signup_vars = c_ws_plugin__optimizemember_utils_users::get_user_ipn_signup_vars(0, $stripe_subscription->id))) { $processing = TRUE; $ipn['txn_type'] = 'subscr_eot'; $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)); $stripe['optimizemember_log'][] = 'Stripe Webhook/IPN event type identified as: `' . $event->type . '` on: ' . date('D M j, Y g:i:s a T'); $stripe['optimizemember_log'][] = 'Webhook/IPN event `' . $event->type . '` reformulated. Piping through optimizeMember\'s core gateway processor as `txn_type` (`' . $ipn['txn_type'] . '`).'; $stripe['optimizemember_log'][] = 'Please check core IPN logs for further processing details.'; } break; // Break switch handler. } if (empty($processing)) { $stripe['optimizemember_log'][] = 'Ignoring this Webhook/IPN. The event does NOT require any action on the part of OptimizeMember.'; } } else { $stripe['optimizemember_log'][] = 'Unable to verify Webhook/IPN event ID. This is most likely related to an invalid Stripe configuration. Please check: optimizeMember -› Stripe Options.'; $stripe['optimizemember_log'][] = 'If you\'re absolutely SURE that your Stripe configuration is valid, you may want to run some tests on your server, just to be sure \\$_POST variables (and php://input) are populated; and that your server is able to connect to Stripe over an HTTPS connection.'; $stripe['optimizemember_log'][] = 'optimizeMember uses the Stripe SDK for remote connections; which relies upon the cURL extension for PHP. Please make sure that your installation of PHP has the cURL extension; and that it\'s configured together with OpenSSL for HTTPS communication.'; $stripe['optimizemember_log'][] = var_export($_REQUEST, TRUE) . "\n" . var_export(json_decode(@file_get_contents('php://input')), TRUE); } $logt = c_ws_plugin__optimizemember_utilities::time_details(); $logv = c_ws_plugin__optimizemember_utilities::ver_details(); $logm = c_ws_plugin__optimizemember_utilities::mem_details(); $log4 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n" . 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT']; $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4; $log2 = is_multisite() && !is_main_site() ? 'stripe-ipn-4-' . trim(preg_replace('/[^a-z0-9]/i', '-', !empty($_log4) ? $_log4 : ''), '-') . '.log' : 'stripe-ipn.log'; if ($GLOBALS['WS_PLUGIN__']['optimizemember']['o']['gateway_debug_logs']) { if (is_dir($logs_dir = $GLOBALS['WS_PLUGIN__']['optimizemember']['c']['logs_dir'])) { if (is_writable($logs_dir) && c_ws_plugin__optimizemember_utils_logs::archive_oversize_log_files()) { file_put_contents($logs_dir . '/' . $log2, 'LOG ENTRY: ' . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__optimizemember_utils_logs::conceal_private_info(var_export($stripe, TRUE)) . "\n\n", FILE_APPEND); } } } 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. exit; // Exit now. } }
/** * 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 />— 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; } } } }
/** * Get ``$_POST`` or ``$_REQUEST`` vars from PayPal. * * @package optimizeMember\PayPal * @since 3.5 * * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false. */ public static function paypal_postvars() { eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action("ws_plugin__optimizemember_before_paypal_postvars", get_defined_vars()); unset($__refs, $__v); /* Unset defined __refs, __v. */ /* Custom conditionals can be applied by filters. */ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); if (!($postvars = apply_filters("ws_plugin__optimizemember_during_paypal_postvars_conditionals", array(), get_defined_vars()))) { unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (!empty($_GET["tx"]) && empty($_GET["optimizemember_paypal_proxy"])) { $postback["tx"] = $_GET["tx"]; $postback["cmd"] = "_notify-synch"; $postback["at"] = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_identity_token"]; /**/ $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com"; /**/ if (preg_match("/^SUCCESS/i", $response = trim(c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/cgi-bin/webscr", $postback, array("timeout" => 20))))) { foreach (preg_split("/[\r\n]+/", preg_replace("/^SUCCESS/i", "", $response)) as $varline) { list($key, $value) = preg_split("/\\=/", $varline, 2); if (strlen($key = trim($key)) && strlen($value = trim($value))) { $postvars[$key] = trim(stripslashes(urldecode($value))); } } if (!empty($postvars["charset"]) && function_exists("mb_convert_encoding")) { foreach ($postvars as &$value) { $value = @mb_convert_encoding($value, "UTF-8", $postvars["charset"] === "gb2312" ? "GBK" : $postvars["charset"]); } } /**/ return apply_filters("ws_plugin__optimizemember_paypal_postvars", $postvars, get_defined_vars()); } else { /* Nope. */ return false; } } else { if (!empty($_REQUEST) && is_array($postvars = stripslashes_deep($_REQUEST))) { foreach ($postvars as $key => $value) { if (preg_match("/^optimizemember_/", $key)) { unset($postvars[$key]); } } /**/ $postback = $postvars; /* Copy. */ $postback["cmd"] = "_notify-validate"; /**/ $postvars = c_ws_plugin__optimizemember_utils_strings::trim_deep($postvars); /**/ if (!empty($postvars["charset"]) && function_exists("mb_convert_encoding")) { foreach ($postvars as &$value) { $value = @mb_convert_encoding($value, "UTF-8", $postvars["charset"] === "gb2312" ? "GBK" : $postvars["charset"]); } } /**/ $endpoint = $GLOBALS["WS_PLUGIN__"]["optimizemember"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com"; /**/ if (!empty($_GET["optimizemember_paypal_proxy"]) && !empty($_GET["optimizemember_paypal_proxy_verification"]) && $_GET["optimizemember_paypal_proxy_verification"] === c_ws_plugin__optimizemember_paypal_utilities::paypal_proxy_key_gen()) { return apply_filters("ws_plugin__optimizemember_paypal_postvars", array_merge($postvars, array("proxy_verified" => $_GET["optimizemember_paypal_proxy"])), get_defined_vars()); } else { if (empty($_POST) && !empty($_GET["optimizemember_paypal_proxy"]) && !empty($_GET["optimizemember_paypal_proxy_verification"]) && c_ws_plugin__optimizemember_utils_urls::optimizemember_sig_ok($_SERVER["REQUEST_URI"], false, false, "optimizemember_paypal_proxy_verification")) { return apply_filters("ws_plugin__optimizemember_paypal_postvars", array_merge($postvars, array("proxy_verified" => $_GET["optimizemember_paypal_proxy"])), get_defined_vars()); } else { if (trim(strtolower(c_ws_plugin__optimizemember_utils_urls::remote("https://" . $endpoint . "/cgi-bin/webscr", $postback, array("timeout" => 20)))) === "verified") { return apply_filters("ws_plugin__optimizemember_paypal_postvars", $postvars, get_defined_vars()); } else { /* Nope. */ return false; } } } } else { /* Nope. */ return false; } } } else { unset($__refs, $__v); /* Unset defined __refs, __v. */ /**/ return apply_filters("ws_plugin__optimizemember_paypal_postvars", $postvars, get_defined_vars()); } }
/** * 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 />— 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 />— 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 />— 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 />— 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 />— 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 />— 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; } } } }