/** * Generates Specific Post/Page Access links via AJAX. * * @package s2Member\SP_Access * @since 3.5 * * @attaches-to ``add_action("wp_ajax_ws_plugin__s2member_sp_access_link_via_ajax");`` * * @return null Exits script execution after returning data for AJAX caller. */ public static function sp_access_link_via_ajax() { do_action("ws_plugin__s2member_before_sp_access_link_via_ajax", get_defined_vars()); status_header(200); // Send a 200 OK status header. header("Content-Type: text/plain; charset=UTF-8"); // Content-Type with UTF-8. while (@ob_end_clean()) { } // Clean any existing output buffers. if (current_user_can("create_users")) { // Check privileges as well. Ability to create Users? if (!empty($_POST["ws_plugin__s2member_sp_access_link_via_ajax"]) && is_string($nonce = $_POST["ws_plugin__s2member_sp_access_link_via_ajax"]) && wp_verify_nonce($nonce, "ws-plugin--s2member-sp-access-link-via-ajax")) { if (($_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST))) && isset($_p["s2member_sp_access_link_ids"], $_p["s2member_sp_access_link_hours"])) { $sp_access_link = c_ws_plugin__s2member_sp_access::sp_access_link_gen((string) $_p["s2member_sp_access_link_ids"], (string) $_p["s2member_sp_access_link_hours"]); } } } exit(apply_filters("ws_plugin__s2member_sp_access_link_via_ajax", !empty($sp_access_link) ? $sp_access_link : "", get_defined_vars())); }
/** * Handles processing of Pro-Forms for Specific Post/Page checkout. * * @package s2Member\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["s2member_pro_paypal_sp_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-sp-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_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("s2member_transient_express_checkout_" . $_GET["token"])))) { $GLOBALS["ws_plugin__s2member_pro_paypal_sp_checkout_response"] = array(); // This holds the global response details. $global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_sp_checkout_response"]; // This is a shorter reference. if (!empty($xco_post_vars)) { // A customer is returning from Express Checkout @ PayPal? $_POST = $xco_post_vars; } // POST vars from submission prior to Express Checkout. $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_sp_checkout"])); $post_vars["attr"] = !empty($post_vars["attr"]) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])) : array(); $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_paypal_sp_checkout_post_attr", $post_vars["attr"], get_defined_vars()); if (!empty($xco_post_vars)) { $post_vars["attr"]["captcha"] = "0"; } // No need to revalidate captcha in this case. $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 (empty($post_vars["card_expiration"]) && isset($post_vars["card_expiration_month"], $post_vars["card_expiration_year"])) { $post_vars["card_expiration"] = $post_vars["card_expiration_month"] . "/" . $post_vars["card_expiration_year"]; } $post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars); // Collect reCAPTCHA™ post vars. !empty($_GET["token"]) ? delete_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])) : null; if (!c_ws_plugin__s2member_pro_paypal_responses::paypal_form_attr_validation_errors($post_vars["attr"])) { if (!($error = c_ws_plugin__s2member_pro_paypal_responses::paypal_form_submission_validation_errors("sp-checkout", $post_vars))) { $cp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post")); $cp_2gbp_attr = c_ws_plugin__s2member_pro_paypal_utilities::paypal_maestro_solo_2gbp($cp_attr, $post_vars["card_type"]); $cost_calculations = c_ws_plugin__s2member_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["s2member_paypal_xco"]) && $post_vars["card_type"] === "PayPal" && $cost_calculations["total"] > 0) { $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("s2member_paypal_xco", urlencode("s2member_pro_paypal_sp_checkout_return"), $return_url); $cancel_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_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__s2member_paypal_utilities::paypal_api_response($paypal_set_xco)) && empty($paypal_set_xco["__error"])) { set_transient("s2m_" . md5("s2member_transient_express_checkout_" . $paypal_set_xco["TOKEN"]), $_POST, 10800); $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["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 (!empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_sp_checkout_return" && !empty($_GET["token"]) && ($paypal_xco_details = array("METHOD" => "GetExpressCheckoutDetails", "TOKEN" => $_GET["token"])) && ($paypal_xco_details = c_ws_plugin__s2member_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 ($cost_calculations["total"] <= 0 || ($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) { if ($cost_calculations["total"] <= 0) { $new__txn_id = strtoupper('free-' . uniqid()); } else { $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__s2member_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["s2member_paypal_proxy"] = "paypal"; $ipn["s2member_paypal_proxy_use"] = "pro-emails"; $ipn["s2member_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["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen(); $ipn["s2member_paypal_proxy_return_url"] = $post_vars["attr"]["success"]; $ipn["s2member_paypal_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20))); } if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) { setcookie("s2member_sp_tracking", $s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_sp_tracking", $s2member_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_sp_tracking"] = $s2member_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["s2member_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__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) { wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_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 processing of Pro-Forms for Specific Post/Page checkout. * * @package s2Member\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["s2member_pro_authnet_sp_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_authnet_sp_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-sp-checkout")) { $GLOBALS["ws_plugin__s2member_pro_authnet_sp_checkout_response"] = array(); // This holds the global response details. $global_response =& $GLOBALS["ws_plugin__s2member_pro_authnet_sp_checkout_response"]; // This is a shorter reference. $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_authnet_sp_checkout"])); $post_vars["attr"] = !empty($post_vars["attr"]) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"])) : array(); $post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_authnet_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()); if (empty($post_vars["card_expiration"]) && isset($post_vars["card_expiration_month"], $post_vars["card_expiration_year"])) { $post_vars["card_expiration"] = $post_vars["card_expiration_month"] . "/" . $post_vars["card_expiration_year"]; } $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__s2member_pro_authnet_responses::authnet_form_attr_validation_errors($post_vars["attr"])) { if (!($error = c_ws_plugin__s2member_pro_authnet_responses::authnet_form_submission_validation_errors("sp-checkout", $post_vars))) { $cp_attr = c_ws_plugin__s2member_pro_authnet_utilities::authnet_apply_coupon($post_vars["attr"], $post_vars["coupon"], "attr", array("affiliates-silent-post")); $cost_calculations = c_ws_plugin__s2member_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_currency_code"] = $cost_calculations["cur"]; $authnet["x_card_num"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]); $authnet["x_exp_date"] = c_ws_plugin__s2member_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 ($cost_calculations["total"] <= 0 || ($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_aim_response($authnet)) && empty($authnet["__error"])) { if ($cost_calculations["total"] <= 0) { $new__txn_id = strtoupper('free-' . uniqid()); } else { $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__s2member_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["s2member_paypal_proxy"] = "authnet"; $ipn["s2member_paypal_proxy_use"] = "pro-emails"; $ipn["s2member_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["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen(); $ipn["s2member_paypal_proxy_return_url"] = $post_vars["attr"]["success"]; $ipn["s2member_authnet_proxy_return_url"] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20))); } if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($post_vars["attr"]["ids"], $post_vars["attr"]["exp"])) { setcookie("s2member_sp_tracking", $s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_sp_tracking", $s2member_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_sp_tracking"] = $s2member_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["s2member_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__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $ipn["s2member_authnet_proxy_return_url"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) { wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_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; } } } }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. * * @todo Optimize with ``empty()`` and ``isset()``. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal["txn_type"]) && preg_match("/^web_accept\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && !empty($paypal["payer_email"]) && !empty($paypal["txn_id"])) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_before_sp_access", get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access."; list(, $paypal["sp_ids"], $paypal["hours"]) = preg_split("/\\:/", $paypal["item_number"], 3); $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : ""; $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"]; if (($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($paypal["sp_ids"], $paypal["hours"])) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $processing = $during = true; // Yes, we ARE processing this. if (preg_match("/(referenc|associat)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) { // Associating this purchase with a Member? if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["option_selection1"], $paypal["option_selection1"])) && is_object($user = new WP_User($user_id)) && $user->ID) { $sp_references = (array) get_user_option("s2member_sp_references", $user_id); $_sp_reference = array("time" => time(), "ids" => $paypal["sp_ids"], "hours" => $paypal["hours"], "url" => $sp_access_url); $sp_references = c_ws_plugin__s2member_utils_arrays::array_unique(array_merge($sp_references, $_sp_reference)); update_user_option($user_id, "s2member_sp_references", $sp_references); $paypal["s2member_log"][] = "Specific Post/Page ~ Sale associated with User ID: " . $user_id . "."; } } $sbj = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_REQUEST["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"]) ? "pro_" : "") . "sp_email_subject"]); $sbj = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $sbj); $msg = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_REQUEST["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"]) ? "pro_" : "") . "sp_email_message"]); $msg = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $msg); $rec = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][($_REQUEST["s2member_paypal_proxy"] && preg_match("/pro-emails/", $_REQUEST["s2member_paypal_proxy_use"]) ? "pro_" : "") . "sp_email_recipients"]); $rec = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $rec); if (($rec = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $rec)) && ($rec = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $rec))) { if ($rec = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $rec)) { // Full amount of the payment, before fee is subtracted. if (($rec = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $rec)) && ($rec = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $rec))) { if (($rec = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"])), $rec)) && ($rec = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"])), $rec))) { if ($rec = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $rec)) { // **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. (ex. "N\"ame" <email>). if ($rec = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $rec)) { if ($rec = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $rec)) { if (($rec = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $rec)) && ($rec = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $rec)) && ($rec = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $rec))) { if (($sbj = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $sbj)) && ($sbj = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $sbj))) { if ($sbj = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $sbj)) { // Full amount of the payment, before fee is subtracted. if (($sbj = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $sbj)) && ($sbj = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $sbj))) { if (($sbj = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $sbj)) && ($sbj = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $sbj))) { if ($sbj = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $sbj)) { if ($sbj = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $sbj)) { if ($sbj = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $sbj)) { if (($sbj = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $sbj)) && ($sbj = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $sbj)) && ($sbj = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $sbj))) { if (($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $msg))) { if ($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) { // Full amount of the payment, before fee is subtracted. if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $msg)) { if (($msg = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $msg))) { if (($rec = trim(preg_replace("/%%(.+?)%%/i", "", $rec))) && ($sbj = trim(preg_replace("/%%(.+?)%%/i", "", $sbj))) && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) { $sbj = c_ws_plugin__s2member_utilities::evl($sbj, get_defined_vars()); $msg = c_ws_plugin__s2member_utilities::evl($msg, get_defined_vars()); } foreach (c_ws_plugin__s2member_utils_strings::parse_emails($rec) as $recipient) { // Go through a possible list of recipients. c_ws_plugin__s2member_email_configs::email_config() . wp_mail($recipient, apply_filters("ws_plugin__s2member_sp_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_sp_email_msg", $msg, get_defined_vars()), "From: \"" . preg_replace('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=UTF-8") . c_ws_plugin__s2member_email_configs::email_config_release(); } $paypal["s2member_log"][] = "Specific Post/Page Confirmation Email sent to: " . $rec . "."; } } } } } } } } } } } } } } } } } } } } } } } } } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_urls"]) as $url) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours")))), $url)) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["ip"])), $url)) { if (($url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["full_coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["affiliate_id"])), $url))) { if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification URLs have been processed."; } if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { $msg = $sbj = "(s2Member / API Notification Email) - Specific Post/Page ~ Sale"; $msg .= "\n\n"; // Spacing in the message body. $msg .= "sp_access_url: %%sp_access_url%%\n"; $msg .= "sp_access_exp: %%sp_access_exp%%\n"; $msg .= "amount: %%amount%%\n"; $msg .= "txn_id: %%txn_id%%\n"; $msg .= "item_number: %%item_number%%\n"; $msg .= "item_name: %%item_name%%\n"; $msg .= "first_name: %%first_name%%\n"; $msg .= "last_name: %%last_name%%\n"; $msg .= "full_name: %%full_name%%\n"; $msg .= "payer_email: %%payer_email%%\n"; $msg .= "user_ip: %%user_ip%%\n"; $msg .= "full_coupon_code: %%full_coupon_code%%\n"; $msg .= "coupon_code: %%coupon_code%%\n"; $msg .= "coupon_affiliate_id: %%coupon_affiliate_id%%\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)) && ($msg = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($sp_access_url), $msg))) { if ($msg = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours"))), $msg)) { if (($msg = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $msg))) { if (($msg = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $msg)) && ($msg = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $msg))) { if (($msg = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $msg)) && ($msg = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $msg))) { if ($msg = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $msg)) { if ($msg = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $msg)) { if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $msg)) { if (($msg = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $msg)) && ($msg = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $msg))) { if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_sale_notification_recipients"]) as $recipient) { wp_mail($recipient, apply_filters("ws_plugin__s2member_sp_sale_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_sp_sale_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8"); } } } } } } } } } } } $paypal["s2member_log"][] = "Specific Post/Page ~ Sale Notification Emails have been processed."; } if ($processing && $_REQUEST["s2member_paypal_proxy"] && ($url = $_REQUEST["s2member_paypal_proxy_return_url"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%sp_access_url%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace("/%%sp_access_exp%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime("+" . $paypal["hours"] . " hours")))), $url)) { if (($url = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["txn_id"])), $url))) { if (($url = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_number"])), $url)) && ($url = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["item_name"])), $url))) { if (($url = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["first_name"])), $url)) && ($url = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["last_name"])), $url))) { if ($url = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($paypal["first_name"] . " " . $paypal["last_name"]))), $url)) { if ($url = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["payer_email"])), $url)) { if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["ip"])), $url)) { if (($url = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["full_coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["coupon_code"])), $url)) && ($url = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($coupon["affiliate_id"])), $url))) { if ($url = trim($url)) { // Preserve Remaining replacements. // Because the parent routine may perform replacements too. $paypal["s2member_paypal_proxy_return_url"] = $url; } } } } } } } } } } $paypal["s2member_log"][] = "Specific Post/Page Return, a Proxy Return URL is ready."; } if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($code = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $code)) && ($code = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $code))) { if (($code = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $code)) && ($code = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $code))) { if (($code = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $code)) && ($code = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $code))) { if ($code = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $code)) { if ($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $code)) { if ($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $code)) { if (($code = preg_replace("/%%full_coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["full_coupon_code"]), $code)) && ($code = preg_replace("/%%coupon_code%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["coupon_code"]), $code)) && ($code = preg_replace("/%%coupon_affiliate_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($coupon["affiliate_id"]), $code))) { if ($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) { $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site."; set_transient("s2m_" . md5("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200); } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_during_sp_access", get_defined_vars()); unset($__refs, $__v); } else { $paypal["s2member_log"][] = "Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?"; } } else { $paypal["s2member_log"][] = "Not processing. Duplicate IPN."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access."; $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored."; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_notify_after_sp_access", get_defined_vars()); unset($__refs, $__v); return apply_filters("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_notify_in_web_accept_sp", false, get_defined_vars()); } }
/** * Handles processing of Pro-Forms for Specific Post/Page checkout. * * @package s2Member\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['s2member_pro_stripe_sp_checkout']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_sp_checkout']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-sp-checkout')) { $GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response'] = array(); // This holds the global response details. $global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response']; $post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_sp_checkout'])); $post_vars['attr'] = !empty($post_vars['attr']) ? (array) unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array(); $post_vars['attr'] = apply_filters('ws_plugin__s2member_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__s2member_pro_stripe_responses::stripe_form_attr_validation_errors($post_vars['attr'])) { if (!($form_submission_validation_errors = c_ws_plugin__s2member_pro_stripe_responses::stripe_form_submission_validation_errors('sp-checkout', $post_vars))) { unset($_POST['s2member_pro_stripe_sp_checkout']['source_token']); // Good one-time only. unset($_POST['s2member_pro_stripe_sp_checkout']['source_token_summary']); // Good one-time only. $is_bitcoin = !empty($post_vars['source_token']) && stripos($post_vars['source_token'], 'btcrcv_') === 0; $cp_attr = c_ws_plugin__s2member_pro_stripe_utilities::apply_coupon($post_vars['attr'], $post_vars['coupon'], 'attr', array('affiliates-silent-post')); $cost_calculations = c_ws_plugin__s2member_pro_stripe_utilities::cost(NULL, $cp_attr['ra'], $post_vars['state'], $post_vars['country'], $post_vars['zip'], $cp_attr['cc'], $cp_attr['desc'], $is_bitcoin); if (!$global_response) { if ($cost_calculations['total'] > 0) { if (!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(get_current_user_id(), $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'], array(), $post_vars))) { $global_response = array('response' => $stripe_customer, 'error' => TRUE); } else { if (!is_object($stripe_customer = $stripe_customer_with_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($stripe_customer->id, $post_vars['source_token'], $post_vars))) { $global_response = array('response' => $stripe_customer, 'error' => TRUE); } else { if (!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'], array(), $post_vars, $cost_calculations))) { $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__s2member_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['s2member_paypal_proxy'] = 'stripe'; $ipn['s2member_paypal_proxy_use'] = 'pro-emails'; $ipn['s2member_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['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen(); $ipn['s2member_paypal_proxy_return_url'] = $post_vars['attr']['success']; $ipn['s2member_stripe_proxy_return_url'] = trim(c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20))); setcookie('s2member_sp_tracking', $s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($new__txn_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_sp_tracking', $s2member_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_sp_tracking'] = $s2member_sp_tracking); if ($sp_access_url = c_ws_plugin__s2member_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', 's2member'), esc_attr($sp_access_url))); if ($post_vars['attr']['success'] && substr($ipn['s2member_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__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $ipn['s2member_stripe_proxy_return_url'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) { wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_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; } } } }
/** * s2Member's PayPal Auto-Return/PDT handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}. * * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); if (!empty($paypal['txn_type']) && preg_match('/^web_accept$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['sp_access_item_number_regex'], $paypal['item_number'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && !empty($paypal['txn_id']) && (!empty($paypal['txn_baid']) || ($paypal['txn_baid'] = $paypal['txn_id'])) && (!empty($paypal['txn_cid']) || ($paypal['txn_cid'] = $paypal['txn_id']))) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_before_sp_access', get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) { $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.'; list(, $paypal['sp_ids'], $paypal['hours']) = preg_split('/\\:/', $paypal['item_number'], 3); $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : ''; $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip']; $paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip']; $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($paypal['sp_ids'], $paypal['hours'], FALSE)) { $processing = $during = TRUE; // Yes, we ARE processing this. setcookie('s2member_sp_tracking', $s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['txn_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_sp_tracking', $s2member_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_sp_tracking'] = $s2member_sp_tracking); $paypal['s2member_log'][] = 'Transient Tracking Cookie set on ( `web_accept` ) for Specific Post/Page Access.'; if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_tracking_codes'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($code = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $code)) && ($code = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) { if (($code = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $code)) && ($code = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $code))) { if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) { if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) { if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) { if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) { if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) { if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $code)) { if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) { $paypal['s2member_log'][] = 'Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.'; set_transient('s2m_' . md5('s2member_transient_sp_tracking_codes_' . $paypal['txn_id']), $code, 43200); } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_during_sp_access', get_defined_vars()); unset($__refs, $__v); if (apply_filters('ws_plugin__s2member_immediate_sp_access_redirection', FALSE, get_defined_vars())) { $paypal['s2member_log'][] = 'Redirecting Customer immediately to the Specific Post/Page.'; wp_redirect($sp_access_url); // Immediate redirection to Specific Post/Page. } else { if ($custom_success_redirection) { $paypal['s2member_log'][] = 'Redirecting Customer to a custom URL on success: ' . $custom_success_redirection; wp_redirect($custom_success_redirection); } else { $paypal['s2member_log'][] = 'Redirecting Customer to the Specific Post/Page (after displaying a thank-you message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>Thank You! Your transaction has been approved.</strong>', 's2member-front', 's2member'), _x('Continue (Click Here)', 's2member-front', 's2member'), $sp_access_url); } } } else { $paypal['s2member_log'][] = 'Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?'; $paypal['s2member_log'][] = 'Redirecting Customer to the Home Page (after displaying an error message).'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], _x('<strong>ERROR:</strong> Unable to generate Access Link.<br />Please contact Support for assistance.', 's2member-front', 's2member'), _x('Back To Home Page', 's2member-front', 's2member'), home_url('/')); } } else { $paypal['s2member_log'][] = 'Page Expired. Duplicate Return-Data.'; $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.'; $paypal['s2member_log'][] = 'Page Expired. Instructing customer to check their email for further details about how to obtain access to what they purchased.'; echo c_ws_plugin__s2member_return_templates::return_template($paypal['subscr_gateway'], '<strong>' . _x('Thank you! Please check your email for further details regarding your purchase.', 's2member-front', 's2member') . '</strong>', _x('Return to Home Page', 's2member-front', 's2member'), home_url('/')); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_return_after_sp_access', get_defined_vars()); unset($__refs, $__v); return apply_filters('c_ws_plugin__s2member_paypal_return_in_web_accept_sp', $paypal, get_defined_vars()); } else { return apply_filters('c_ws_plugin__s2member_paypal_return_in_web_accept_sp', FALSE, get_defined_vars()); } }
/** * Handles Google® XML Checkout redirections. * * @package s2Member\Google * @since 1.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after redirection to Google® Checkout. */ public static function google_co() { global $current_site, $current_blog; /**/ if (!empty($_GET["s2member_pro_google_co"]) && c_ws_plugin__s2member_utils_urls::s2member_sig_ok($_SERVER["REQUEST_URI"]) && !empty($_GET["co"]) && is_array($attr = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_GET["co"]))) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"]) { $attr = shortcode_atts(array("ids" => "0", "exp" => "72", "level" => "1", "ccaps" => "", "desc" => "", "cc" => "USD", "custom" => $_SERVER["HTTP_HOST"], "ta" => "0", "tp" => "0", "tt" => "D", "ra" => "0.01", "rp" => "1", "rt" => "M", "rr" => "1", "modify" => "0", "cancel" => "0", "sp" => "0", "image" => "default", "output" => "anchor"), $attr); /**/ $attr["tt"] = strtoupper($attr["tt"]); /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */ $attr["rt"] = strtoupper($attr["rt"]); /* Term lengths absolutely must be provided in upper-case format. Only after running shortcode_atts(). */ $attr["rr"] = strtoupper($attr["rr"]); /* Must be provided in upper-case format. Numerical, or BN value. Only after running shortcode_atts(). */ $attr["ccaps"] = strtolower($attr["ccaps"]); /* Custom Capabilities must be typed in lower-case format. Only after running shortcode_atts(). */ $attr["rr"] = $attr["rt"] === "L" ? "BN" : $attr["rr"]; /* Lifetime Subscriptions require Buy Now. Only after running shortcode_atts(). */ $attr["rr"] = $attr["level"] === "*" ? "BN" : $attr["rr"]; /* Independent Ccaps do NOT recur. Only after running shortcode_atts(). */ $attr["rr"] = !$attr["tp"] && !$attr["rr"] ? "BN" : $attr["rr"]; /* No Trial / non-recurring. Only after running shortcode_atts(). */ /**/ if ($attr["modify"] || $attr["cancel"]) { $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com"; /**/ wp_redirect("https://" . $endpoint . "/"); } else { if ($attr["sp"]) { $attr["uniqid"] = uniqid(); /* Unique ID. */ $attr["referencing"] = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id(); /**/ $attr["sp_ids_exp"] = "sp:" . $attr["ids"] . ":" . $attr["exp"]; /* Combined "sp:ids:expiration hours". */ $attr["sp_access_link"] = c_ws_plugin__s2member_sp_access::sp_access_link_gen($attr["ids"], $attr["exp"]); /**/ $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">'; $xml .= '<shopping-cart>'; $xml .= '<items>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(TID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Grants you immediate access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_txn_id>s2-' . esc_html($attr["uniqid"]) . '</s2_txn_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_item_number>' . esc_html($attr["sp_ids_exp"]) . '</s2_item_number>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; $xml .= '<description>' . esc_html($attr["desc"]) . '</description>'; $xml .= '<url>' . esc_html($attr["sp_access_link"]) . '</url>'; $xml .= '</digital-content>'; /**/ $xml .= '</item>'; /**/ $xml .= '</items>'; $xml .= '</shopping-cart>'; /**/ $xml .= '<checkout-flow-support>'; $xml .= '<merchant-checkout-flow-support>'; $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) . '</edit-cart-url>'; $xml .= '<continue-shopping-url>' . esc_html($attr["sp_access_link"]) . '</continue-shopping-url>'; $xml .= '</merchant-checkout-flow-support>'; $xml .= '</checkout-flow-support>'; /**/ $xml .= '</checkout-shopping-cart>'; /**/ $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com"; /**/ if (($xml = c_ws_plugin__s2member_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__s2member_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) { wp_redirect(wp_specialchars_decode($google, ENT_QUOTES)); } else { /* Display error message. */ echo strip_tags($xml); } } else { if ($attr["level"] === "*") { $attr["uniqid"] = uniqid(); /* Unique ID. */ $attr["referencing"] = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id(); /**/ $attr["level_ccaps_eotper"] = $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); /* Right-trim separators from this string so we don't have trailing colons. */ /**/ $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">'; $xml .= '<shopping-cart>'; $xml .= '<items>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(TID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Grants you immediate access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_txn_id>s2-' . esc_html($attr["uniqid"]) . '</s2_txn_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>'; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; $xml .= '<description>' . esc_html(sprintf(_x('You now have access to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>'; $xml .= '<url>' . esc_html(wp_login_url()) . '</url>'; $xml .= '</digital-content>'; /**/ $xml .= '</item>'; /**/ $xml .= '</items>'; $xml .= '</shopping-cart>'; /**/ $xml .= '<checkout-flow-support>'; $xml .= '<merchant-checkout-flow-support>'; $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) . '</edit-cart-url>'; $xml .= '<continue-shopping-url>' . esc_html(wp_login_url()) . '</continue-shopping-url>'; $xml .= '</merchant-checkout-flow-support>'; $xml .= '</checkout-flow-support>'; /**/ $xml .= '</checkout-shopping-cart>'; /**/ $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com"; /**/ if (($xml = c_ws_plugin__s2member_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__s2member_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) { wp_redirect(wp_specialchars_decode($google, ENT_QUOTES)); } else { /* Display error message. */ echo strip_tags($xml); } } else { if ($attr["rr"] === "BN" || !$attr["tp"] && !$attr["rr"]) { $attr["uniqid"] = uniqid(); /* Unique ID. */ $attr["referencing"] = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id(); /**/ $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"]; /**/ $attr["level_ccaps_eotper"] = $attr["rt"] !== "L" ? $attr["level"] . ":" . $attr["ccaps"] . ":" . $attr["rp"] . " " . $attr["rt"] : $attr["level"] . ":" . $attr["ccaps"]; $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); /* Right-trim separators from this string so we don't have trailing colons. */ /**/ $attr["register_access_link"] = c_ws_plugin__s2member_register_access::register_link_gen("google", "s2-" . $attr["uniqid"], $attr["custom"], $attr["level_ccaps_eotper"]); /**/ $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">'; $xml .= '<shopping-cart>'; $xml .= '<items>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(TID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Grants you immediate access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_txn_id>s2-' . esc_html($attr["uniqid"]) . '</s2_txn_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; /**/ if ($attr["referencing"]) { $xml .= '<description>' . esc_html(sprintf(_x('You\'ve been updated to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>'; $xml .= '<url>' . esc_html(wp_login_url()) . '</url>'; } else { $xml .= '<description>' . esc_html(sprintf(_x('%s<br />( the next step is to Register a Username )', "s2member-front", "s2member"), $attr["desc"])) . '</description>'; $xml .= '<url>' . esc_html($attr["register_access_link"]) . '</url>'; } /**/ $xml .= '</digital-content>'; /**/ $xml .= '</item>'; /**/ $xml .= '</items>'; $xml .= '</shopping-cart>'; /**/ $xml .= '<checkout-flow-support>'; $xml .= '<merchant-checkout-flow-support>'; $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) . '</edit-cart-url>'; $xml .= '<continue-shopping-url>' . esc_html($attr["referencing"] ? wp_login_url() : $attr["register_access_link"]) . '</continue-shopping-url>'; $xml .= '</merchant-checkout-flow-support>'; $xml .= '</checkout-flow-support>'; /**/ $xml .= '</checkout-shopping-cart>'; /**/ $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com"; /**/ if (($xml = c_ws_plugin__s2member_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__s2member_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) { wp_redirect(wp_specialchars_decode($google, ENT_QUOTES)); } else { /* Display error message. */ echo strip_tags($xml); } } else { $attr["uniqid"] = uniqid(); /* Unique ID. */ $attr["referencing"] = c_ws_plugin__s2member_utils_users::get_user_subscr_or_wp_id(); /**/ $attr["desc"] = !$attr["desc"] ? $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $attr["level"] . "_label"] : $attr["desc"]; /**/ $attr["level_ccaps_eotper"] = $attr["level"] . ":" . $attr["ccaps"]; /* Actual Subscriptions will always end on their own. */ $attr["level_ccaps_eotper"] = rtrim($attr["level_ccaps_eotper"], ":"); /* Clean any trailing separators from this string. */ /**/ $attr["periodicity"] = c_ws_plugin__s2member_pro_google_utilities::google_periodicity($attr["rp"] . " " . $attr["rt"]); /* Google® periodicity. */ /**/ $attr["register_access_link"] = c_ws_plugin__s2member_register_access::register_link_gen("google", "s2-" . $attr["uniqid"], $attr["custom"], $attr["level_ccaps_eotper"]); /**/ if ($attr["tp"]) { $attr["start_time"] = c_ws_plugin__s2member_pro_google_utilities::google_start_time($attr["tp"] . " " . $attr["tt"]); /**/ $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">'; $xml .= '<shopping-cart>'; $xml .= '<items>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= $attr["ta"] < 0.01 ? '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("100% free trial. NO charge today.", "s2member-front", "s2member")) . '</item-description>' : '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("First payment for immediate access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ta"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_period1>' . esc_html($attr["tp"] . " " . $attr["tt"]) . '</s2_period1>'; $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>'; $xml .= $attr["rr"] ? '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>' : ''; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; $xml .= '<description>' . esc_html(_x("You'll receive an email confirmation within 15 minutes.", "s2member-front", "s2member")) . '</description>'; $xml .= '</digital-content>'; /**/ $xml .= '</item>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(sprintf(_x("Cancel at any time to avoid %s.", "s2member-front", "s2member"), !$attr["rr"] ? _x("this charge", "s2member-front", "s2member") : _x("charges", "s2member-front", "s2member"))) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">0.00</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_period1>' . esc_html($attr["tp"] . " " . $attr["tt"]) . '</s2_period1>'; $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>'; $xml .= $attr["rr"] ? '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>' : ''; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; /**/ if ($attr["referencing"]) { $xml .= '<description>' . esc_html(sprintf(_x('You\'ve been updated to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>'; $xml .= '<url>' . esc_html(wp_login_url()) . '</url>'; } else { $xml .= '<description>' . esc_html(sprintf(_x('%s<br />( the next step is to Register a Username )', "s2member-front", "s2member"), $attr["desc"])) . '</description>'; $xml .= '<url>' . esc_html($attr["register_access_link"]) . '</url>'; } /**/ $xml .= '</digital-content>'; /**/ $xml .= '<subscription type="google" period="' . esc_attr($attr["periodicity"]) . '" start-date="' . esc_attr(date("Y-m-d", $attr["start_time"]) . "T00:00:00Z") . '">'; /**/ $xml .= '<payments>'; $xml .= '<subscription-payment' . (!$attr["rr"] ? ' times="1"' : '') . '>'; $xml .= '<maximum-charge currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</maximum-charge>'; $xml .= '</subscription-payment>'; $xml .= '</payments>'; /**/ $xml .= '<recurrent-item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Covers ongoing access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_subscr_payment>1</s2_subscr_payment>'; $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_period1>' . esc_html($attr["tp"] . " " . $attr["tt"]) . '</s2_period1>'; $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>'; $xml .= $attr["rr"] ? '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>' : ''; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; $xml .= '<description>' . esc_html($attr["desc"]) . '</description>'; $xml .= '<url>' . esc_html(home_url("/")) . '</url>'; $xml .= '</digital-content>'; /**/ $xml .= '</recurrent-item>'; /**/ $xml .= '</subscription>'; /**/ $xml .= '</item>'; /**/ $xml .= '</items>'; $xml .= '</shopping-cart>'; /**/ $xml .= '<checkout-flow-support>'; $xml .= '<merchant-checkout-flow-support>'; $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) . '</edit-cart-url>'; $xml .= '<continue-shopping-url>' . esc_html($attr["referencing"] ? wp_login_url() : $attr["register_access_link"]) . '</continue-shopping-url>'; $xml .= '</merchant-checkout-flow-support>'; $xml .= '</checkout-flow-support>'; /**/ $xml .= '</checkout-shopping-cart>'; } else { if (!$attr["tp"] && $attr["rr"]) { $attr["start_time"] = c_ws_plugin__s2member_pro_google_utilities::google_start_time($attr["rp"] . " " . $attr["rt"]); /**/ $xml = '<?xml version="1.0" encoding="UTF-8"?>'; $xml .= '<checkout-shopping-cart xmlns="http://checkout.google.com/schema/2">'; $xml .= '<shopping-cart>'; $xml .= '<items>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("First payment for immediate access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_period1>0 D</s2_period1>'; /* There is no Trial Period. */ $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>'; $xml .= '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>'; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; $xml .= '<description>' . esc_html(_x("You'll receive an email confirmation within 15 minutes.", "s2member-front", "s2member")) . '</description>'; $xml .= '</digital-content>'; /**/ $xml .= '</item>'; /**/ $xml .= '<item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Cancel at any time to avoid charges.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">0.00</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_period1>0 D</s2_period1>'; /* There is no Trial Period. */ $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>'; $xml .= '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>'; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; /**/ if ($attr["referencing"]) { $xml .= '<description>' . esc_html(sprintf(_x('You\'ve been updated to:<br />%s<br />( <a href="%s">please log back in now</a> )', "s2member-front", "s2member"), $attr["desc"], esc_attr(wp_login_url()))) . '</description>'; $xml .= '<url>' . esc_html(wp_login_url()) . '</url>'; } else { $xml .= '<description>' . esc_html(sprintf(_x('%s<br />( the next step is to Register a Username )', "s2member-front", "s2member"), $attr["desc"])) . '</description>'; $xml .= '<url>' . esc_html($attr["register_access_link"]) . '</url>'; } /**/ $xml .= '</digital-content>'; /**/ $xml .= '<subscription type="google" period="' . esc_attr($attr["periodicity"]) . '" start-date="' . esc_attr(date("Y-m-d", $attr["start_time"]) . "T00:00:00Z") . '">'; /**/ $xml .= '<payments>'; $xml .= '<subscription-payment>'; $xml .= '<maximum-charge currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</maximum-charge>'; $xml .= '</subscription-payment>'; $xml .= '</payments>'; /**/ $xml .= '<recurrent-item>'; /**/ $xml .= '<quantity>1</quantity>'; $xml .= '<item-name>' . esc_html($attr["desc"]) . '</item-name>'; $xml .= '<item-description>(SID:s2-' . esc_html($attr["uniqid"]) . ') ' . esc_html(_x("Covers ongoing access.", "s2member-front", "s2member")) . '</item-description>'; $xml .= '<unit-price currency="' . esc_attr($attr["cc"]) . '">' . esc_html($attr["ra"]) . '</unit-price>'; /**/ $xml .= '<merchant-private-item-data>'; $xml .= '<s2_subscr_payment>1</s2_subscr_payment>'; $xml .= '<s2_subscr_id>s2-' . esc_html($attr["uniqid"]) . '</s2_subscr_id>'; $xml .= '<s2_custom>' . esc_html($attr["custom"]) . '</s2_custom>'; $xml .= '<s2_customer_ip>' . esc_html($_SERVER["REMOTE_ADDR"]) . '</s2_customer_ip>'; $xml .= '<s2_item_number>' . esc_html($attr["level_ccaps_eotper"]) . '</s2_item_number>'; $xml .= '<s2_period1>0 D</s2_period1>'; /* There is no Trial Period. */ $xml .= '<s2_period3>' . esc_html($attr["rp"] . " " . $attr["rt"]) . '</s2_period3>'; $xml .= '<s2_recurring>' . esc_html($attr["rr"]) . '</s2_recurring>'; $xml .= $attr["referencing"] ? '<s2_referencing>' . esc_html($attr["referencing"]) . '</s2_referencing>' : ''; $xml .= '</merchant-private-item-data>'; /**/ $xml .= '<digital-content>'; $xml .= '<display-disposition>PESSIMISTIC</display-disposition>'; $xml .= '<description>' . esc_html($attr["desc"]) . '</description>'; $xml .= '<url>' . esc_html(home_url("/")) . '</url>'; $xml .= '</digital-content>'; /**/ $xml .= '</recurrent-item>'; /**/ $xml .= '</subscription>'; /**/ $xml .= '</item>'; /**/ $xml .= '</items>'; $xml .= '</shopping-cart>'; /**/ $xml .= '<checkout-flow-support>'; $xml .= '<merchant-checkout-flow-support>'; $xml .= '<edit-cart-url>' . esc_html(get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_options_page"])) . '</edit-cart-url>'; $xml .= '<continue-shopping-url>' . esc_html($attr["referencing"] ? wp_login_url() : $attr["register_access_link"]) . '</continue-shopping-url>'; $xml .= '</merchant-checkout-flow-support>'; $xml .= '</checkout-flow-support>'; /**/ $xml .= '</checkout-shopping-cart>'; } } /**/ $endpoint = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_sandbox"] ? "sandbox.google.com/checkout" : "checkout.google.com"; /**/ if (($xml = c_ws_plugin__s2member_utils_urls::remote("https://" . $endpoint . "/api/checkout/v2/merchantCheckout/Merchant/" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["pro_google_merchant_id"], $xml, array_merge(c_ws_plugin__s2member_pro_google_utilities::google_api_headers(), array("timeout" => 20)))) && preg_match("/\\<redirect-url\\>(.+?)\\<\\/redirect-url\\>/i", preg_replace("/[\r\n\t]+/", "", $xml), $m) && ($google = $m[1])) { wp_redirect(wp_specialchars_decode($google, ENT_QUOTES)); } else { /* Display error message. */ echo strip_tags($xml); } } } } } /**/ exit; /* Clean exit. */ } }
/** * s2Member's PayPal Auto-Return/PDT handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}. * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. * * @todo Optimize with ``empty()`` and ``isset()``. */ public static function cp($vars = array()) { extract($vars); if (!empty($paypal["txn_type"]) && preg_match("/^web_accept\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && !empty($paypal["txn_id"])) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_return_before_sp_access", get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_rtn = "s2m_rtn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) { $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access."; list(, $paypal["sp_ids"], $paypal["hours"]) = preg_split("/\\:/", $paypal["item_number"], 3); $paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : ""; $paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"]; $paypal["ip"] = !$paypal["ip"] && $_SERVER["REMOTE_ADDR"] ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"]; if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($paypal["sp_ids"], $paypal["hours"], false)) { $processing = $during = true; setcookie("s2member_sp_tracking", $s2member_sp_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal["txn_id"]), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_sp_tracking", $s2member_sp_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_sp_tracking"] = $s2member_sp_tracking); $paypal["s2member_log"][] = "Transient Tracking Cookie set on ( `web_accept` ) for Specific Post/Page Access."; if ($processing && ($code = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_tracking_codes"]) && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) { if (($code = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $code)) && ($code = preg_replace("/%%amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $code)) && ($code = preg_replace("/%%txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["txn_id"]), $code))) { if (($code = preg_replace("/%%item_number%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_number"]), $code)) && ($code = preg_replace("/%%item_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["item_name"]), $code))) { if (($code = preg_replace("/%%first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["first_name"]), $code)) && ($code = preg_replace("/%%last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["last_name"]), $code))) { if ($code = preg_replace("/%%full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(trim($paypal["first_name"] . " " . $paypal["last_name"])), $code)) { if ($code = preg_replace("/%%payer_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["payer_email"]), $code)) { if ($code = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["ip"]), $code)) { if ($code = trim(preg_replace("/%%(.+?)%%/i", "", $code))) { $paypal["s2member_log"][] = "Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site."; set_transient("s2m_" . md5("s2member_transient_sp_tracking_codes_" . $paypal["txn_id"]), $code, 43200); } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_return_during_sp_access", get_defined_vars()); unset($__refs, $__v); if (apply_filters("ws_plugin__s2member_immediate_sp_access_redirection", false, get_defined_vars())) { $paypal["s2member_log"][] = "Redirecting Customer immediately to the Specific Post/Page."; wp_redirect($sp_access_url); } else { if ($custom_success_redirection) { $paypal["s2member_log"][] = "Redirecting Customer to a custom URL on success: " . $custom_success_redirection; wp_redirect($custom_success_redirection); } else { $paypal["s2member_log"][] = "Redirecting Customer to the Specific Post/Page (after displaying a thank-you message)."; echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Thank You! Your transaction has been approved.</strong>', "s2member-front", "s2member"), _x("Continue (Click Here)", "s2member-front", "s2member"), $sp_access_url); } } } else { $paypal["s2member_log"][] = "Unable to generate Specific Post/Page Access Link. Does your Leading Post/Page still exist?"; $paypal["s2member_log"][] = "Redirecting Customer to the Home Page (after displaying an error message)."; echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>ERROR:</strong> Unable to generate Access Link.<br />Please contact Support for assistance.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/")); } } else { $paypal["s2member_log"][] = "Page Expired. Duplicate Return-Data."; $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access."; $paypal["s2member_log"][] = "Page Expired. Redirecting Customer to the Home Page (after displaying an error message)."; echo c_ws_plugin__s2member_return_templates::return_template($paypal["subscr_gateway"], _x('<strong>Page Expired:</strong> Duplicate Return-Data.<br />Please contact Support if you need any assistance.', "s2member-front", "s2member"), _x("Back To Home Page", "s2member-front", "s2member"), home_url("/")); } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action("ws_plugin__s2member_during_paypal_return_after_sp_access", get_defined_vars()); unset($__refs, $__v); return apply_filters("c_ws_plugin__s2member_paypal_return_in_web_accept_sp", $paypal, get_defined_vars()); } else { return apply_filters("c_ws_plugin__s2member_paypal_return_in_web_accept_sp", false, get_defined_vars()); } }
/** * s2Member's PayPal IPN handler (inner processing routine). * * @package s2Member\PayPal * @since 110720 * * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}. * * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply. */ public static function cp($vars = array()) { extract($vars, EXTR_OVERWRITE | EXTR_REFS); // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. if (!empty($paypal['txn_type']) && preg_match('/^web_accept$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['sp_access_item_number_regex'], $paypal['item_number'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && !empty($paypal['payer_email']) && !empty($paypal['txn_id']) && (!empty($paypal['txn_baid']) || ($paypal['txn_baid'] = $paypal['txn_id'])) && (!empty($paypal['txn_cid']) || ($paypal['txn_cid'] = $paypal['txn_id']))) { foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_before_sp_access', get_defined_vars()); unset($__refs, $__v); if (!get_transient($transient_ipn = 's2m_ipn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) { $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.'; list(, $paypal['sp_ids'], $paypal['hours']) = preg_split('/\\:/', $paypal['item_number'], 3); $paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : ''; $paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip']; $paypal['currency'] = strtoupper($paypal['mc_currency']); // Normalize input currency. $paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']); if (!empty($coupon['coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) { $coupon_class = new c_ws_plugin__s2member_pro_coupons(); $coupon_class->update_uses($coupon['coupon_code']); } if ($sp_access_url = c_ws_plugin__s2member_sp_access::sp_access_link_gen($paypal['sp_ids'], $paypal['hours'])) { $processing = $during = TRUE; // Yes, we ARE processing this. if (preg_match('/(referenc|associat)/i', $paypal['option_name1']) && $paypal['option_selection1']) { // Associating this purchase with a Member? if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['option_selection1'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) { $sp_references = (array) get_user_option('s2member_sp_references', $user_id); $_sp_reference = array('time' => time(), 'ids' => $paypal['sp_ids'], 'hours' => $paypal['hours'], 'url' => $sp_access_url); $sp_references = c_ws_plugin__s2member_utils_arrays::array_unique(array_merge($sp_references, $_sp_reference)); update_user_option($user_id, 's2member_sp_references', $sp_references); if (!empty($coupon['full_coupon_code']) && c_ws_plugin__s2member_utils_conds::pro_is_installed()) { $user_coupons = is_array($user_coupons = get_user_option('s2member_coupon_codes', $user_id)) ? $user_coupons : array(); $user_coupons = array_unique(array_merge($user_coupons, (array) $coupon['full_coupon_code'])); update_user_option($user_id, 's2member_coupon_codes', $user_coupons); } $paypal['s2member_log'][] = 'Specific Post/Page ~ Sale associated with User ID: ' . $user_id . '.'; } } $sbj = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($sp_access_url), $GLOBALS['WS_PLUGIN__']['s2member']['o'][($_REQUEST['s2member_paypal_proxy'] && preg_match('/pro-emails/', $_REQUEST['s2member_paypal_proxy_use']) ? 'pro_' : '') . 'sp_email_subject']); $sbj = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours'))), $sbj); $msg = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($sp_access_url), $GLOBALS['WS_PLUGIN__']['s2member']['o'][($_REQUEST['s2member_paypal_proxy'] && preg_match('/pro-emails/', $_REQUEST['s2member_paypal_proxy_use']) ? 'pro_' : '') . 'sp_email_message']); $msg = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours'))), $msg); $rec = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($sp_access_url), $GLOBALS['WS_PLUGIN__']['s2member']['o'][($_REQUEST['s2member_paypal_proxy'] && preg_match('/pro-emails/', $_REQUEST['s2member_paypal_proxy_use']) ? 'pro_' : '') . 'sp_email_recipients']); $rec = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours'))), $rec); if (($rec = c_ws_plugin__s2member_utils_strings::fill_cvs($rec, $paypal['custom'])) && ($rec = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $rec))) { if ($rec = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $rec)) { // Full amount of the payment, before fee is subtracted. if (($rec = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $rec)) && ($rec = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $rec))) { if (($rec = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $rec)) && ($rec = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $rec))) { if (($rec = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $rec)) && ($rec = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $rec))) { if (($rec = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name'])), $rec)) && ($rec = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name'])), $rec))) { if ($rec = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_dq(c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $rec)) { // **NOTE** c_ws_plugin__s2member_utils_strings::esc_dq() is applied here. (ex. 'N\'ame' <email>). if ($rec = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $rec)) { if ($rec = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $rec)) { if (($rec = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $rec)) && ($rec = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $rec))) { if (($sbj = c_ws_plugin__s2member_utils_strings::fill_cvs($sbj, $paypal['custom'])) && ($sbj = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $sbj))) { if ($sbj = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $sbj)) { // Full amount of the payment, before fee is subtracted. if (($sbj = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $sbj)) && ($sbj = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $sbj))) { if (($sbj = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $sbj)) && ($sbj = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $sbj))) { if (($sbj = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $sbj)) && ($sbj = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $sbj))) { if (($sbj = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $sbj)) && ($sbj = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $sbj))) { if ($sbj = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $sbj)) { if ($sbj = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $sbj)) { if ($sbj = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $sbj)) { if (($sbj = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $sbj)) && ($sbj = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $sbj))) { if (($msg = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $msg))) { if ($msg = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $msg)) { // Full amount of the payment, before fee is subtracted. if (($msg = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $msg)) && ($msg = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $msg))) { if (($msg = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $msg)) && ($msg = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $msg))) { if (($msg = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $msg)) && ($msg = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $msg))) { if (($msg = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $msg)) && ($msg = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $msg))) { if ($msg = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $msg)) { if ($msg = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $msg)) { if (($msg = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $msg))) { if (($rec = trim(preg_replace('/%%(.+?)%%/i', '', $rec))) && ($sbj = trim(preg_replace('/%%(.+?)%%/i', '', $sbj))) && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) { if (!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) { $sbj = c_ws_plugin__s2member_utilities::evl($sbj, get_defined_vars()); $msg = c_ws_plugin__s2member_utilities::evl($msg, get_defined_vars()); } foreach (c_ws_plugin__s2member_utils_strings::parse_emails($rec) as $recipient) { // Go through a possible list of recipients. c_ws_plugin__s2member_email_configs::email_config() . wp_mail($recipient, apply_filters('ws_plugin__s2member_sp_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_sp_email_msg', $msg, get_defined_vars()), 'From: "' . preg_replace('/"/', '"', $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_name']) . '" <' . $GLOBALS['WS_PLUGIN__']['s2member']['o']['reg_email_from_email'] . '>' . "\r\n" . 'Content-Type: text/plain; charset=UTF-8') . c_ws_plugin__s2member_email_configs::email_config_release(); } $paypal['s2member_log'][] = 'Specific Post/Page Confirmation Email sent to: ' . $rec . '.'; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_sale_notification_urls']) { foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_sale_notification_urls']) as $url) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours')))), $url)) { if (($url = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['currency'])), $url)) && ($url = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['currency_symbol'])), $url))) { if (($url = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['mc_gross'])), $url)) && ($url = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_id'])), $url))) { if (($url = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_baid'])), $url)) && ($url = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_cid'])), $url))) { if (($url = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_number'])), $url)) && ($url = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_name'])), $url))) { if (($url = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['first_name'])), $url)) && ($url = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['last_name'])), $url))) { if ($url = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $url)) { if ($url = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['payer_email'])), $url)) { if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['ip'])), $url)) { if (($url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $url))) { if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) { c_ws_plugin__s2member_utils_urls::remote($url); } } } } } } } } } } } } } $paypal['s2member_log'][] = 'Specific Post/Page ~ Sale Notification URLs have been processed.'; } if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_sale_notification_recipients']) { $msg = $sbj = '(s2Member / API Notification Email) - Specific Post/Page ~ Sale'; $msg .= "\n\n"; // Spacing in the message body. $msg .= 'sp_access_url: %%sp_access_url%%' . "\n"; $msg .= 'sp_access_exp: %%sp_access_exp%%' . "\n"; $msg .= 'currency: %%currency%%' . "\n"; $msg .= 'currency_symbol: %%currency_symbol%%' . "\n"; $msg .= 'amount: %%amount%%' . "\n"; $msg .= 'txn_id: %%txn_id%%' . "\n"; $msg .= 'txn_baid: %%txn_baid%%' . "\n"; $msg .= 'txn_cid: %%txn_cid%%' . "\n"; $msg .= 'item_number: %%item_number%%' . "\n"; $msg .= 'item_name: %%item_name%%' . "\n"; $msg .= 'first_name: %%first_name%%' . "\n"; $msg .= 'last_name: %%last_name%%' . "\n"; $msg .= 'full_name: %%full_name%%' . "\n"; $msg .= 'payer_email: %%payer_email%%' . "\n"; $msg .= 'user_ip: %%user_ip%%' . "\n"; $msg .= 'full_coupon_code: %%full_coupon_code%%' . "\n"; $msg .= 'coupon_code: %%coupon_code%%' . "\n"; $msg .= 'coupon_affiliate_id: %%coupon_affiliate_id%%' . "\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 = c_ws_plugin__s2member_utils_strings::fill_cvs($msg, $paypal['custom'])) && ($msg = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($sp_access_url), $msg))) { if ($msg = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours'))), $msg)) { if (($msg = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $msg)) && ($msg = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $msg))) { if (($msg = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $msg)) && ($msg = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $msg))) { if (($msg = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $msg)) && ($msg = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $msg))) { if (($msg = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $msg)) && ($msg = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $msg))) { if (($msg = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $msg)) && ($msg = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $msg))) { if ($msg = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $msg)) { if ($msg = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $msg)) { if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $msg)) { if (($msg = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $msg)) && ($msg = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $msg))) { if ($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) { // Still have a ``$sbj`` and a ``$msg``? foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_sale_notification_recipients']) as $recipient) { wp_mail($recipient, apply_filters('ws_plugin__s2member_sp_sale_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_sp_sale_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8'); } } } } } } } } } } } } } $paypal['s2member_log'][] = 'Specific Post/Page ~ Sale Notification Emails have been processed.'; } if ($processing && $_REQUEST['s2member_paypal_proxy'] && ($url = $_REQUEST['s2member_paypal_proxy_return_url'])) { if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%sp_access_url%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(rawurlencode($sp_access_url)), $url))) { if ($url = preg_replace('/%%sp_access_exp%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(c_ws_plugin__s2member_utils_time::approx_time_difference(time(), strtotime('+' . $paypal['hours'] . ' hours')))), $url)) { if (($url = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['currency'])), $url)) && ($url = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['currency_symbol'])), $url))) { if (($url = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['mc_gross'])), $url)) && ($url = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_id'])), $url))) { if (($url = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_baid'])), $url)) && ($url = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['txn_cid'])), $url))) { if (($url = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_number'])), $url)) && ($url = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['item_name'])), $url))) { if (($url = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['first_name'])), $url)) && ($url = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['last_name'])), $url))) { if ($url = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($paypal['first_name'] . ' ' . $paypal['last_name']))), $url)) { if ($url = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['payer_email'])), $url)) { if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['ip'])), $url)) { if (($url = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['full_coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['coupon_code'])), $url)) && ($url = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($coupon['affiliate_id'])), $url))) { if ($url = trim($url)) { // Preserve Remaining replacements. // Because the parent routine may perform replacements too. $paypal['s2member_paypal_proxy_return_url'] = $url; } } } } } } } } } } } } $paypal['s2member_log'][] = 'Specific Post/Page Return, a Proxy Return URL is ready.'; } if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_tracking_codes'])) { if (($code = c_ws_plugin__s2member_utils_strings::fill_cvs($code, $paypal['custom'])) && ($code = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $code)) && ($code = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) { if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) { if (($code = preg_replace('/%%txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $code)) && ($code = preg_replace('/%%txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $code))) { if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) { if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) { if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) { if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) { if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['ip']), $code)) { if (($code = preg_replace('/%%full_coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['full_coupon_code']), $code)) && ($code = preg_replace('/%%coupon_code%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['coupon_code']), $code)) && ($code = preg_replace('/%%coupon_affiliate_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($coupon['affiliate_id']), $code))) { if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) { $paypal['s2member_log'][] = 'Storing Specific Post/Page Tracking Codes into a Transient Queue. These will be processed on-site.'; set_transient('s2m_' . md5('s2member_transient_sp_tracking_codes_' . $paypal['txn_id']), $code, 43200); } } } } } } } } } } } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_during_sp_access', get_defined_vars()); unset($__refs, $__v); } else { $paypal['s2member_log'][] = 'Unable to generate Access Link for Specific Post/Page Access. Does your Leading Post/Page still exist?'; } } else { $paypal['s2member_log'][] = 'Not processing. Duplicate IPN.'; $paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) for Specific Post/Page Access.'; $paypal['s2member_log'][] = 'Duplicate IPN. Already processed. This IPN will be ignored.'; } foreach (array_keys(get_defined_vars()) as $__v) { $__refs[$__v] =& ${$__v}; } do_action('ws_plugin__s2member_during_paypal_notify_after_sp_access', get_defined_vars()); unset($__refs, $__v); return apply_filters('c_ws_plugin__s2member_paypal_notify_in_web_accept_sp', $paypal, get_defined_vars()); } else { return apply_filters('c_ws_plugin__s2member_paypal_notify_in_web_accept_sp', FALSE, get_defined_vars()); } }