本文整理汇总了PHP中c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number方法的典型用法代码示例。如果您正苦于以下问题:PHP c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number方法的具体用法?PHP c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number怎么用?PHP c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c_ws_plugin__s2member_paypal_utilities
的用法示例。
在下文中一共展示了c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cp
/**
* 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);
/* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */
/**/
if (!empty($paypal["txn_type"]) && preg_match("/^(subscr_failed|recurring_payment_failed|recurring_payment_skipped)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) {
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_failed", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __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 ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
/**/
$processing = $during = true;
/* Yes, we ARE processing this. */
/**/
$paypal["s2member_log"][] = "This `txn_type` does not require any action on the part of s2Member.";
$paypal["s2member_log"][] = "s2Member does NOT respond to individual failed payments, only multiple consecutive failed payments.";
$paypal["s2member_log"][] = "When multiple consecutive payments fail, a special IPN response will be triggered.";
/**/
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_failed", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __refs, __v. */
} else {
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_failed|recurring_payment_failed|recurring_payment_skipped` ).";
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
}
/**/
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_during_paypal_notify_after_subscr_failed", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __refs, __v. */
/**/
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", $paypal, get_defined_vars());
} else {
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_subscr_or_rp_payment_failed_w_level", false, get_defined_vars());
}
}
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:50,代码来源:paypal-notify-in-subscr-or-rp-payment-failed-w-level.inc.php
示例2: cp
/**
* 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);
/* Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``. */
/**/
if (!empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_created\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) {
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_during_paypal_notify_before_recurring_payment_profile_created", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __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 ( `recurring_payment_profile_created` ).";
/**/
$processing = $during = true;
/* Yes, we ARE processing this. */
/**/
$paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
$paypal["s2member_log"][] = "s2Member Pro handles this event on-site, with an IPN proxy.";
/**/
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_during_paypal_notify_during_recurring_payment_profile_created", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __refs, __v. */
} else {
$paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `recurring_payment_profile_created` ).";
$paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
}
/**/
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action("ws_plugin__s2member_during_paypal_notify_after_recurring_payment_profile_created", get_defined_vars());
unset($__refs, $__v);
/* Unset defined __refs, __v. */
/**/
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", $paypal, get_defined_vars());
} else {
return apply_filters("c_ws_plugin__s2member_paypal_notify_in_rec_profile_creation_w_level", false, get_defined_vars());
}
}
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:49,代码来源:paypal-notify-in-rec-profile-creation-w-level.inc.php
示例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'];
$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 ($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') {
if (preg_match('/^(Active|ActiveProfile)$/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['NAME'];
$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'] = !empty($paypal['DESC']) ? $paypal['DESC'] : $paypal['PROFILENAME'];
$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));
}
c_ws_plugin__s2member_pro_paypal_utilities::payflow_cancel_profile($paypal['PROFILEID'], !empty($paypal['BAID']) ? $paypal['BAID'] : '');
$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 {
if ($paypal && $paypal['TENDER'] === 'P') {
$global_response = array('response' => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to cancel your Subscription.', 's2member-front', 's2member'), esc_attr('https://' . ($GLOBALS['WS_PLUGIN__']['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: cp
/**
* 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("/^(subscr_payment|recurring_payment)\$/i", $paypal["txn_type"]) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))) && (!empty($paypal["subscr_baid"]) || ($paypal["subscr_baid"] = $paypal["subscr_id"])) && (!empty($paypal["subscr_cid"]) || ($paypal["subscr_cid"] = $paypal["subscr_id"])) && !empty($paypal["txn_id"]) && !empty($paypal["mc_gross"])) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_payment", 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 " . ($identified_as = "( `subscr_payment|recurring_payment` )") . ".";
if (empty($_REQUEST["s2member_paypal_proxy"])) {
$paypal["s2member_log"][] = "Sleeping for 5 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
sleep(5);
// Sleep here for a moment. PayPal sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
$paypal["s2member_log"][] = "Awake. It's " . date("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . ".";
}
list($paypal["level"], $paypal["ccaps"]) = 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 (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
$processing = $during = true;
// Yes, we ARE processing this.
$pr_times = get_user_option("s2member_paid_registration_times", $user_id);
$pr_times["level"] = !$pr_times["level"] ? time() : $pr_times["level"];
// Preserves existing.
$pr_times["level" . $paypal["level"]] = !$pr_times["level" . $paypal["level"]] ? time() : $pr_times["level" . $paypal["level"]];
update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
// Update now.
if (!get_user_option("s2member_first_payment_txn_id", $user_id)) {
// 1st payment?
update_user_option($user_id, "s2member_first_payment_txn_id", $paypal["txn_id"]);
}
update_user_option($user_id, "s2member_last_payment_time", time());
// Also update last payment time.
$paypal["s2member_log"][] = "Updated Payment Times for this Member.";
// Flag this action in the log.
$fields = get_user_option("s2member_custom_fields", $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
// Now merge conditionally.
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_urls"]) as $url) {
if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_id"])), $url))) {
if (($url = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_baid"])), $url)) && ($url = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_cid"])), $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("/%%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_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) {
if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) {
if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) {
if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) {
if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) {
if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
if (is_array($fields) && !empty($fields)) {
foreach ($fields as $var => $val) {
if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
break;
}
}
}
if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
c_ws_plugin__s2member_utils_urls::remote($url);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
$paypal["s2member_log"][] = "Payment Notification URLs have been processed.";
}
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["payment_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
$msg = $sbj = "(s2Member / API Notification Email) - Payment";
$msg .= "\n\n";
// Spacing in the message body.
$msg .= "subscr_id: %%subscr_id%%\n";
$msg .= "subscr_baid: %%subscr_baid%%\n";
//.........这里部分代码省略.........
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:101,代码来源:paypal-notify-in-subscr-or-rp-payment-w-level.inc.php
示例5: cp
/**
* 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);
// Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
if ((!empty($paypal["txn_type"]) && preg_match("/^new_case\$/i", $paypal["txn_type"]) && !empty($paypal["case_type"]) && preg_match("/^chargeback\$/i", $paypal["case_type"]) || !empty($paypal["payment_status"]) && preg_match("/^(refunded|reversed|reversal)\$/i", $paypal["payment_status"])) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["sp_access_item_number_regex"], $paypal["item_number"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"])) && !empty($paypal["payer_email"]) && !empty($paypal["parent_txn_id"])) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal", 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 ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).";
$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"];
$processing = $during = true;
// Yes, we ARE processing this.
/*
Refunds and chargeback reversals. This is excluded from the processing check.
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
*/
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_urls"]) as $url) {
if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["parent_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("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_gross"])), $url)) && ($url = preg_replace("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["mc_fee"])), $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 = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
c_ws_plugin__s2member_utils_urls::remote($url);
}
}
}
}
}
}
}
}
}
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.";
}
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sp_ref_rev_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
$msg = $sbj = "(s2Member / API Notification Email) - Specific Post/Page ~ Refund/Reversal";
$msg .= "\n\n";
// Spacing in the message body.
$msg .= "parent_txn_id: %%parent_txn_id%%\n";
$msg .= "item_number: %%item_number%%\n";
$msg .= "item_name: %%item_name%%\n";
$msg .= "-amount: %%-amount%%\n";
$msg .= "-fee: %%-fee%%\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 .= "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("/%%parent_txn_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["parent_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("/%%-amount%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_gross"]), $msg)) && ($msg = preg_replace("/%%-fee%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($paypal["mc_fee"]), $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 ($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_ref_rev_notification_recipients"]) as $recipient) {
wp_mail($recipient, apply_filters("ws_plugin__s2member_sp_ref_rev_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_sp_ref_rev_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8");
}
}
}
}
}
}
}
}
}
$paypal["s2member_log"][] = "Specific Post/Page ~ Refund/Reversal Notification Emails have been processed.";
//.........这里部分代码省略.........
示例6: 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"] = 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_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_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 ($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") {
if (preg_match("/^(Active|ActiveProfile)\$/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"] ? $paypal["DESC"] : $paypal["PROFILENAME"];
$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(site_url("/?s2member_paypal_notify=1"), $ipn, array("timeout" => 20));
}
c_ws_plugin__s2member_pro_paypal_utilities::payflow_cancel_profile($paypal["PROFILEID"], $paypal["BAID"]);
$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 {
if ($paypal && $paypal["TENDER"] === "P") {
$global_response = array("response" => sprintf(_x('Please <a href="%s" rel="nofollow">log in at PayPal</a> to cancel your Subscription.', "s2member-front", "s2member"), esc_attr("https://" . ($GLOBALS["WS_PLUGIN__"]["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_business"]))), "error" => true);
} else {
$global_response = array("response" => _x('<strong>Billing terminated.</strong> Your account has been cancelled.', "s2member-front", "s2member"));
if ($post_vars["attr"]["success"] && ($custom_success_url = str_ireplace(array("%%s_response%%", "%%response%%"), array(urlencode(c_ws_plugin__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;
}
}
}
}
示例7: cp
/**
* 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("/^(subscr_cancel|recurring_payment_profile_cancel|mp_cancel)\$/i", $paypal["txn_type"]) && !(preg_match("/^recurring_payment_profile_cancel\$/i", $paypal["txn_type"]) && !empty($paypal["initial_payment_status"]) && preg_match("/^failed\$/i", $paypal["initial_payment_status"])) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal)) || ($paypal["period1"] = "0 D")) && (!empty($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal))) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"]))) && (!empty($paypal["subscr_baid"]) || ($paypal["subscr_baid"] = $paypal["subscr_id"])) && (!empty($paypal["subscr_cid"]) || ($paypal["subscr_cid"] = $paypal["subscr_id"]))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_cancel", 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 ( `subscr_cancel|recurring_payment_profile_cancel|mp_cancel` ).";
list($paypal["level"], $paypal["ccaps"]) = 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 (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap("administrator")) {
$fields = get_user_option("s2member_custom_fields", $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
// Now merge conditionally.
if (!get_user_option("s2member_auto_eot_time", $user_id)) {
$processing = $during = true;
// Yes, we ARE processing this.
$auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time($user_id, $paypal["period1"], $paypal["period3"]);
update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
// s2Member follows-up later.
$paypal["s2member_log"][] = "Auto-EOT Time for this account: " . date("D M j, Y g:i a T", $auto_eot_time);
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_cancel", get_defined_vars());
unset($__refs, $__v);
} else {
$paypal["s2member_log"][] = "Ignoring Cancellation. An Auto-EOT Time is already set for this Member. An s2Member API Notification will still be processed however.";
}
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_urls"]) as $url) {
// Handle Cancellation Notifications.
if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim(@$cv[$1]))', $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_id"])), $url))) {
if (($url = preg_replace("/%%subscr_baid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_baid"])), $url)) && ($url = preg_replace("/%%subscr_cid%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal["subscr_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("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) {
if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) {
if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) {
if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) {
if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) {
if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
if (is_array($fields) && !empty($fields)) {
foreach ($fields as $var => $val) {
if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
break;
}
}
}
if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
c_ws_plugin__s2member_utils_urls::remote($url);
}
}
}
}
}
}
}
}
}
}
}
$paypal["s2member_log"][] = "Cancellation Notification URLs have been processed.";
}
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["cancellation_notification_recipients"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
$msg = $sbj = "(s2Member / API Notification Email) - Cancellation";
$msg .= "\n\n";
// Spacing in the message body.
$msg .= "subscr_id: %%subscr_id%%\n";
$msg .= "subscr_baid: %%subscr_baid%%\n";
$msg .= "subscr_cid: %%subscr_cid%%\n";
$msg .= "item_number: %%item_number%%\n";
$msg .= "item_name: %%item_name%%\n";
$msg .= "user_first_name: %%user_first_name%%\n";
$msg .= "user_last_name: %%user_last_name%%\n";
$msg .= "user_full_name: %%user_full_name%%\n";
$msg .= "user_email: %%user_email%%\n";
$msg .= "user_login: %%user_login%%\n";
$msg .= "user_ip: %%user_ip%%\n";
$msg .= "user_id: %%user_id%%\n";
if (is_array($fields) && !empty($fields)) {
foreach ($fields as $var => $val) {
$msg .= $var . ": %%" . $var . "%%\n";
//.........这里部分代码省略.........
开发者ID:adnandot,项目名称:intenseburn,代码行数:101,代码来源:paypal-notify-in-subscr-or-rp-cancellation-w-level.inc.php
示例8: cp
/**
* 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('/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)$/i', $paypal['txn_type']) && ($recurring = TRUE) || !empty($paypal['txn_type']) && preg_match('/^recurring_payment_profile_cancel$/i', $paypal['txn_type']) && !empty($paypal['initial_payment_status']) && preg_match('/^failed$/i', $paypal['initial_payment_status']) && ($recurring = TRUE) || !empty($paypal['txn_type']) && preg_match('/^new_case$/i', $paypal['txn_type']) && !empty($paypal['case_type']) && preg_match('/^chargeback$/i', $paypal['case_type']) && !($recurring = FALSE) || !empty($paypal['payment_status']) && preg_match('/^(refunded|reversed|reversal)$/i', $paypal['payment_status']) && !($recurring = FALSE)) && (!empty($paypal['subscr_id']) || ($paypal['subscr_id'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal)) || !empty($paypal['parent_txn_id']) && ($paypal['subscr_id'] = $paypal['parent_txn_id'])) && (!empty($paypal['period1']) || ($paypal['period1'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal, FALSE)) || empty($recurring) || ($paypal['period1'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('period1', FALSE, $paypal['subscr_id'])) || ($paypal['period1'] = '0 D')) && (!empty($paypal['period3']) || ($paypal['period3'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal, FALSE)) || empty($recurring) || ($paypal['period3'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('period3', FALSE, $paypal['subscr_id'])) || ($paypal['period3'] = '1 D')) && ((!empty($paypal['item_number']) || ($paypal['item_number'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal)) || ($paypal['item_number'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('item_number', FALSE, $paypal['subscr_id'])) || ($paypal['item_number'] = '1')) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['item_name']) || ($paypal['item_name'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal['item_name'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('item_name', FALSE, $paypal['subscr_id'])) || ($paypal['item_name'] = $_SERVER['HTTP_HOST'])) && (!empty($paypal['payer_email']) || ($paypal['payer_email'] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('payer_email', FALSE, $paypal['subscr_id'])) || ($paypal['payer_email'] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal['subscr_id']))) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_notify_before_subscr_eot', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
if (!get_transient($transient_ipn = 's2m_ipn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
$is_refund = preg_match('/^refunded$/i', $paypal['payment_status']) && !empty($paypal['parent_txn_id']);
$is_reversal = preg_match('/^(reversed|reversal)$/i', $paypal['payment_status']) && !empty($paypal['parent_txn_id']);
$is_reversal = !$is_reversal ? preg_match('/^new_case$/i', $paypal['txn_type']) && preg_match('/^chargeback$/i', $paypal['case_type']) : $is_reversal;
$is_refund_or_reversal = $is_refund || $is_reversal;
// If either of the previous tests above evaluated to true; then it's obviously a Refund and/or a Reversal.
$is_partial_refund = !$is_refund || !empty($paypal['mc_gross']) && ($original_txn_type = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('txn_type', FALSE, $paypal['subscr_id'])) === 'web_accept' && ($original_mc_gross = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var('mc_gross', FALSE, $paypal['subscr_id'])) <= abs($paypal['mc_gross']) ? FALSE : TRUE;
$is_delayed_eot = !$is_refund_or_reversal && preg_match('/^(subscr_eot|recurring_payment_expired)$/i', $paypal['txn_type']) && preg_match('/^I-/i', $paypal['subscr_id']);
if ($is_refund_or_reversal) {
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ' . ($identified_as = '( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` )') . '.';
} else {
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ' . ($identified_as = '( `subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment` ) - or - `recurring_payment_profile_cancel` w/ `initial_payment_status` ( `failed` )') . '.';
}
if (empty($_REQUEST['s2member_paypal_proxy'])) {
$paypal['s2member_log'][] = 'Sleeping for 15 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).';
sleep(15);
// Sleep here for a moment. PayPal sometimes sends a subscr_eot before the subscr_signup, subscr_modify.
$paypal['s2member_log'][] = 'Awake. It\'s ' . date('D M j, Y g:i:s a T') . '. s2Member `txn_type` identified as ' . $identified_as . '.';
}
$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 (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'])) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) {
$fields = get_user_option('s2member_custom_fields', $user_id);
// These will be needed below.
$user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
// Needed below.
$user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
if (!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option('s2member_auto_eot_time', $user_id) || $is_refund_or_reversal && $is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,partial_refunds,reversals' || $is_refund_or_reversal && !$is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,partial_refunds,reversals' || $is_refund_or_reversal && !$is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds,reversals' || $is_refund && !$is_partial_refund && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'refunds' || $is_reversal && $GLOBALS['WS_PLUGIN__']['s2member']['o']['triggers_immediate_eot'] === 'reversals') {
if (!$user->has_cap('administrator')) {
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['auto_eot_system_enabled']) {
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['membership_eot_behavior'] === 'demote') {
$processing = $during = TRUE;
// Yes, we ARE processing this.
$eot_del_type = $is_refund_or_reversal ? 'ipn-refund-reversal-demotion' : 'ipn-cancellation-expiration-demotion';
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role('subscriber');
$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote', get_defined_vars());
do_action('ws_plugin__s2member_during_collective_mods', $user_id, get_defined_vars(), $eot_del_type, 'modification', $demotion_role);
do_action('ws_plugin__s2member_during_collective_eots', $user_id, get_defined_vars(), $eot_del_type, 'modification');
unset($__refs, $__v);
// Housekeeping.
if ($existing_role !== $demotion_role) {
// Only if NOT the existing Role.
$user->set_role($demotion_role);
}
// Give User the demotion Role.
if (apply_filters('ws_plugin__s2member_remove_ccaps_during_eot_events', (bool) $GLOBALS['WS_PLUGIN__']['s2member']['o']['eots_remove_ccaps'] || $is_refund_or_reversal, get_defined_vars())) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match('/^access_s2member_ccap_/', $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
delete_user_option($user_id, 's2member_subscr_gateway');
delete_user_option($user_id, 's2member_subscr_id');
delete_user_option($user_id, 's2member_subscr_baid');
delete_user_option($user_id, 's2member_subscr_cid');
delete_user_option($user_id, 's2member_ipn_signup_vars');
if (!apply_filters('ws_plugin__s2member_preserve_paid_registration_times', TRUE)) {
delete_user_option($user_id, 's2member_paid_registration_times');
}
delete_user_option($user_id, 's2member_last_status_scan');
delete_user_option($user_id, 's2member_first_payment_txn_id');
delete_user_option($user_id, 's2member_last_payment_time');
delete_user_option($user_id, 's2member_last_auto_eot_time');
delete_user_option($user_id, 's2member_auto_eot_time');
delete_user_option($user_id, 's2member_file_download_access_log');
delete_user_option($user_id, 's2member_authnet_payment_failures');
update_user_option($user_id, 's2member_last_auto_eot_time', time());
c_ws_plugin__s2member_user_notes::append_user_notes($user_id, 'Demoted by s2Member: ' . date('D M j, Y g:i a T'));
c_ws_plugin__s2member_user_notes::append_user_notes($user_id, 'Paid Subscr. ID @ time of demotion: ' . $paypal['subscr_gateway'] . ' → ' . $paypal['subscr_id']);
$paypal['s2member_log'][] = 'Member Level/Capabilities demoted to: ' . ucwords(preg_replace('/_/', ' ', $demotion_role)) . '.';
if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls'] && is_array($cv = preg_split('/\\|/', $paypal['custom']))) {
//.........这里部分代码省略.........
示例9: cp
/**
* 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('/^new_case$/i', $paypal['txn_type']) && !empty($paypal['case_type']) && preg_match('/^chargeback$/i', $paypal['case_type']) || !empty($paypal['payment_status']) && preg_match('/^(refunded|reversed|reversal)$/i', $paypal['payment_status'])) && ((!empty($paypal['item_number']) || ($paypal['item_number'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['sp_access_item_number_regex'], $paypal['item_number'])) && (!empty($paypal['item_name']) || ($paypal['item_name'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal['item_name'] = $_SERVER['HTTP_HOST'])) && !empty($paypal['payer_email']) && !empty($paypal['parent_txn_id']) && (!empty($paypal['parent_txn_baid']) || ($paypal['parent_txn_baid'] = $paypal['parent_txn_id'])) && (!empty($paypal['parent_txn_cid']) || ($paypal['parent_txn_cid'] = $paypal['parent_txn_id']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_notify_before_sp_refund_reversal', 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 ( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` ).';
$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']);
$processing = $during = TRUE;
// Yes, we ARE processing this.
/*
Refunds and chargeback reversals. This is excluded from the processing check.
In other words, s2Member sends `Refund/Reversal` Notifications ANYTIME a Refund/Reversal occurs; even if s2Member did not process it otherwise.
Since this routine ignores the processing check, it is *possible* that Refund/Reversal Notification URLs will be contacted more than once.
If you're writing scripts that depend on Refund/Reversal Notifications, please keep this in mind.
*/
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_ref_rev_notification_urls']) {
foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_ref_rev_notification_urls']) as $url) {
if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%parent_txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['parent_txn_id'])), $url))) {
if (($url = preg_replace('/%%parent_txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['parent_txn_baid'])), $url)) && ($url = preg_replace('/%%parent_txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['parent_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('/%%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('/%%-fee%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['mc_fee'])), $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 = trim(preg_replace('/%%(.+?)%%/i', '', $url))) {
c_ws_plugin__s2member_utils_urls::remote($url);
}
}
}
}
}
}
}
}
}
}
}
$paypal['s2member_log'][] = 'Specific Post/Page ~ Refund/Reversal Notification URLs have been processed.';
}
if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['sp_ref_rev_notification_recipients']) {
$msg = $sbj = '(s2Member / API Notification Email) - Specific Post/Page ~ Refund/Reversal';
$msg .= "\n\n";
// Spacing in the message body.
$msg .= 'parent_txn_id: %%parent_txn_id%%' . "\n";
$msg .= 'parent_txn_baid: %%parent_txn_baid%%' . "\n";
$msg .= 'parent_txn_cid: %%parent_txn_cid%%' . "\n";
$msg .= 'item_number: %%item_number%%' . "\n";
$msg .= 'item_name: %%item_name%%' . "\n";
$msg .= 'currency: %%currency%%' . "\n";
$msg .= 'currency_symbol: %%currency_symbol%%' . "\n";
$msg .= '-amount: %%-amount%%' . "\n";
$msg .= '-fee: %%-fee%%' . "\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 .= '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('/%%parent_txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['parent_txn_id']), $msg))) {
if (($msg = preg_replace('/%%parent_txn_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['parent_txn_baid']), $msg)) && ($msg = preg_replace('/%%parent_txn_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['parent_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('/%%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('/%%-fee%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_fee']), $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 ($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) {
// Still have a ``$sbj`` and a ``$msg``?
//.........这里部分代码省略.........
示例10: cp
/**
* 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('/^(subscr_payment|recurring_payment|merch_pmt)$/i', $paypal['txn_type']) && ((!empty($paypal['item_number']) || ($paypal['item_number'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal))) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && (!empty($paypal['subscr_id']) || ($paypal['subscr_id'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal))) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && (!empty($paypal['item_name']) || ($paypal['item_name'] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal))) && (!empty($paypal['payer_email']) || ($paypal['payer_email'] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal['subscr_id']))) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id'])) && !empty($paypal['txn_id']) && !empty($paypal['mc_gross'])) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_notify_before_subscr_payment', 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 ' . ($identified_as = '( `subscr_payment|recurring_payment` )') . '.';
if (empty($_REQUEST['s2member_paypal_proxy'])) {
$paypal['s2member_log'][] = 'Sleeping for 15 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).';
sleep(15);
// Sleep here for a moment. PayPal sometimes sends a subscr_payment before the subscr_signup, subscr_modify.
$paypal['s2member_log'][] = 'Awake. It\'s ' . date('D M j, Y g:i:s a T') . '. s2Member `txn_type` identified as ' . $identified_as . '.';
}
list($paypal['level'], $paypal['ccaps']) = 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 (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
$processing = $during = TRUE;
// Yes, we ARE processing this.
$pr_times = get_user_option('s2member_paid_registration_times', $user_id);
$pr_times['level'] = !$pr_times['level'] ? time() : $pr_times['level'];
// Preserves existing.
$pr_times['level' . $paypal['level']] = !$pr_times['level' . $paypal['level']] ? time() : $pr_times['level' . $paypal['level']];
update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
// Update now.
if (!get_user_option('s2member_first_payment_txn_id', $user_id)) {
// 1st payment?
update_user_option($user_id, 's2member_first_payment_txn_id', $paypal['txn_id']);
}
update_user_option($user_id, 's2member_last_payment_time', time());
// Also update last payment time.
$paypal['s2member_log'][] = 'Updated Payment Times for this Member.';
// Flag this action in the log.
$fields = get_user_option('s2member_custom_fields', $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
// Now merge conditionally.
if ($processing && $GLOBALS['WS_PLUGIN__']['s2member']['o']['payment_notification_urls']) {
foreach (preg_split('/[' . "\r\n\t" . ']+/', $GLOBALS['WS_PLUGIN__']['s2member']['o']['payment_notification_urls']) as $url) {
if (($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $paypal['custom'], true)) && ($url = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['subscr_id'])), $url))) {
if (($url = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['subscr_baid'])), $url)) && ($url = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($paypal['subscr_cid'])), $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('/%%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_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) {
if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name . ' ' . $user->last_name))), $url)) {
if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url)) {
if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_login)), $url)) {
if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_reg_ip)), $url)) {
if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
if (is_array($fields) && !empty($fields)) {
foreach ($fields as $var => $val) {
if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
break;
}
}
}
if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) {
c_ws_plugin__s2member_utils_urls::remote($url);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
$paypal['s2member_log'][] = 'Payment Notification URLs have been processed.';
}
//.........这里部分代码省略.........
示例11: cp
/**
* 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("/^(subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment)\$/i", $paypal["txn_type"]) && ($recurring = true) || !empty($paypal["txn_type"]) && preg_match("/^recurring_payment_profile_cancel\$/i", $paypal["txn_type"]) && !empty($paypal["initial_payment_status"]) && preg_match("/^failed\$/i", $paypal["initial_payment_status"]) && ($recurring = true) || !empty($paypal["txn_type"]) && preg_match("/^new_case\$/i", $paypal["txn_type"]) && !empty($paypal["case_type"]) && preg_match("/^chargeback\$/i", $paypal["case_type"]) && !($recurring = false) || !empty($paypal["payment_status"]) && preg_match("/^(refunded|reversed|reversal)\$/i", $paypal["payment_status"]) && !($recurring = false)) && (!empty($paypal["subscr_id"]) || ($paypal["subscr_id"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_subscr_id($paypal)) || !empty($paypal["parent_txn_id"]) && ($paypal["subscr_id"] = $paypal["parent_txn_id"])) && (!empty($paypal["period1"]) || ($paypal["period1"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period1($paypal, false)) || empty($recurring) || ($paypal["period1"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period1", false, $paypal["subscr_id"])) || ($paypal["period1"] = "0 D")) && (!empty($paypal["period3"]) || ($paypal["period3"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_period3($paypal, false)) || empty($recurring) || ($paypal["period3"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("period3", false, $paypal["subscr_id"])) || ($paypal["period3"] = "1 D")) && ((!empty($paypal["item_number"]) || ($paypal["item_number"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_number($paypal)) || ($paypal["item_number"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("item_number", false, $paypal["subscr_id"])) || ($paypal["item_number"] = "1")) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["item_name"]) || ($paypal["item_name"] = c_ws_plugin__s2member_paypal_utilities::paypal_pro_item_name($paypal)) || ($paypal["item_name"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("item_name", false, $paypal["subscr_id"])) || ($paypal["item_name"] = $_SERVER["HTTP_HOST"])) && (!empty($paypal["payer_email"]) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("payer_email", false, $paypal["subscr_id"])) || ($paypal["payer_email"] = c_ws_plugin__s2member_utils_users::get_user_email_with($paypal["subscr_id"])))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_eot", 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)) {
$is_refund = preg_match("/^refunded\$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"];
$is_reversal = preg_match("/^(reversed|reversal)\$/i", $paypal["payment_status"]) && $paypal["parent_txn_id"];
$is_reversal = !$is_reversal ? preg_match("/^new_case\$/i", $paypal["txn_type"]) && preg_match("/^chargeback\$/i", $paypal["case_type"]) : $is_reversal;
$is_refund_or_reversal = $is_refund || $is_reversal;
// If either of the previous tests above evaluated to true; then it's obviously a Refund and/or a Reversal.
$is_partial_refund = !$is_refund || !empty($paypal["mc_gross"]) && ($original_txn_type = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("txn_type", FALSE, $paypal["subscr_id"])) === "web_accept" && ($original_mc_gross = c_ws_plugin__s2member_utils_users::get_user_ipn_signup_var("mc_gross", FALSE, $paypal["subscr_id"])) <= abs($paypal["mc_gross"]) ? FALSE : TRUE;
$is_delayed_eot = !$is_refund_or_reversal && preg_match("/^(subscr_eot|recurring_payment_expired)\$/i", $paypal["txn_type"]) && preg_match("/^I-/i", $paypal["subscr_id"]);
if ($is_refund_or_reversal) {
$paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `[empty or irrelevant]` ) w/ `payment_status` ( `refunded|reversed|reversal` ) - or - `new_case` w/ `case_type` ( `chargeback` )") . ".";
} else {
$paypal["s2member_log"][] = "s2Member `txn_type` identified as " . ($identified_as = "( `subscr_eot|recurring_payment_expired|recurring_payment_suspended_due_to_max_failed_payment` ) - or - `recurring_payment_profile_cancel` w/ `initial_payment_status` ( `failed` )") . ".";
}
if (empty($_REQUEST["s2member_paypal_proxy"])) {
$paypal["s2member_log"][] = "Sleeping for 10 seconds. Waiting for a possible ( `subscr_signup|subscr_modify|recurring_payment_profile_created` ).";
sleep(10);
// Sleep here for a moment. PayPal sometimes sends a subscr_eot before the subscr_signup, subscr_modify.
$paypal["s2member_log"][] = "Awake. It's " . date("D M j, Y g:i:s a T") . ". s2Member `txn_type` identified as " . $identified_as . ".";
}
$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 (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && !empty($user->ID)) {
$fields = get_user_option("s2member_custom_fields", $user_id);
// These will be needed below.
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
// Needed below.
$user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
if (!$is_refund_or_reversal && !$is_delayed_eot && !get_user_option("s2member_auto_eot_time", $user_id) || $is_refund_or_reversal && $is_partial_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,partial_refunds,reversals" || $is_refund_or_reversal && !$is_partial_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds,reversals" || $is_refund && !$is_partial_refund && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "refunds" || $is_reversal && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["triggers_immediate_eot"] === "reversals") {
if (!$user->has_cap("administrator")) {
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["auto_eot_system_enabled"]) {
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["membership_eot_behavior"] === "demote") {
$processing = $during = true;
// Yes, we ARE processing this.
$eot_del_type = $is_refund_or_reversal ? "ipn-refund-reversal-demotion" : "ipn-cancellation-expiration-demotion";
$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");
$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_during_subscr_eot_before_demote", get_defined_vars());
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), $eot_del_type, "modification", $demotion_role);
do_action("ws_plugin__s2member_during_collective_eots", $user_id, get_defined_vars(), $eot_del_type, "modification");
unset($__refs, $__v);
if ($existing_role !== $demotion_role) {
// Only if NOT the existing Role.
$user->set_role($demotion_role);
}
// Give User the demotion Role.
if (apply_filters("ws_plugin__s2member_remove_ccaps_during_eot_events", (bool) $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eots_remove_ccaps"] || $is_refund_or_reversal, get_defined_vars())) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match("/^access_s2member_ccap_/", $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
delete_user_option($user_id, "s2member_custom");
delete_user_option($user_id, "s2member_subscr_id");
delete_user_option($user_id, "s2member_subscr_baid");
delete_user_option($user_id, "s2member_subscr_gateway");
delete_user_option($user_id, "s2member_ipn_signup_vars");
if (!apply_filters("ws_plugin__s2member_preserve_paid_registration_times", true, get_defined_vars())) {
delete_user_option($user_id, "s2member_paid_registration_times");
}
delete_user_option($user_id, "s2member_last_status_scan");
delete_user_option($user_id, "s2member_first_payment_txn_id");
delete_user_option($user_id, "s2member_last_payment_time");
delete_user_option($user_id, "s2member_auto_eot_time");
delete_user_option($user_id, "s2member_file_download_access_log");
c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Demoted by s2Member: " . date("D M j, Y g:i a T"));
c_ws_plugin__s2member_user_notes::append_user_notes($user_id, "Paid Subscr. ID @ time of demotion: " . $paypal["subscr_gateway"] . " -› " . $paypal["subscr_id"]);
$paypal["s2member_log"][] = "Member Level/Capabilities demoted to: " . ucwords(preg_replace("/_/", " ", $demotion_role)) . ".";
if ($processing && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"] && is_array($cv = preg_split("/\\|/", $paypal["custom"]))) {
foreach (preg_split("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["eot_del_notification_urls"]) as $url) {
// Handle EOT Notifications.
if (($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) && ($url = preg_replace("/%%eot_del_type%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($eot_del_type)), $url)) && ($url = preg_replace("/%%subscr_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($paypal["subscr_id"])), $url))) {
if (($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->first_name)), $url)) && ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->last_name)), $url))) {
if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(trim($user->first_name . " " . $user->last_name))), $url)) {
if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->user_email)), $url)) {
if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user->user_login)), $url)) {
//.........这里部分代码省略.........
示例12: 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;
}
}
}
}