PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260917
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260917
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
← All changes | src/includes/classes/utilities.inc.php +19 -6 260805260917 View file →
@@ -151,9 +151,9 @@
151 151 public static function s_badge_gen($v = '1', $no_cache = FALSE, $display_on_failure = FALSE)
152 152 {
153 153 if($v && file_exists(($template = dirname(dirname(__FILE__)).'/templates/badges/s-badge.php')))
154 154 {
155 - switch((integer)$v) // Width/height based on variation.
155 + switch((int)$v) // Width/height based on variation.
156 156 {
157 157 case 1: // Variation number 1.
158 158
159 159 $width_height_attrs = 'width="200" height="55"';
@@ -182,9 +182,9 @@
182 182 break; // Break switch loop.
183 183 }
184 184 $badge = trim(c_ws_plugin__s2member_utilities::evl(file_get_contents($template)));
185 185
186 - $badge = preg_replace('/%%v%%/i', (string)(integer)$v, $badge);
186 + $badge = preg_replace('/%%v%%/i', (string)(int)$v, $badge);
187 187 $badge = preg_replace('/%%site_url%%/i', urlencode(home_url()), $badge);
188 188 $badge = preg_replace('/%%no_cache%%/i', $no_cache ? '&no_cache='.urlencode(mt_rand()) : '', $badge);
189 189 $badge = preg_replace('/%%display_on_failure%%/i', $display_on_failure ? '&display_on_failure=1' : '', $badge);
190 190 $badge = preg_replace(array('/%%width_height_attrs%%/i', '/%%width_height_styles%%/i'), array($width_height_attrs, $width_height_styles), $badge);
@@ -374,12 +374,13 @@
374 374 * @param string|bool $subscr_baid Previously captured `s2member_subscr_baid`.
375 375 * @param string|bool $subscr_cid Previously captured `s2member_subscr_cid`.
376 376 * @param array $ipn_signup_vars Previously captured signup/proxy vars for product-specific routing.
377 377 * @param bool $immediate Optional. If false, cancel at period end where supported.
378 + * @param string $reason Optional human-readable cancellation reason for APIs that accept one.
378 379 *
379 380 * @return bool True if a cancellation request was accepted; else false.
380 381 */
381 - public static function cancel_gateway_subscription($subscr_gateway = FALSE, $subscr_id = FALSE, $subscr_baid = FALSE, $subscr_cid = FALSE, $ipn_signup_vars = array(), $immediate = TRUE)
382 + public static function cancel_gateway_subscription($subscr_gateway = FALSE, $subscr_id = FALSE, $subscr_baid = FALSE, $subscr_cid = FALSE, $ipn_signup_vars = array(), $immediate = TRUE, $reason = '')
382 383 {
383 384 $subscr_gateway = strtolower((string)$subscr_gateway);
384 385 $subscr_id = (string)$subscr_id;
385 386 $subscr_baid = (string)$subscr_baid;
@@ -412,9 +413,10 @@
412 413 return (($authnet = c_ws_plugin__s2member_pro_authnet_utilities::authnet_arb_response(array('x_method' => 'cancel', 'x_subscription_id' => $subscr_id))) && empty($authnet['__error'])) ? TRUE : FALSE;
413 414
414 415 case 'paypal':
415 416 $paypal_proxy_use = (!empty($ipn_signup_vars['s2member_paypal_proxy_use'])) ? (string)$ipn_signup_vars['s2member_paypal_proxy_use'] : '';
416 - $try_ppco_first = ($paypal_proxy_use === 'paypal_checkout' || preg_match('/^I\-[A-Z0-9]+$/', $subscr_id));
417 + $paypal_invoice = (!empty($ipn_signup_vars['invoice'])) ? (string)$ipn_signup_vars['invoice'] : '';
418 + $ppco_hint = ($paypal_proxy_use === 'paypal_checkout' || strpos($paypal_invoice, 's2mpf-') === 0);
417 419 $can_try_ppco = FALSE;
418 420 $can_try_standard = FALSE;
419 421 $can_try_payflow = FALSE;
420 422
@@ -430,10 +432,21 @@
430 432 && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_payflow_api_vendor'])
431 433 && !empty($GLOBALS['WS_PLUGIN__']['s2member']['o']['paypal_payflow_api_password'])
432 434 && class_exists('c_ws_plugin__s2member_pro_paypal_utilities'));
433 435
434 - $paypal_routes = ($try_ppco_first) ? array('ppco', 'standard', 'payflow') : array('standard', 'ppco', 'payflow');
436 + //260819.0543 Use positive product provenance where available; I-* is ambiguous, while Payflow profile IDs use RP/RT prefixes.
437 + $payflow_hint = (bool)preg_match('/^R[PT]/i', $subscr_id);
438 + if($ppco_hint)
439 + $paypal_routes = array('ppco', 'standard', 'payflow');
440 + else if($payflow_hint)
441 + $paypal_routes = array('payflow', 'standard', 'ppco');
442 + else
443 + $paypal_routes = array('standard', 'ppco', 'payflow');
435 444
445 + $reason = trim((string)$reason);
446 + if(!$reason)
447 + $reason = 'Cancelled by replacement checkout.';
448 +
436 449 foreach($paypal_routes as $_paypal_route)
437 450 {
438 451 switch($_paypal_route)
439 452 {
@@ -440,9 +453,9 @@
440 453 case 'ppco':
441 454 if(!$can_try_ppco)
442 455 break;
443 456
444 - if(($paypal_checkout = c_ws_plugin__s2member_paypal_utilities::paypal_checkout_subscription_cancel($subscr_id, 'Cancelled by replacement checkout.'))
457 + if(($paypal_checkout = c_ws_plugin__s2member_paypal_utilities::paypal_checkout_subscription_cancel($subscr_id, $reason))
445 458 && !empty($paypal_checkout['code']) && ($paypal_checkout['code'] === 204 || ($paypal_checkout['code'] >= 200 && $paypal_checkout['code'] <= 299)))
446 459 return TRUE;
447 460 break;
448 461