本文整理汇总了PHP中c_ws_plugin__s2member_utils_encryption::decrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_utils_encryption::decrypt方法的具体用法?PHP c_ws_plugin__s2member_utils_encryption::decrypt怎么用?PHP c_ws_plugin__s2member_utils_encryption::decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c_ws_plugin__s2member_utils_encryption
的用法示例。
在下文中一共展示了c_ws_plugin__s2member_utils_encryption::decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Handles Registration Links.
*
* @package s2Member\Registrations
* @since 3.5
*
* @attaches-to ``add_action("init");``
*
* @return null Or exits script execution after redirection.
*/
public static function register()
{
do_action("ws_plugin__s2member_before_register", get_defined_vars());
/**/
if (!empty($_GET["s2member_register"])) {
eval('while (@ob_end_clean ());');
/* First we end/clean any output buffers that may exist already. */
/**/
$msg_503 = _x('<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
/**/
if (is_array($register = preg_split("/\\:\\.\\:\\|\\:\\.\\:/", c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes((string) $_GET["s2member_register"])))))) {
if (count($register) === 6 && $register[0] === "subscr_gateway_subscr_id_custom_item_number_time") {
if (is_numeric($register[5]) && $register[5] <= strtotime("now") && $register[5] >= strtotime("-" . apply_filters("ws_plugin__s2member_register_link_exp_time", "2 days", get_defined_vars()))) {
$_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[1]);
$_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[2]);
$_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[3]);
$_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt($register[4]);
/**/
if (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
status_header(200);
/* Send a 200 OK status header. */
header("Content-Type: text/html; charset=utf-8");
/* Content-Type with UTF-8. */
/**/
setcookie("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie("s2member_custom", $_COOKIE["s2member_custom"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_custom", $_COOKIE["s2member_custom"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie("s2member_item_number", $_COOKIE["s2member_item_number"], time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie("s2member_item_number", $_COOKIE["s2member_item_number"], time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
/**/
do_action("ws_plugin__s2member_during_register", get_defined_vars());
/**/
if (is_multisite() && c_ws_plugin__s2member_utils_conds::is_multisite_farm() && is_main_site() && ($location = c_ws_plugin__s2member_utils_urls::wp_signup_url())) {
echo '<script type="text/javascript">' . "\n";
echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($location) . "';";
echo '</script>' . "\n";
} else {
if ($location = c_ws_plugin__s2member_utils_urls::wp_register_url()) {
echo '<script type="text/javascript">' . "\n";
echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq($location) . "';";
echo '</script>' . "\n";
}
}
exit;
/* Clean exit. The browser will now be redirected to ``$location``. */
} else {
status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
}
} else {
status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
}
} else {
status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
}
} else {
status_header(503) . header("Content-Type: text/html; charset=utf-8") . exit($msg_503);
}
}
/**/
do_action("ws_plugin__s2member_after_register", get_defined_vars());
}
示例2: stripe_update
/**
* Handles processing of Pro-Form billing updates.
*
* @package s2Member\Stripe
* @since 140617
*
* @attaches-to ``add_action('init');``
*/
public static function stripe_update()
{
if (!empty($_POST['s2member_pro_stripe_update']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_update']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-update')) {
$GLOBALS['ws_plugin__s2member_pro_stripe_update_response'] = array();
// This holds the global response details.
$global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_update_response'];
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_update']));
$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_update_post_attr', $post_vars['attr'], get_defined_vars());
$post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
// Collect reCAPTCHA™ post vars.
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('update', $post_vars))) {
if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
if (($cur__subscr_cid = get_user_option('s2member_subscr_cid')) && ($cur__subscr_id = get_user_option('s2member_subscr_id'))) {
if (is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id)) && !preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
unset($_POST['s2member_pro_stripe_update']['source_token']);
// These are good one-time only.
unset($_POST['s2member_pro_stripe_update']['source_token_summary']);
if (is_object($set_customer_source = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_source($cur__subscr_cid, $post_vars['source_token'], $post_vars, $post_vars['attr']['reject_prepaid']))) {
$global_response = array('response' => _x('<strong>Confirmed.</strong> Your billing information has been updated.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
} else {
$global_response = array('response' => $set_customer_source, 'error' => TRUE);
}
} else {
$global_response = array('response' => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
$global_response = array('response' => _x('<strong>Oops.</strong> No Customer|Subscr. ID. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
$global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
// Input form field validation errors.
$global_response = $form_submission_validation_errors;
}
}
}
}
示例3: paypal_cancellation
/**
* Handles processing of Pro-Form cancellations.
*
* @package s2Member\PayPal
* @since 1.5
*
* @attaches-to ``add_action("init");``
*
* @return null Or exits script execution after a custom URL redirection.
*/
public static function paypal_cancellation()
{
if (!empty($_POST["s2member_pro_paypal_cancellation"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-cancellation")) {
$GLOBALS["ws_plugin__s2member_pro_paypal_cancellation_response"] = array();
// This holds the global response details.
$global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_cancellation_response"];
// This is a shorter reference.
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_cancellation"]));
$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_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
$post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
// Collect reCAPTCHA™ post vars.
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("cancellation", $post_vars))) {
if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
if (($paypal = array("METHOD" => "GetRecurringPaymentsProfileDetails")) && ($paypal["PROFILEID"] = $cur__subscr_id = get_user_option("s2member_subscr_id"))) {
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal)) && empty($paypal["__error"])) {
if (preg_match("/^(Active|ActiveProfile|Suspended|SuspendedProfile)\$/i", $paypal["STATUS"])) {
if (!($ipn = array())) {
$ipn["txn_type"] = "subscr_cancel";
$ipn["subscr_id"] = $paypal["PROFILEID"];
$ipn["custom"] = get_user_option("s2member_custom");
$ipn["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal);
$ipn["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal);
$ipn["payer_email"] = $paypal["EMAIL"];
$ipn["first_name"] = $paypal["FIRSTNAME"];
$ipn["last_name"] = $paypal["LASTNAME"];
$ipn["option_name1"] = "Referencing Customer ID";
$ipn["option_selection1"] = $paypal["PROFILEID"];
$ipn["option_name2"] = "Customer IP Address";
// IP Address.
$ipn["option_selection2"] = get_user_option("s2member_registration_ip");
$ipn["item_name"] = $paypal["DESC"];
$ipn["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal);
$ipn["s2member_paypal_proxy"] = "paypal";
$ipn["s2member_paypal_proxy_use"] = "pro-emails";
$ipn["s2member_paypal_proxy_verification"] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
c_ws_plugin__s2member_utils_urls::remote(home_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
}
if ($paypal = array("METHOD" => "ManageRecurringPaymentsProfileStatus", "ACTION" => "Cancel", "PROFILEID" => $cur__subscr_id)) {
c_ws_plugin__s2member_paypal_utilities::paypal_api_response($paypal);
$global_response = array("response" => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
} else {
if (preg_match("/^(Pending|PendingProfile)\$/i", $paypal["STATUS"])) {
$global_response = array("response" => _x('<strong>Unable to cancel at this time.</strong> Your account is pending other changes. Please try again in 15 minutes.', "s2member-front", "s2member"), "error" => true);
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
}
} else {
if ($paypal && !empty($paypal["__error"]) && $paypal["L_ERRORCODE0"] === "11592") {
$global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to cancel your Subscription.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/cgi-bin/webscr?cmd=_subscr-find&alias=" . urlencode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_merchant_id"]))), "error" => true);
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
}
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
if ($post_vars["attr"]["unsub"]) {
c_ws_plugin__s2member_list_servers::process_list_server_removals_against_current_user(TRUE);
}
} else {
$global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
}
} else {
$global_response = $error;
}
}
}
}
示例4: sp_checkout
/**
* 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";
//.........这里部分代码省略.........
示例5: paypal_registration
/**
* Handles processing of Pro Form registrations.
*
* @package s2Member\PayPal
* @since 1.5
*
* @attaches-to ``add_action("init");``
*
* @return null Or exits script execution after a custom URL redirection.
*/
public static function paypal_registration()
{
if (!empty($_POST["s2member_pro_paypal_registration"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_registration"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-registration")) {
$GLOBALS["ws_plugin__s2member_pro_paypal_registration_response"] = array();
// This holds the global response details.
$global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_registration_response"];
// This is a shorter reference.
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_registration"]));
$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_registration_post_attr", $post_vars["attr"], get_defined_vars());
$post_vars["recaptcha_challenge_field"] = isset($_POST["recaptcha_challenge_field"]) ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : "";
$post_vars["recaptcha_response_field"] = isset($_POST["recaptcha_response_field"]) ? trim(stripslashes($_POST["recaptcha_response_field"])) : "";
$post_vars["name"] = trim($post_vars["first_name"] . " " . $post_vars["last_name"]);
$post_vars["email"] = apply_filters("user_registration_email", sanitize_email($post_vars["email"]), get_defined_vars());
$post_vars["username"] = is_multisite() ? strtolower($post_vars["username"]) : $post_vars["username"];
// Force lowercase.
$post_vars["username"] = preg_replace("/\\s+/", "", sanitize_user($post_vars["_o_username"] = $post_vars["username"], is_multisite()));
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("registration", $post_vars))) {
if (!($create_user = array())) {
$_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $post_vars["password1"];
// Fake this for registration configuration.
$_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $post_vars["first_name"];
// Fake this for registration configuration.
$_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $post_vars["last_name"];
// Fake this for registration configuration.
$_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $post_vars["custom_fields"]["opt_in"];
// Fake this too.
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
$field_id_class = preg_replace("/_/", "-", $field_var);
if (isset($post_vars["custom_fields"][$field_var])) {
$_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $post_vars["custom_fields"][$field_var];
}
}
}
$GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_level"] = $post_vars["attr"]["level"];
$GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_ccaps"] = $post_vars["attr"]["ccaps"];
$GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"] = $post_vars["attr"]["tp"] . " " . $post_vars["attr"]["tt"];
$_EOT_ =& $GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"];
// Quick/shorter reference to this var.
$_EOT_ = $post_vars["attr"]["tp"] && $post_vars["attr"]["tt"] ? date("Y-m-d H:i:s", c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $_EOT_)) : "";
$GLOBALS["ws_plugin__s2member_registration_vars"]["ws_plugin__s2member_custom_reg_field_s2member_custom"] = $post_vars["attr"]["custom"];
unset($_EOT_);
// We can unset this shorter/reference variable now.
$GLOBALS["ws_plugin__s2member_registration_return_url"] = $post_vars["attr"]["success"];
// Custom success return.
$create_user["user_login"] = $post_vars["username"];
// Copy this into a separate array for `wp_create_user()`.
$create_user["user_pass"] = wp_generate_password();
// Which may fire `c_ws_plugin__s2member_registrations::generate_password()`.
$create_user["user_email"] = $post_vars["email"];
// Copy this into a separate array for `wp_create_user()`.
}
if ($post_vars["password1"] && $post_vars["password1"] === $create_user["user_pass"]) {
if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
update_user_option($new__user_id, "default_password_nag", false, true);
wp_new_user_notification($new__user_id, $create_user["user_pass"]);
$global_response = array("response" => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">login</a>.', "s2member-front", "s2member"), esc_attr(wp_login_url())));
if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__s2member_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__s2member_registration_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> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
}
} else {
if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user["user_login"], $create_user["user_email"], $create_user["user_pass"])) || ($new__user_id = wp_create_user($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"]))) && !is_wp_error($new__user_id)) {
update_user_option($new__user_id, "default_password_nag", true, true);
wp_new_user_notification($new__user_id, $create_user["user_pass"]);
$global_response = array("response" => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && substr($GLOBALS["ws_plugin__s2member_registration_return_url"], 0, 2) === substr($post_vars["attr"]["success"], 0, 2) && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $GLOBALS["ws_plugin__s2member_registration_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> A slight problem. Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
}
}
} else {
$global_response = $error;
}
}
}
}
示例6: authnet_sp_checkout
/**
* 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 {
//.........这里部分代码省略.........
示例7: cp
/**
* 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);
// Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
if (!empty($paypal['txn_type']) && preg_match('/^(web_accept|subscr_signup|subscr_payment)$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['subscr_id']) || !empty($paypal['txn_id']) && ($paypal['subscr_id'] = $paypal['txn_id'])) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
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|subscr_signup|subscr_payment` ).';
@(list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3));
$paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
$paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
$paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip'];
if (preg_match('/^subscr_payment$/i', $paypal['txn_type']) && !empty($_GET['s2member_paypal_return_tra']) && (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET['s2member_paypal_return_tra'])))) && is_array($tra = maybe_unserialize($tra))) && (count($tra) === 11 && isset($tra['ta'], $tra['tp'], $tra['tt'], $tra['ra'], $tra['rp'], $tra['rt'], $tra['rr'], $tra['rrt'], $tra['rra'], $tra['invoice'], $tra['checksum'])) && $tra['invoice'] === $paypal['invoice'] && $tra['checksum'] === md5($paypal['invoice'] . $paypal['ip'] . $paypal['item_number'])) {
$tracking_properties = TRUE;
// Yes, these tracking properties ARE being set here.
$paypal['period1'] = $tra['rr'] !== 'BN' && $tra['tp'] ? $tra['tp'] . ' ' . $tra['tt'] : '0 D';
$paypal['mc_amount1'] = $tra['rr'] !== 'BN' && $tra['tp'] ? number_format($tra['ta'], 2, '.', '') : '0.00';
$paypal['period3'] = $tra['rp'] . ' ' . $tra['rt'];
$paypal['mc_amount3'] = $tra['ra'];
$paypal['recurring'] = $tra['rr'] === '1' ? '1' : '0';
$paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
// Defaults to '0 D' (zero days).
$paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3'];
$paypal['regular'] = $paypal['mc_amount3'];
// This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
$paypal['regular_term'] = $paypal['period3'];
// This is just set to keep a standard; this way both initial_term & regular_term are available.
$paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0';
// If non-recurring, this should be zero, otherwise Regular.
$paypal['currency'] = strtoupper($paypal['mc_currency']);
// Normalize input currency.
$paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
$ipn_signup_vars = $paypal;
// Copy of PayPal vars; used as IPN signup vars.
unset($ipn_signup_vars['s2member_log']);
// Create array of wouldbe IPN signup vars w/o s2member_log.
} else {
if (preg_match('/^(web_accept|subscr_signup)$/i', $paypal['txn_type'])) {
$tracking_properties = TRUE;
// Yes, these tracking properties ARE being set here.
$paypal['period1'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
// Defaults to '0 D' (zero days).
$paypal['mc_amount1'] = strlen($paypal['mc_amount1']) && $paypal['mc_amount1'] > 0 ? $paypal['mc_amount1'] : '0.00';
if (preg_match('/^web_accept$/i', $paypal['txn_type'])) {
$paypal['period3'] = $paypal['eotper'] ? $paypal['eotper'] : '1 L';
// 1 Lifetime.
$paypal['mc_amount3'] = $paypal['mc_gross'];
// The 'Buy Now' amount is the full gross.
}
$paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
// Defaults to '0 D' (zero days).
$paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3'];
$paypal['regular'] = $paypal['mc_amount3'];
// This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
$paypal['regular_term'] = $paypal['period3'];
// This is just set to keep a standard; this way both initial_term & regular_term are available.
$paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0';
// If non-recurring, this should be zero, otherwise Regular.
$paypal['currency'] = strtoupper($paypal['mc_currency']);
// Normalize input currency.
$paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
$ipn_signup_vars = $paypal;
// Copy of PayPal vars; used as IPN signup vars.
unset($ipn_signup_vars['s2member_log']);
// Create array of wouldbe IPN signup vars w/o s2member_log.
} else {
$tracking_properties = FALSE;
}
}
// Not possible.
/*
New Subscription with advanced update vars (option_name1, option_selection1)? Used in Subscr. Modifications.
*/
if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.';
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap('administrator')) {
$processing = $modifying = $during = TRUE;
// Yes, we ARE processing this.
//.........这里部分代码省略.........
示例8: paypal_checkout
/**
* Handles processing of Pro-Form checkouts.
*
* @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 paypal_checkout()
{
if (!empty($_POST["s2member_pro_paypal_checkout"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_checkout"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-checkout") || !empty($_GET["s2member_paypal_xco"]) && $_GET["s2member_paypal_xco"] === "s2member_pro_paypal_checkout_return" && !empty($_GET["token"]) && ($_GET["token"] = esc_html($_GET["token"])) && (empty($_GET["PayerID"]) || ($_GET["PayerID"] = esc_html($_GET["PayerID"]))) && ($xco_post_vars = get_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"])))) {
$GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"] = array();
$global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"];
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_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_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());
$post_vars["username"] = is_multisite() ? strtolower(@$post_vars["username"]) : @$post_vars["username"];
// Force lowercase.
$post_vars["username"] = sanitize_user($post_vars["_o_username"] = $post_vars["username"], is_multisite());
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.
if (!empty($_GET["token"])) {
delete_transient("s2m_" . md5("s2member_transient_express_checkout_" . $_GET["token"]));
}
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("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($cp_2gbp_attr["ta"], $cp_2gbp_attr["ra"], $post_vars["state"], $post_vars["country"], $post_vars["zip"], $cp_2gbp_attr["cc"], $cp_2gbp_attr["desc"]);
if ($cost_calculations["total"] <= 0 && $post_vars["attr"]["tp"] && $cost_calculations["trial_total"] > 0) {
$post_vars["attr"]["tp"] = "0";
// Ditch the trial period completely.
$cost_calculations["sub_total"] = $cost_calculations["trial_sub_total"];
// Use as regular sub-total (ditch trial sub-total).
$cost_calculations["tax"] = $cost_calculations["trial_tax"];
// Use as regular tax (ditch trial tax).
$cost_calculations["tax_per"] = $cost_calculations["trial_tax_per"];
// Use as regular tax (ditch trial tax).
$cost_calculations["total"] = $cost_calculations["trial_total"];
// Use as regular total (ditch trial).
$cost_calculations["trial_sub_total"] = "0.00";
// Ditch the initial total (using as grand total).
$cost_calculations["trial_tax"] = "0.00";
// Ditch this calculation now also.
$cost_calculations["trial_tax_per"] = "";
// Ditch this calculation now also.
$cost_calculations["trial_total"] = "0.00";
// Ditch this calculation now also.
}
$use_recurring_profile = $post_vars["attr"]["rr"] === "BN" || !$post_vars["attr"]["tp"] && !$post_vars["attr"]["rr"] ? false : true;
$is_independent_ccaps_sale = $post_vars["attr"]["level"] === "*" ? true : false;
if ($use_recurring_profile && $cost_calculations["trial_total"] <= 0 && $cost_calculations["total"] <= 0) {
if (!$post_vars["attr"]["rr"] && $post_vars["attr"]["rt"] !== "L") {
if (substr_count($post_vars["attr"]["level_ccaps_eotper"], ":") === 1) {
$post_vars["attr"]["level_ccaps_eotper"] .= ":" . $post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"];
} else {
if (substr_count($post_vars["attr"]["level_ccaps_eotper"], ":") === 0) {
$post_vars["attr"]["level_ccaps_eotper"] .= "::" . $post_vars["attr"]["rp"] . " " . $post_vars["attr"]["rt"];
}
}
} else {
if ($post_vars["attr"]["rr"] && $post_vars["attr"]["rrt"] && $post_vars["attr"]["rt"] !== "L") {
if (substr_count($post_vars["attr"]["level_ccaps_eotper"], ":") === 1) {
$post_vars["attr"]["level_ccaps_eotper"] .= ":" . $post_vars["attr"]["rp"] * $post_vars["attr"]["rrt"] . " " . $post_vars["attr"]["rt"];
} else {
if (substr_count($post_vars["attr"]["level_ccaps_eotper"], ":") === 0) {
$post_vars["attr"]["level_ccaps_eotper"] .= "::" . $post_vars["attr"]["rp"] * $post_vars["attr"]["rrt"] . " " . $post_vars["attr"]["rt"];
}
}
}
}
}
if (empty($_GET["s2member_paypal_xco"]) && $post_vars["card_type"] === "PayPal" && ($cost_calculations["trial_total"] > 0 || $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", "s2p-option"), $return_url = $cancel_url);
$return_url = add_query_arg("s2p-option", urlencode((string) @$_REQUEST["s2p-option"]), $return_url);
$return_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_return"), $return_url);
$cancel_url = add_query_arg("s2p-option", urlencode((string) @$_REQUEST["s2p-option"]), $cancel_url);
$cancel_url = add_query_arg("s2member_paypal_xco", urlencode("s2member_pro_paypal_checkout_cancel"), $cancel_url);
$user = is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID) ? $user : false;
if (!($paypal_set_xco = array())) {
$paypal_set_xco["METHOD"] = "SetExpressCheckout";
$paypal_set_xco["RETURNURL"] = $return_url;
//.........这里部分代码省略.........
示例9: authnet_cancellation
/**
* Handles processing of Pro Form cancellations.
*
* @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_cancellation()
{
if (!empty($_POST["s2member_pro_authnet_cancellation"]["nonce"]) && ($nonce = $_POST["s2member_pro_authnet_cancellation"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-authnet-cancellation")) {
$GLOBALS["ws_plugin__s2member_pro_authnet_cancellation_response"] = array();
/* This holds the global response details. */
$global_response =& $GLOBALS["ws_plugin__s2member_pro_authnet_cancellation_response"];
/* This is a shorter reference. */
/**/
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_authnet_cancellation"]));
$post_vars["attr"] = unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"]));
/* And run a Filter. */
$post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_authnet_cancellation_post_attr", $post_vars["attr"], get_defined_vars());
/**/
$post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
$post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
/**/
if (!c_ws_plugin__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("cancellation", $post_vars))) {
if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
if (($authnet = array("x_method" => "status")) && ($authnet["x_subscription_id"] = $cur__subscr_id = get_user_option("s2member_subscr_id"))) {
if (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet["__error"]) && $authnet["subscription_status"]) {
if (preg_match("/^(active|suspended)\$/i", $authnet["subscription_status"])) {
if (!($ipn = array())) {
/* With Authorize.Net®, we need their IPN signup vars. */
if (is_array($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars())) {
$ipn["txn_type"] = "subscr_cancel";
$ipn["subscr_id"] = $ipn_signup_vars["subscr_id"];
$ipn["custom"] = $ipn_signup_vars["custom"];
/**/
$ipn["period1"] = $ipn_signup_vars["period1"];
$ipn["period3"] = $ipn_signup_vars["period3"];
/**/
$ipn["payer_email"] = $ipn_signup_vars["payer_email"];
$ipn["first_name"] = $ipn_signup_vars["first_name"];
$ipn["last_name"] = $ipn_signup_vars["last_name"];
/**/
$ipn["option_name1"] = $ipn_signup_vars["option_name1"];
$ipn["option_selection1"] = $ipn_signup_vars["option_selection1"];
/**/
$ipn["option_name2"] = $ipn_signup_vars["option_name2"];
$ipn["option_selection2"] = $ipn_signup_vars["option_selection2"];
/**/
$ipn["item_name"] = $ipn_signup_vars["item_name"];
$ipn["item_number"] = $ipn_signup_vars["item_number"];
/**/
$ipn_q = "&s2member_paypal_proxy=authnet&s2member_paypal_proxy_use=pro-emails";
$ipn_q .= "&s2member_paypal_proxy_verification=" . urlencode(c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
/**/
c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1" . $ipn_q), $ipn, array("timeout" => 20));
}
}
/**/
if ($authnet = array("x_method" => "cancel", "x_subscription_id" => $cur__subscr_id)) {
c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
/**/
$global_response = array("response" => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
/**/
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
/**/
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
/**/
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
/**/
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
}
} else {
$global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
}
} else {
$global_response = $error;
}
}
}
//.........这里部分代码省略.........
示例10: stripe_cancellation
/**
* Handles processing of Pro-Form cancellations.
*
* @package s2Member\Stripe
* @since 140617
*
* @attaches-to ``add_action('init');``
*/
public static function stripe_cancellation()
{
if (!empty($_POST['s2member_pro_stripe_cancellation']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_cancellation']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-cancellation')) {
$GLOBALS['ws_plugin__s2member_pro_stripe_cancellation_response'] = array();
// This holds the global response details.
$global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_cancellation_response'];
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_cancellation']));
$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_cancellation_post_attr', $post_vars['attr'], get_defined_vars());
$post_vars['recaptcha_challenge_field'] = isset($_POST['recaptcha_challenge_field']) ? trim(stripslashes($_POST['recaptcha_challenge_field'])) : '';
$post_vars['recaptcha_response_field'] = isset($_POST['recaptcha_response_field']) ? trim(stripslashes($_POST['recaptcha_response_field'])) : '';
if (!c_ws_plugin__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('cancellation', $post_vars))) {
if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
if (($cur__subscr_cid = get_user_option('s2member_subscr_cid')) && ($cur__subscr_id = get_user_option('s2member_subscr_id'))) {
if (is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::get_customer_subscription($cur__subscr_cid, $cur__subscr_id))) {
if (!preg_match('/^canceled$/i', $stripe_subscription->status) && !$stripe_subscription->cancel_at_period_end) {
if (is_object(c_ws_plugin__s2member_pro_stripe_utilities::cancel_customer_subscription($cur__subscr_cid, $cur__subscr_id))) {
if (is_array($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars())) {
$ipn['txn_type'] = 'subscr_cancel';
$ipn['subscr_cid'] = $ipn_signup_vars['subscr_cid'];
$ipn['subscr_id'] = $ipn_signup_vars['subscr_id'];
$ipn['custom'] = $ipn_signup_vars['custom'];
$ipn['period1'] = $ipn_signup_vars['period1'];
$ipn['period3'] = $ipn_signup_vars['period3'];
$ipn['payer_email'] = $ipn_signup_vars['payer_email'];
$ipn['first_name'] = $ipn_signup_vars['first_name'];
$ipn['last_name'] = $ipn_signup_vars['last_name'];
$ipn['option_name1'] = $ipn_signup_vars['option_name1'];
$ipn['option_selection1'] = $ipn_signup_vars['option_selection1'];
$ipn['option_name2'] = $ipn_signup_vars['option_name2'];
$ipn['option_selection2'] = $ipn_signup_vars['option_selection2'];
$ipn['item_name'] = $ipn_signup_vars['item_name'];
$ipn['item_number'] = $ipn_signup_vars['item_number'];
$ipn['s2member_paypal_proxy'] = 'stripe';
$ipn['s2member_paypal_proxy_use'] = 'pro-emails';
$ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
}
$global_response = array('response' => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
} else {
$global_response = array('response' => _x('API failure. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
$global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
} else {
$global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
} else {
$global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
if ($post_vars['attr']['unsub']) {
c_ws_plugin__s2member_list_servers::process_list_server_removals_against_current_user(TRUE);
}
} else {
$global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
// Input form field validation errors.
$global_response = $form_submission_validation_errors;
}
}
}
}
示例11: authnet_cancellation
/**
* Handles processing of Pro-Form cancellations.
*
* @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_cancellation()
{
if (!empty($_POST['s2member_pro_authnet_cancellation']['nonce']) && ($nonce = $_POST['s2member_pro_authnet_cancellation']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-authnet-cancellation')) {
$GLOBALS['ws_plugin__s2member_pro_authnet_cancellation_response'] = array();
// This holds the global response details.
$global_response =& $GLOBALS['ws_plugin__s2member_pro_authnet_cancellation_response'];
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_authnet_cancellation']));
$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_cancellation_post_attr', $post_vars['attr'], get_defined_vars());
$post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
// Collect reCAPTCHA™ post vars.
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('cancellation', $post_vars))) {
if (is_user_logged_in() && is_object($user = wp_get_current_user()) && ($user_id = $user->ID)) {
if (($authnet = array('x_method' => 'status')) && ($authnet['x_subscription_id'] = $cur__subscr_id = get_user_option('s2member_subscr_id'))) {
if (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet)) && empty($authnet['__error']) && $authnet['subscription_status']) {
if (preg_match('/^(active|suspended)$/i', $authnet['subscription_status'])) {
if (is_array($ipn_signup_vars = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_vars())) {
$ipn['txn_type'] = 'subscr_cancel';
$ipn['subscr_id'] = $ipn_signup_vars['subscr_id'];
$ipn['custom'] = $ipn_signup_vars['custom'];
$ipn['period1'] = $ipn_signup_vars['period1'];
$ipn['period3'] = $ipn_signup_vars['period3'];
$ipn['payer_email'] = $ipn_signup_vars['payer_email'];
$ipn['first_name'] = $ipn_signup_vars['first_name'];
$ipn['last_name'] = $ipn_signup_vars['last_name'];
$ipn['option_name1'] = $ipn_signup_vars['option_name1'];
$ipn['option_selection1'] = $ipn_signup_vars['option_selection1'];
$ipn['option_name2'] = $ipn_signup_vars['option_name2'];
$ipn['option_selection2'] = $ipn_signup_vars['option_selection2'];
$ipn['item_name'] = $ipn_signup_vars['item_name'];
$ipn['item_number'] = $ipn_signup_vars['item_number'];
$ipn['s2member_paypal_proxy'] = 'authnet';
$ipn['s2member_paypal_proxy_use'] = 'pro-emails';
$ipn['s2member_paypal_proxy_verification'] = c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen();
c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), $ipn, array('timeout' => 20));
}
if ($authnet = array('x_method' => 'cancel', 'x_subscription_id' => $cur__subscr_id)) {
c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response($authnet);
$global_response = array('response' => _x('<strong>Billing termination confirmed.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
} else {
$global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
} else {
$global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
} else {
$global_response = array('response' => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', 's2member-front', 's2member'));
if ($post_vars['attr']['success'] && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $post_vars['attr']['success'])) && ($custom_success_url = trim(preg_replace('/%%(.+?)%%/i', '', $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, 's2p-v')) . exit;
}
}
if ($post_vars['attr']['unsub']) {
c_ws_plugin__s2member_list_servers::process_list_server_removals_against_current_user(TRUE);
}
} else {
$global_response = array('response' => _x('You\'re <strong>NOT</strong> logged in.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
$global_response = $error;
}
}
}
}
示例12: reg_cookies_ok
/**
* Checks registration cookies.
*
* @package s2Member\Registrations
* @since 110707
*
* @return array|bool An array of cookies if they're OK, else false.
*/
public static function reg_cookies_ok()
{
global $wpdb;
/** @var $wpdb \wpdb */
do_action("ws_plugin__s2member_before_reg_cookies_ok", get_defined_vars());
if (isset($_COOKIE["s2member_subscr_gateway"], $_COOKIE["s2member_subscr_id"], $_COOKIE["s2member_custom"], $_COOKIE["s2member_item_number"])) {
if (($subscr_gateway = c_ws_plugin__s2member_utils_encryption::decrypt((string) $_COOKIE["s2member_subscr_gateway"])) && ($subscr_id = c_ws_plugin__s2member_utils_encryption::decrypt((string) $_COOKIE["s2member_subscr_id"])) && preg_match("/^" . preg_quote(preg_replace("/\\:([0-9]+)\$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", $custom = c_ws_plugin__s2member_utils_encryption::decrypt((string) $_COOKIE["s2member_custom"])) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $item_number = c_ws_plugin__s2member_utils_encryption::decrypt((string) $_COOKIE["s2member_item_number"])) && !$wpdb->get_var("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . esc_sql($subscr_id) . "' LIMIT 1")) {
$reg_cookies_ok = $reg_cookies = array("subscr_gateway" => $subscr_gateway, "subscr_id" => $subscr_id, "custom" => $custom, "item_number" => $item_number);
}
}
return apply_filters("ws_plugin__s2member_reg_cookies_ok", isset($reg_cookies_ok) && $reg_cookies_ok && !empty($reg_cookies) ? $reg_cookies : false, get_defined_vars());
}
示例13: stripe_registration
/**
* Handles processing of Pro-Form registrations.
*
* @package s2Member\Stripe
* @since 140617
*
* @attaches-to ``add_action('init');``
*/
public static function stripe_registration()
{
if (!empty($_POST['s2member_pro_stripe_registration']['nonce']) && ($nonce = $_POST['s2member_pro_stripe_registration']['nonce']) && wp_verify_nonce($nonce, 's2member-pro-stripe-registration')) {
$GLOBALS['ws_plugin__s2member_pro_stripe_registration_response'] = array();
// This holds the global response details.
$global_response =& $GLOBALS['ws_plugin__s2member_pro_stripe_registration_response'];
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_registration']));
$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_registration_post_attr', $post_vars['attr'], get_defined_vars());
$post_vars['name'] = trim($post_vars['first_name'] . ' ' . $post_vars['last_name']);
$post_vars['email'] = apply_filters('user_registration_email', sanitize_email($post_vars['email']), get_defined_vars());
$post_vars['username'] = is_multisite() ? strtolower($post_vars['username']) : $post_vars['username'];
// Force lowercase.
$post_vars['username'] = sanitize_user($post_vars['_o_username'] = $post_vars['username'], is_multisite());
$post_vars = c_ws_plugin__s2member_utils_captchas::recaptcha_post_vars($post_vars);
// Collect reCAPTCHA™ post vars.
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('registration', $post_vars))) {
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_user_pass1'] = $post_vars['password1'];
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_first_name'] = $post_vars['first_name'];
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_last_name'] = $post_vars['last_name'];
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_opt_in'] = @$post_vars['custom_fields']['opt_in'];
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
$field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
$field_id_class = preg_replace('/_/', '-', $field_var);
if (isset($post_vars['custom_fields'][$field_var])) {
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_' . $field_var] = $post_vars['custom_fields'][$field_var];
}
}
}
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_level'] = $post_vars['attr']['level'];
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_ccaps'] = $post_vars['attr']['ccaps'];
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_custom'] = $post_vars['attr']['custom'];
$GLOBALS['ws_plugin__s2member_registration_vars']['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time'] = $post_vars['attr']['tp'] && $post_vars['attr']['tt'] ? date('Y-m-d H:i:s', c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $post_vars['attr']['tp'] . ' ' . $post_vars['attr']['tt'])) : '';
$GLOBALS['ws_plugin__s2member_registration_return_url'] = $post_vars['attr']['success'];
$create_user['user_email'] = $post_vars['email'];
// Copy this into a separate array for `wp_create_user()`.
$create_user['user_login'] = $post_vars['username'];
// Copy this into a separate array for `wp_create_user()`.
$create_user['user_pass'] = c_ws_plugin__s2member_registrations::maybe_custom_pass($post_vars["password1"]);
$has_custom_password = $post_vars['password1'] && $post_vars['password1'] === $create_user['user_pass'];
if ((is_multisite() && ($new__user_id = c_ws_plugin__s2member_registrations::ms_create_existing_user($create_user['user_login'], $create_user['user_email'], $create_user['user_pass'])) || ($new__user_id = wp_create_user($create_user['user_login'], $create_user['user_pass'], $create_user['user_email']))) && !is_wp_error($new__user_id)) {
update_user_option($new__user_id, 'default_password_nag', $has_custom_password ? FALSE : TRUE, TRUE);
if (version_compare(get_bloginfo("version"), "4.3.1", ">=")) {
wp_new_user_notification($new__user_id, null, $has_custom_password ? "admin" : "both", $create_user['user_pass']);
} else {
if (version_compare(get_bloginfo("version"), "4.3", ">=")) {
wp_new_user_notification($new__user_id, $has_custom_password ? "admin" : "both", $create_user['user_pass']);
} else {
wp_new_user_notification($new__user_id, $create_user['user_pass']);
}
}
if ($has_custom_password) {
$global_response = array('response' => sprintf(_x('<strong>Thank you.</strong> Please <a href="%s" rel="nofollow">log in</a>.', 's2member-front', 's2member'), esc_attr(wp_login_url())));
} else {
$global_response = array('response' => _x('<strong>Thank you.</strong> You\'ll receive an email momentarily.', 's2member-front', 's2member'));
}
if ($post_vars['attr']['success'] && substr($GLOBALS['ws_plugin__s2member_registration_return_url'], 0, 2) === substr($post_vars['attr']['success'], 0, 2) && ($custom_success_url = str_ireplace(array('%%s_response%%', '%%response%%'), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response['response'])), urlencode($global_response['response'])), $GLOBALS['ws_plugin__s2member_registration_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> A slight problem. Please contact Support for assistance.', 's2member-front', 's2member'), 'error' => TRUE);
}
} else {
// Input form field validation errors.
$global_response = $form_submission_validation_errors;
}
}
}
}
示例14: paypal_update
/**
* Handles processing of Pro Form billing updates.
*
* @package s2Member\PayPal
* @since 1.5
*
* @attaches-to ``add_action("init");``
*
* @return null Or exits script execution after a custom URL redirection.
*/
public static function paypal_update()
{
if (!empty($_POST["s2member_pro_paypal_update"]["nonce"]) && ($nonce = $_POST["s2member_pro_paypal_update"]["nonce"]) && wp_verify_nonce($nonce, "s2member-pro-paypal-update")) {
$GLOBALS["ws_plugin__s2member_pro_paypal_update_response"] = array();
// This holds the global response details.
$global_response =& $GLOBALS["ws_plugin__s2member_pro_paypal_update_response"];
// This is a shorter reference.
$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_paypal_update"]));
$post_vars["attr"] = unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars["attr"]));
// And run a Filter.
$post_vars["attr"] = apply_filters("ws_plugin__s2member_pro_paypal_update_post_attr", $post_vars["attr"], get_defined_vars());
$post_vars["recaptcha_challenge_field"] = !$post_vars["recaptcha_challenge_field"] ? trim(stripslashes($_POST["recaptcha_challenge_field"])) : $post_vars["recaptcha_challenge_field"];
$post_vars["recaptcha_response_field"] = !$post_vars["recaptcha_response_field"] ? trim(stripslashes($_POST["recaptcha_response_field"])) : $post_vars["recaptcha_response_field"];
if (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"];
}
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("update", $post_vars))) {
if ($post_vars["card_type"] === "PayPal") {
$global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
} else {
if (is_user_logged_in() && ($user = wp_get_current_user()) && ($user_id = $user->ID)) {
if ($cur__subscr_id = get_user_option("s2member_subscr_id")) {
if (($paypal = c_ws_plugin__s2member_pro_paypal_utilities::payflow_get_profile($cur__subscr_id)) && $paypal["TENDER"] !== "P" && preg_match("/^(Active|ActiveProfile)\$/i", $paypal["STATUS"])) {
$paypal = array();
// Reset the PayPal array.
$paypal["TRXTYPE"] = "R";
$paypal["ACTION"] = "M";
$paypal["ORIGPROFILEID"] = $cur__subscr_id;
$paypal["EMAIL"] = $user->user_email;
$paypal["FIRSTNAME"] = $user->first_name;
$paypal["LASTNAME"] = $user->last_name;
$paypal["TENDER"] = "C";
$paypal["ACCT"] = preg_replace("/[^0-9]/", "", $post_vars["card_number"]);
if (preg_match("/^(?P<month>[0-9]{2})\\/[0-9]{2}(?P<year_suffix>[0-9]{2})\$/", $post_vars["card_expiration"], $_m)) {
$paypal["EXPDATE"] = $_m["month"] . $_m["year_suffix"];
}
$paypal["CVV2"] = $post_vars["card_verification"];
if (in_array($post_vars["card_type"], array("Maestro", "Solo"))) {
if (preg_match("/^(?P<month>[0-9]{2})\\/[0-9]{2}(?P<year>[0-9]{2})\$/", $post_vars["card_start_date_issue_number"], $_m)) {
$paypal["CARDSTART"] = $_m["month"] . $_m["year"];
} else {
$paypal["CARDISSUE"] = $post_vars["card_start_date_issue_number"];
}
unset($_m);
}
$paypal["STREET"] = $post_vars["street"];
$paypal["CITY"] = $post_vars["city"];
$paypal["STATE"] = $post_vars["state"];
$paypal["COUNTRY"] = $post_vars["country"];
$paypal["ZIP"] = $post_vars["zip"];
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_payflow_api_response($paypal)) && empty($paypal["__error"])) {
$global_response = array("response" => _x('<strong>Confirmed.</strong> Your billing information has been updated.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__s2member_utils_encryption::encrypt($global_response["response"])), urlencode($global_response["response"])), $post_vars["attr"]["success"])) && ($custom_success_url = trim(preg_replace("/%%(.+?)%%/i", "", $custom_success_url)))) {
wp_redirect(c_ws_plugin__s2member_utils_urls::add_s2member_sig($custom_success_url, "s2p-v")) . exit;
}
} else {
$global_response = array("response" => $paypal["__error"], "error" => true);
}
} else {
if ($paypal && $paypal["TENDER"] !== "P" && !preg_match("/^(Active|ActiveProfile)\$/i", $paypal["STATUS"])) {
$global_response = array("response" => _x('<strong>Unable to update.</strong> You have NO recurring fees. Or, your billing profile is no longer active. Please contact Support if you need assistance.', "s2member-front", "s2member"), "error" => true);
} else {
if ($paypal && $paypal["TENDER"] === "P") {
$global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to update your billing information.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["paypal_sandbox"] ? "www.sandbox.paypal.com" : "www.paypal.com") . "/")), "error" => true);
} else {
$global_response = array("response" => _x('<strong>Unknown error.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
}
}
}
} else {
$global_response = array("response" => _x('<strong>No Subscr. ID.</strong> Please contact Support for assistance.', "s2member-front", "s2member"), "error" => true);
}
} else {
$global_response = array("response" => _x('You\'re <strong>NOT</strong> logged in.', "s2member-front", "s2member"), "error" => true);
}
}
} else {
$global_response = $error;
}
}
}
}
示例15: stripe_sp_checkout
/**
* 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;
}
}
}
//.........这里部分代码省略.........