Community Support Forums — WordPress® ( Users Helping Users ) — 2011-12-20T09:49:57-05:00 http://www.primothemes.com/forums/feed.php?f=40&t=13039 2011-12-20T09:49:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=57770#p57770 <![CDATA[s2Member v111220 / Source Code: s2member\i...]]>
s2Member v111220
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: December 20, 2011, 9:50 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — December 20th, 2011, 9:49 am


]]>
2011-12-07T01:03:05-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=55452#p55452 <![CDATA[s2Member v111206 / Source Code: s2member\i...]]>
s2Member v111206
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: December 7, 2011, 1:03 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — December 7th, 2011, 1:03 am


]]>
2011-11-05T19:26:02-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=51826#p51826 <![CDATA[s2Member v111105 / Source Code: s2member\i...]]>
s2Member v111105
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: November 5, 2011, 8:26 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — November 5th, 2011, 7:26 pm


]]>
2011-10-29T20:34:54-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=49921#p49921 <![CDATA[s2Member v111029 / Source Code: s2member\i...]]>
s2Member v111029
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: October 29, 2011, 9:35 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 29th, 2011, 8:34 pm


]]>
2011-10-17T15:39:04-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=47715#p47715 <![CDATA[s2Member v111017 / Source Code: s2member\i...]]>
s2Member v111017
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: October 17, 2011, 1:39 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 17th, 2011, 3:39 pm


]]>
2011-10-11T14:34:57-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=46115#p46115 <![CDATA[s2Member v111011 / Source Code: s2member\i...]]>
s2Member v111011
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: October 11, 2011, 12:35 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 11th, 2011, 2:34 pm


]]>
2011-10-03T15:47:21-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=44246#p44246 <![CDATA[s2Member v111003 / Source Code: s2member\i...]]>
s2Member v111003
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: October 3, 2011, 1:47 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 3rd, 2011, 3:47 pm


]]>
2011-10-03T03:40:51-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=42953#p42953 <![CDATA[s2Member v111002 / Source Code: s2member\i...]]>
s2Member v111002
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: October 3, 2011, 1:40 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — October 3rd, 2011, 3:40 am


]]>
2011-09-27T05:26:13-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=41199#p41199 <![CDATA[s2Member v110927 / Source Code: s2member\i...]]>
s2Member v110927
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: September 27, 2011, 3:26 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 27th, 2011, 5:26 am


]]>
2011-09-26T21:03:05-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=39955#p39955 <![CDATA[s2Member v110926 / Source Code: s2member\i...]]>
s2Member v110926
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: September 26, 2011, 7:03 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 26th, 2011, 9:03 pm


]]>
2011-09-17T16:20:12-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=38099#p38099 <![CDATA[s2Member v110915 / Source Code: s2member\i...]]>
s2Member v110915
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: September 17, 2011, 2:20 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 17th, 2011, 4:20 pm


]]>
2011-09-14T01:27:43-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=36680#p36680 <![CDATA[s2Member v110913 / Source Code: s2member\i...]]>
s2Member v110913
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: September 13, 2011, 11:27 pm

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 14th, 2011, 1:27 am


]]>
2011-09-13T12:02:46-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=35408#p35408 <![CDATA[s2Member v110912 / Source Code: s2member\i...]]>
s2Member v110912
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: September 13, 2011, 10:02 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — September 13th, 2011, 12:02 pm


]]>
2011-08-15T14:13:05-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=31515#p31515 <![CDATA[s2Member v111220 / Source Code: s2member\i...]]>
s2Member v111220
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: December 20, 2011, 9:50 am

Open for public discussion.
(!-- s-words :: --)n/a(!-- :: s-words --)

Statistics: Posted by System Robot — August 15th, 2011, 2:13 pm


]]>
2011-07-11T17:28:55-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=27702#p27702 <![CDATA[s2Member v110710 / Source Code: s2member\i...]]>
s2Member v110710
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: July 11, 2011, 6:28 pm

Open for public discussion.
(!-- s-words :: --)Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Source Code jQuery(window).load(function(){ if(typeof location.hash === 'string' && location.hash.match(/^#/)) jQuery('olli'+location.hash).addClass('hilite'); }); jQuery(window).bind('hashchange', function(){ if(typeof location.hash === 'string' && location.hash.match(/^#/)) jQuery('olli').removeClass('hilite'); jQuery('olli'+location.hash).addClass('hilite'); }); [ full view ]s2member\includes\classes\paypal-utilities.inc.php ?php /** * PayPal® utilities. * * Copyright: © 2009-2011 * {@link http://www.websharks-inc.com/ WebSharks, Inc.} * ( coded in the USA ) * * Released under the terms of the GNU General Public License. * You should have received a copy of the GNU General Public License, * along with this software. In the main directory, see: /licensing/ * If not, see: {@link http://www.gnu.org/licenses/}. * * @package s2Member\PayPal * @since 3.5 */ if ( realpath ( __FILE__ ) === realpath ( $_SERVER [ "SCRIPT_FILENAME" ] ) ) exit ( "Do not access this file directly." ) ; /**/ if ( ! class_exists ( "c_ws_plugin__s2member_paypal_utilities" ) ) { /** * PayPal® utilities. * * @package s2Member\PayPal * @since 3.5 */ class c_ws_plugin__s2member_paypal_utilities { /** * Get ``$_POST`` or ``$_REQUEST`` vars from PayPal®. * * @package s2Member\PayPal * @since 3.5 * * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false. */ public static function paypal_postvars ( ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_postvars" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /* Custom conditionals can be applied by filters. */ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; if ( ! ( $postvars = apply_filters ( "ws_plugin__s2member_during_paypal_postvars_conditionals" , array ( ) , get_defined_vars ( ) ) ) ) { unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( ! empty ( $_GET [ "tx" ] ) && empty ( $_GET [ "s2member_paypal_proxy" ] ) ) { $postback [ "tx" ] = $_GET [ "tx" ] ; $postback [ "cmd" ] = "_notify-synch" ; $postback [ "at" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_identity_token" ] ; /**/ $endpoint = ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_sandbox" ] ) ? "www.sandbox.paypal.com" : "www.paypal.com" ; /**/ if ( preg_match ( "/^SUCCESS/i" , ( $response = trim (c_ws_plugin__s2member_utils_urls:: remote ( "https://" . $endpoint . "/cgi-bin/webscr" , $postback , array ( "timeout" = 20 ) ) ) ) ) ) { foreach ( preg_split ( "/[\r \n]+/" , preg_replace ( "/^SUCCESS/i" , "" , $response ) ) as $varline ) { list ( $key , $value ) = preg_split ( "/\=/" , $varline , 2 ) ; if ( strlen ( $key = trim ( $key ) ) && strlen ( $value = trim ( $value ) ) ) $postvars [ $key ] = trim ( stripslashes ( urldecode ( $value ) ) ) ; } /**/ return apply_filters ( "ws_plugin__s2member_paypal_postvars" , $postvars , get_defined_vars ( ) ) ; } else /* Nope. */ return false ; } else if ( ! empty ( $_REQUEST ) && is_array ( $postvars = stripslashes_deep ( $_REQUEST ) ) ) { foreach ( $postvars as $key = $value ) if ( preg_match ( "/^s2member_/" , $key ) ) unset ( $postvars [ $key ] ) ; /**/ $postback = $postvars ; /* Copy. */ $postback [ "cmd" ] = "_notify-validate" ; /**/ $postvars = c_ws_plugin__s2member_utils_strings:: trim_deep ( $postvars ) ; /**/ $endpoint = ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_sandbox" ] ) ? "www.sandbox.paypal.com" : "www.paypal.com" ; /**/ if ( ! empty ( $_GET [ "s2member_paypal_proxy" ] ) && ! empty ( $_GET [ "s2member_paypal_proxy_verification" ] ) && $_GET [ "s2member_paypal_proxy_verification" ] === c_ws_plugin__s2member_paypal_utilities:: paypal_proxy_key_gen ( ) ) return apply_filters ( "ws_plugin__s2member_paypal_postvars" , array_merge ( $postvars , array ( "proxy_verified" = $_GET [ "s2member_paypal_proxy" ] ) ) , get_defined_vars ( ) ) ; /**/ else if ( trim ( strtolower (c_ws_plugin__s2member_utils_urls:: remote ( "https://" . $endpoint . "/cgi-bin/webscr" , $postback , array ( "timeout" = 20 ) ) ) ) === "verified" ) return apply_filters ( "ws_plugin__s2member_paypal_postvars" , $postvars , get_defined_vars ( ) ) ; /**/ else /* Nope. */ return false ; } else /* Nope. */ return false ; } else /* Else a custom conditional has been applied by Filters. */ { unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ return apply_filters ( "ws_plugin__s2member_paypal_postvars" , $postvars , get_defined_vars ( ) ) ; } } /** * Generates a PayPal® Proxy Key, for simulated IPN responses. * * @package s2Member\PayPal * @since 3.5 * * @return str A Proxy Key. It's an MD5 Hash, 32 chars, URL-safe. */ public static function paypal_proxy_key_gen ( ) /* Generate Key. */ { global $current_site , $current_blog ; /* Multisite Networking. */ /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_proxy_key_gen" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_multisite ( ) && ! is_main_site ( ) ) $key = md5 (c_ws_plugin__s2member_utils_encryption:: xencrypt ( $current_blog - domain . $current_blog - path ) ) ; /**/ else /* Else it's a standard Proxy Key; not on a Multisite Network, or not on the Main Site anyway. */ $key = md5 (c_ws_plugin__s2member_utils_encryption:: xencrypt ( preg_replace ( "/\:[0-9]+$/" , "" , $_SERVER [ "HTTP_HOST" ] ) ) ) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_proxy_key_gen" , $key , get_defined_vars ( ) ) ; } /** * Calls upon the PayPal® API, and returns the response. * * @package s2Member\PayPal * @since 3.5 * * @param array $post_vars An array of variables to send through the PayPal® API call. * @return array An array of variables returned by the PayPal® API. * * @todo Optimize this routine with ``empty()`` and ``isset()``. */ public static function paypal_api_response ( $post_vars = FALSE ) { global $current_site , $current_blog ; /* For Multisite support. */ /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_api_response" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $url = "https://" . ( ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_sandbox" ] ) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com" ) . "/nvp" ; /**/ $post_vars = apply_filters ( "ws_plugin__s2member_paypal_api_post_vars" , $post_vars , get_defined_vars ( ) ) ; $post_vars = ( is_array ( $post_vars ) ) ? $post_vars : array ( ) ; /* Must be an array. */ /**/ $post_vars [ "VERSION" ] = "71.0" ; /* Configure the PayPal® API version. */ $post_vars [ "USER" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_api_username" ] ; $post_vars [ "PWD" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_api_password" ] ; $post_vars [ "SIGNATURE" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_api_signature" ] ; /**/ $input_time = date ( "D M j, Y g:i:s a T" ) ; /* Record input/nvp for logging. */ /**/ $nvp = trim (c_ws_plugin__s2member_utils_urls:: remote ( $url , $post_vars , array ( "timeout" = 20 ) ) ) ; /**/ $output_time = date ( "D M j, Y g:i:s a T" ) ; /* Now record after output time. */ /**/ wp_parse_str ( $nvp , $response ) ; /* Parse NVP response. */ $response = c_ws_plugin__s2member_utils_strings:: trim_deep ( stripslashes_deep ( $response ) ) ; /**/ if ( ! $response [ "ACK" ] || ! preg_match ( "/^(Success|SuccessWithWarning)$/i" , $response [ "ACK" ] ) ) { if ( strlen ( $response [ "L_ERRORCODE0" ] ) || $response [ "L_SHORTMESSAGE0" ] || $response [ "L_LONGMESSAGE0" ] ) /* Did we at least get an error msg? */ $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". " . rtrim ( $response [ "L_SHORTMESSAGE0" ] , "." ) . ". " . rtrim ( $response [ "L_LONGMESSAGE0" ] , "." ) . "." ; /**/ else /* Else, generate an error messsage - so something is reported back to the Customer. */ $response [ "__error" ] = "Error. Please contact Support for assistance." ; } /* If debugging is enabled; we need to maintain a comprehensive log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__s2member_utilities:: ver_details ( ) ; $log4 = $_SERVER [ "HTTP_HOST" ] . $_SERVER [ "REQUEST_URI" ] . "\nUser-Agent: " . $_SERVER [ "HTTP_USER_AGENT" ] ; $log4 = ( is_multisite ( ) && ! is_main_site ( ) ) ? ( $_log4 = $current_blog - domain . $current_blog - path ) . "\n" . $log4 : $log4 ; $log2 = ( is_multisite ( ) && ! is_main_site ( ) ) ? "paypal-api-4-" . trim ( preg_replace ( "/[^a-z0-9]/i" , "-" , $_log4 ) , "-" ) . ".log" : "paypal-api.log" ; /**/ if ( isset ( $post_vars [ "ACCT" ] ) && strlen ( $post_vars [ "ACCT" ] ) 4 ) $post_vars [ "ACCT" ] = str_repeat ( "*" , strlen ( $post_vars [ "ACCT" ] ) - 4 ) . substr ( $post_vars [ "ACCT" ] , - 4 ) ; /**/ if ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "gateway_debug_logs" ] ) if ( is_dir ( $logs_dir = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "c" ] [ "logs_dir" ] ) ) if ( is_writable ( $logs_dir ) && c_ws_plugin__s2member_utils_logs:: archive_oversize_log_files ( ) ) if ( ( $log = "-------- Input vars: ( " . $input_time . " ) --------\n" . var_export ( $post_vars , true ) . "\n" ) ) if ( ( $log .= "-------- Output string/vars: ( " . $output_time . " ) --------\n" . $nvp . "\n" . var_export ( $response , true ) ) ) file_put_contents ( $logs_dir . "/" . $log2 , $logv . "\n" . $log4 . "\n" . $log . "\n \n" , FILE_APPEND) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_api_response" , c_ws_plugin__s2member_paypal_utilities::_paypal_api_response_filters ( $response ) , get_defined_vars ( ) ) ; } /** * A sort of callback function that Filters PayPal® responses. * * Provides alternative explanations in some cases that require special attention. * * @package s2Member\PayPal * @since 3.5 * * @param array $response Expects an array of response variables returned by the PayPal® API. * @return array An array of variables returned by the PayPal® API, after ``$response["__error"]`` is Filtered. */ public static function _paypal_api_response_filters ( $response = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "_ws_plugin__s2member_before_paypal_api_response_filters" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( ! empty ( $response [ "__error" ] ) && ! empty ( $response [ "L_ERRORCODE0" ] ) ) { if ( $response [ "L_ERRORCODE0" ] == 10422 ) $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". Transaction declined. Please use an alternate funding source." ; /**/ else if ( $response [ "L_ERRORCODE0" ] == 10435 ) $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". Transaction declined. Express Checkout was NOT confirmed." ; /**/ else if ( $response [ "L_ERRORCODE0" ] == 10417 ) $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". Transaction declined. Please use an alternate funding source." ; } /**/ return $response ; /* Filters already applied with: ``ws_plugin__s2member_paypal_api_response``. */ } /** * Converts a term `D|W|M|Y` into PayPal® Pro format. * * @package s2Member\PayPal * @since 3.5 * * @param str $term Expects one of `D|W|M|Y`. * @return bool|str A full singular description of the term *( i.e. `Day|Week|Month|Year` )*, else false. */ public static function paypal_pro_term ( $term = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_term" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $paypal_pro_terms = array ( "D" = "Day" , "W" = "Week" , "M" = "Month" , "Y" = "Year" ) ; /**/ $pro_term = ( ! empty ( $paypal_pro_terms [ strtoupper ( $term ) ] ) ) ? $paypal_pro_terms [ strtoupper ( $term ) ] : false ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_term" , $pro_term , get_defined_vars ( ) ) ; } /** * Converts a term `Day|Week|Month|Year` into PayPal® Standard format. * * @package s2Member\PayPal * @since 3.5 * * @param str $term Expects one of `Day|Week|Month|Year`. * @return bool|str A term code *( i.e. `D|W|M|Y` )*, else false. */ public static function paypal_std_term ( $term = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_std_term" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $paypal_std_terms = array ( "DAY" = "D" , "WEEK" = "W" , "MONTH" = "M" , "YEAR" = "Y" ) ; /**/ $std_term = ( ! empty ( $paypal_std_terms [ strtoupper ( $term ) ] ) ) ? $paypal_std_terms [ strtoupper ( $term ) ] : false ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_std_term" , $std_term , get_defined_vars ( ) ) ; } /** * Get `subscr_id` from either an array with `recurring_payment_id|subscr_id`, or use an existing string. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * @return str|bool A `subscr_id` string if non-empty, else false. */ public static function paypal_pro_subscr_id ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_subscr_id" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "recurring_payment_id" ] ) ) $subscr_id = trim ( $array [ "recurring_payment_id" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "subscr_id" ] ) ) $subscr_id = trim ( $array [ "subscr_id" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $subscr_id = trim ( $string ) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_subscr_id" , ( ( ! empty ( $subscr_id ) ) ? $subscr_id : false ) , get_defined_vars ( ) ) ; } /** * Get `item_number` from either an array with `PROFILEREFERENCE|rp_invoice_id|item_number1|item_number`, or use an existing string. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * If it's a string, we make sure it is a valid `level:ccaps:eotper` or `sp:ids:expiration` combination. * @return str|bool An `item_number` string if non-empty, else false. */ public static function paypal_pro_item_number ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_item_number" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ( ! empty ( $array [ "PROFILEREFERENCE" ] ) || ! empty ( $array [ "rp_invoice_id" ] ) ) ) list ( $_reference , $_domain , $_item_number ) = array_map ( "trim" , preg_split ( "/~/" , ( ( ! empty ( $array [ "PROFILEREFERENCE" ] ) ) ? $array [ "PROFILEREFERENCE" ] : $array [ "rp_invoice_id" ] ) , 3 ) ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_number1" ] ) ) $_item_number = trim ( $array [ "item_number1" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_number" ] ) ) $_item_number = trim ( $array [ "item_number" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $_item_number = trim ( $string ) ; /**/ if ( ! empty ( $_item_number ) && preg_match ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "c" ] [ "membership_item_number_regex" ] , $_item_number ) ) $item_number = $_item_number ; /**/ else if ( ! empty ( $_item_number ) && preg_match ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "c" ] [ "sp_access_item_number_regex" ] , $_item_number ) ) $item_number = $_item_number ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_item_number" , ( ( ! empty ( $item_number ) ) ? $item_number : false ) , get_defined_vars ( ) ) ; } /** * Get `item_name` from either an array with `product_name|item_name1|item_name`, or use an existing string. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * @return str|bool An `item_name` string if non-empty, else false. */ public static function paypal_pro_item_name ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_item_name" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "product_name" ] ) ) $item_name = trim ( $array [ "product_name" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_name1" ] ) ) $item_name = trim ( $array [ "item_name1" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_name" ] ) ) $item_name = trim ( $array [ "item_name" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $item_name = trim ( $string ) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_item_name" , ( ( ! empty ( $item_name ) ) ? $item_name : false ) , get_defined_vars ( ) ) ; } /** * Get `period1` from either an array with `PROFILEREFERENCE|rp_invoice_id|period1`, or use an existing string. * * This will also convert `1 Day`, into `1 D`, and so on. * This will also convert `1 SemiMonth`, into `2 W`, and so on. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * If it's a string, we make sure it is a valid `period term` combination. * @return str A `period1` string if possible, or defaults to `0 D`. */ public static function paypal_pro_period1 ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_period1" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ( ! empty ( $array [ "PROFILEREFERENCE" ] ) || ! empty ( $array [ "rp_invoice_id" ] ) ) ) { list ( $_reference , $_domain , $_item_number ) = array_map ( "trim" , preg_split ( "/~/" , ( ( ! empty ( $array [ "PROFILEREFERENCE" ] ) ) ? $array [ "PROFILEREFERENCE" ] : $array [ "rp_invoice_id" ] ) , 3 ) ) ; list ( $_start_time , $_period1 , $_period3 ) = array_map ( "trim" , preg_split ( "/\:/" , $_reference , 3 ) ) ; } else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "period1" ] ) ) $_period1 = trim ( $array [ "period1" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $_period1 = trim ( $string ) ; /**/ if ( ! empty ( $_period1 ) ) /* Were we able to get a `period1` string? */ { list ( $num , $span ) = array_map ( "trim" , preg_split ( "/ /" , $_period1 , 2 ) ) ; /**/ if ( strtoupper ( $span ) === "SEMIMONTH" ) if ( is_numeric ( $num ) && $num = 1 ) eval ( '$num = "2"; $span = "W";' ) ; /**/ if ( strlen ( $span ) !== 1 ) /* To Standard format. */ $span = c_ws_plugin__s2member_paypal_utilities:: paypal_std_term ( $span ) ; /**/ $span = ( preg_match ( "/^[DWMY]$/i" , $span ) ) ? $span : "" ; $num = ( $span && is_numeric ( $num ) && $num = 0 ) ? $num : "" ; /**/ $period1 = ( $num && $span ) ? $num . " " . strtoupper ( $span ) : "0 D" ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_period1" , $period1 , get_defined_vars ( ) ) ; } else /* Default. */ return apply_filters ( "ws_plugin__s2member_paypal_pro_period1" , "0 D" , get_defined_vars ( ) ) ; } /** * Get `period3` from either an array with `PROFILEREFERENCE|rp_invoice_id|period3`, or use an existing string. * * This will also convert `1 Day`, into `1 D`, and so on. * This will also convert `1 SemiMonth`, into `2 W`, and so on. * The Regular Period can never be less than 1 day ( `1 D` ). * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * If it's a string, we make sure it is a valid `period term` combination. * @return str A `period3` string if possible, or defaults to `1 D`. */ public static function paypal_pro_period3 ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_period3" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ( ! empty ( $array [ "PROFILEREFERENCE" ] ) || ! empty ( $array [ "rp_invoice_id" ] ) ) ) { list ( $_reference , $_domain , $_item_number ) = array_map ( "trim" , preg_split ( "/~/" , ( ( ! empty ( $array [ "PROFILEREFERENCE" ] ) ) ? $array [ "PROFILEREFERENCE" ] : $array [ "rp_invoice_id" ] ) , 3 ) ) ; list ( $_start_time , $_period1 , $_period3 ) = array_map ( "trim" , preg_split ( "/\:/" , $_reference , 3 ) ) ; } else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "period3" ] ) ) $_period3 = trim ( $array [ "period3" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $_period3 = trim ( $string ) ; /**/ if ( ! empty ( $_period3 ) ) /* Were we able to get a `period3` string? */ { list ( $num , $span ) = array_map ( "trim" , preg_split ( "/ /" , $_period3 , 2 ) ) ; /**/ if ( strtoupper ( $span ) === "SEMIMONTH" ) if ( is_numeric ( $num ) && $num = 1 ) eval ( '$num = "2"; $span = "W";' ) ; /**/ if ( strlen ( $span ) !== 1 ) /* To Standard format. */ $span = c_ws_plugin__s2member_paypal_utilities:: paypal_std_term ( $span ) ; /**/ $span = ( preg_match ( "/^[DWMY]$/i" , $span ) ) ? $span : "" ; $num = ( $span && is_numeric ( $num ) && $num = 0 ) ? $num : "" ; /**/ $period3 = ( $num && $span ) ? $num . " " . strtoupper ( $span ) : "1 D" ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_period3" , $period3 , get_defined_vars ( ) ) ; } else /* Default. */ return apply_filters ( "ws_plugin__s2member_paypal_pro_period3" , "1 D" , get_defined_vars ( ) ) ; } } } ? [ full view ]s2member\includes\classes\paypal-utilities.inc.php Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Source Code(!-- :: s-words --)

Statistics: Posted by System Robot — July 11th, 2011, 5:28 pm


]]>
2011-07-09T06:08:54-05:00 http://www.primothemes.com/forums/viewtopic.php?t=13039&p=25334#p25334 <![CDATA[s2Member v110815 / Source Code: s2member\i...]]>
s2Member v110815
Source Code: s2member\includes\classes\paypal-utilities.inc.php
Docs updated: August 15, 2011, 3:13 pm

Open for public discussion.
(!-- s-words :: --)Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Source Code jQuery(window).load(function(){ if(typeof location.hash === 'string' && location.hash.match(/^#/)) jQuery('olli'+location.hash).addClass('hilite'); }); jQuery(window).bind('hashchange', function(){ if(typeof location.hash === 'string' && location.hash.match(/^#/)) jQuery('olli').removeClass('hilite'); jQuery('olli'+location.hash).addClass('hilite'); }); [ full view ]s2member\includes\classes\paypal-utilities.inc.php ?php /** * PayPal® utilities. * * Copyright: © 2009-2011 * {@link http://www.websharks-inc.com/ WebSharks, Inc.} * ( coded in the USA ) * * Released under the terms of the GNU General Public License. * You should have received a copy of the GNU General Public License, * along with this software. In the main directory, see: /licensing/ * If not, see: {@link http://www.gnu.org/licenses/}. * * @package s2Member\PayPal * @since 3.5 */ if ( realpath ( __FILE__ ) === realpath ( $_SERVER [ "SCRIPT_FILENAME" ] ) ) exit ( "Do not access this file directly." ) ; /**/ if ( ! class_exists ( "c_ws_plugin__s2member_paypal_utilities" ) ) { /** * PayPal® utilities. * * @package s2Member\PayPal * @since 3.5 */ class c_ws_plugin__s2member_paypal_utilities { /** * Get ``$_POST`` or ``$_REQUEST`` vars from PayPal®. * * @package s2Member\PayPal * @since 3.5 * * @return array|bool An array of verified ``$_POST`` or ``$_REQUEST`` variables, else false. */ public static function paypal_postvars ( ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_postvars" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /* Custom conditionals can be applied by filters. */ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; if ( ! ( $postvars = apply_filters ( "ws_plugin__s2member_during_paypal_postvars_conditionals" , array ( ) , get_defined_vars ( ) ) ) ) { unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( ! empty ( $_GET [ "tx" ] ) && empty ( $_GET [ "s2member_paypal_proxy" ] ) ) { $postback [ "tx" ] = $_GET [ "tx" ] ; $postback [ "cmd" ] = "_notify-synch" ; $postback [ "at" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_identity_token" ] ; /**/ $endpoint = ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_sandbox" ] ) ? "www.sandbox.paypal.com" : "www.paypal.com" ; /**/ if ( preg_match ( "/^SUCCESS/i" , ( $response = trim (c_ws_plugin__s2member_utils_urls:: remote ( "https://" . $endpoint . "/cgi-bin/webscr" , $postback , array ( "timeout" = 20 ) ) ) ) ) ) { foreach ( preg_split ( "/[\r \n]+/" , preg_replace ( "/^SUCCESS/i" , "" , $response ) ) as $varline ) { list ( $key , $value ) = preg_split ( "/\=/" , $varline , 2 ) ; if ( strlen ( $key = trim ( $key ) ) && strlen ( $value = trim ( $value ) ) ) $postvars [ $key ] = trim ( stripslashes ( urldecode ( $value ) ) ) ; } /**/ return apply_filters ( "ws_plugin__s2member_paypal_postvars" , $postvars , get_defined_vars ( ) ) ; } else /* Nope. */ return false ; } else if ( ! empty ( $_REQUEST ) && is_array ( $postvars = stripslashes_deep ( $_REQUEST ) ) ) { foreach ( $postvars as $key = $value ) if ( preg_match ( "/^s2member_/" , $key ) ) unset ( $postvars [ $key ] ) ; /**/ $postback = $postvars ; /* Copy. */ $postback [ "cmd" ] = "_notify-validate" ; /**/ $postvars = c_ws_plugin__s2member_utils_strings:: trim_deep ( $postvars ) ; /**/ $endpoint = ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_sandbox" ] ) ? "www.sandbox.paypal.com" : "www.paypal.com" ; /**/ if ( ! empty ( $_GET [ "s2member_paypal_proxy" ] ) && ! empty ( $_GET [ "s2member_paypal_proxy_verification" ] ) && $_GET [ "s2member_paypal_proxy_verification" ] === c_ws_plugin__s2member_paypal_utilities:: paypal_proxy_key_gen ( ) ) return apply_filters ( "ws_plugin__s2member_paypal_postvars" , array_merge ( $postvars , array ( "proxy_verified" = $_GET [ "s2member_paypal_proxy" ] ) ) , get_defined_vars ( ) ) ; /**/ else if ( trim ( strtolower (c_ws_plugin__s2member_utils_urls:: remote ( "https://" . $endpoint . "/cgi-bin/webscr" , $postback , array ( "timeout" = 20 ) ) ) ) === "verified" ) return apply_filters ( "ws_plugin__s2member_paypal_postvars" , $postvars , get_defined_vars ( ) ) ; /**/ else /* Nope. */ return false ; } else /* Nope. */ return false ; } else /* Else a custom conditional has been applied by Filters. */ { unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ return apply_filters ( "ws_plugin__s2member_paypal_postvars" , $postvars , get_defined_vars ( ) ) ; } } /** * Generates a PayPal® Proxy Key, for simulated IPN responses. * * @package s2Member\PayPal * @since 3.5 * * @return str A Proxy Key. It's an MD5 Hash, 32 chars, URL-safe. */ public static function paypal_proxy_key_gen ( ) /* Generate Key. */ { global $current_site , $current_blog ; /* Multisite Networking. */ /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_proxy_key_gen" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_multisite ( ) && ! is_main_site ( ) ) $key = md5 (c_ws_plugin__s2member_utils_encryption:: xencrypt ( $current_blog - domain . $current_blog - path ) ) ; /**/ else /* Else it's a standard Proxy Key; not on a Multisite Network, or not on the Main Site anyway. */ $key = md5 (c_ws_plugin__s2member_utils_encryption:: xencrypt ( preg_replace ( "/\:[0-9]+$/" , "" , $_SERVER [ "HTTP_HOST" ] ) ) ) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_proxy_key_gen" , $key , get_defined_vars ( ) ) ; } /** * Calls upon the PayPal® API, and returns the response. * * @package s2Member\PayPal * @since 3.5 * * @param array $post_vars An array of variables to send through the PayPal® API call. * @return array An array of variables returned by the PayPal® API. * * @todo Optimize this routine with ``empty()`` and ``isset()``. */ public static function paypal_api_response ( $post_vars = FALSE ) { global $current_site , $current_blog ; /* For Multisite support. */ /**/ eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_api_response" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $url = "https://" . ( ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_sandbox" ] ) ? "api-3t.sandbox.paypal.com" : "api-3t.paypal.com" ) . "/nvp" ; /**/ $post_vars = apply_filters ( "ws_plugin__s2member_paypal_api_post_vars" , $post_vars , get_defined_vars ( ) ) ; $post_vars = ( is_array ( $post_vars ) ) ? $post_vars : array ( ) ; /* Must be an array. */ /**/ $post_vars [ "VERSION" ] = "71.0" ; /* Configure the PayPal® API version. */ $post_vars [ "USER" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_api_username" ] ; $post_vars [ "PWD" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_api_password" ] ; $post_vars [ "SIGNATURE" ] = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "paypal_api_signature" ] ; /**/ $input_time = date ( "D M j, Y g:i:s a T" ) ; /* Record input/nvp for logging. */ /**/ $nvp = trim (c_ws_plugin__s2member_utils_urls:: remote ( $url , $post_vars , array ( "timeout" = 20 ) ) ) ; /**/ $output_time = date ( "D M j, Y g:i:s a T" ) ; /* Now record after output time. */ /**/ wp_parse_str ( $nvp , $response ) ; /* Parse NVP response. */ $response = c_ws_plugin__s2member_utils_strings:: trim_deep ( stripslashes_deep ( $response ) ) ; /**/ if ( ! $response [ "ACK" ] || ! preg_match ( "/^(Success|SuccessWithWarning)$/i" , $response [ "ACK" ] ) ) { if ( strlen ( $response [ "L_ERRORCODE0" ] ) || $response [ "L_SHORTMESSAGE0" ] || $response [ "L_LONGMESSAGE0" ] ) /* Did we at least get an error msg? */ $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". " . rtrim ( $response [ "L_SHORTMESSAGE0" ] , "." ) . ". " . rtrim ( $response [ "L_LONGMESSAGE0" ] , "." ) . "." ; /**/ else /* Else, generate an error messsage - so something is reported back to the Customer. */ $response [ "__error" ] = "Error. Please contact Support for assistance." ; } /* If debugging is enabled; we need to maintain a comprehensive log file. Logging now supports Multisite Networking as well. */ $logv = c_ws_plugin__s2member_utilities:: ver_details ( ) ; $logm = c_ws_plugin__s2member_utilities:: mem_details ( ) ; $log4 = $_SERVER [ "HTTP_HOST" ] . $_SERVER [ "REQUEST_URI" ] . "\nUser-Agent: " . $_SERVER [ "HTTP_USER_AGENT" ] ; $log4 = ( is_multisite ( ) && ! is_main_site ( ) ) ? ( $_log4 = $current_blog - domain . $current_blog - path ) . "\n" . $log4 : $log4 ; $log2 = ( is_multisite ( ) && ! is_main_site ( ) ) ? "paypal-api-4-" . trim ( preg_replace ( "/[^a-z0-9]/i" , "-" , $_log4 ) , "-" ) . ".log" : "paypal-api.log" ; /**/ if ( isset ( $post_vars [ "ACCT" ] ) && strlen ( $post_vars [ "ACCT" ] ) 4 ) $post_vars [ "ACCT" ] = str_repeat ( "*" , strlen ( $post_vars [ "ACCT" ] ) - 4 ) . substr ( $post_vars [ "ACCT" ] , - 4 ) ; /**/ if ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "o" ] [ "gateway_debug_logs" ] ) if ( is_dir ( $logs_dir = $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "c" ] [ "logs_dir" ] ) ) if ( is_writable ( $logs_dir ) && c_ws_plugin__s2member_utils_logs:: archive_oversize_log_files ( ) ) if ( ( $log = "-------- Input vars: ( " . $input_time . " ) --------\n" . var_export ( $post_vars , true ) . "\n" ) ) if ( ( $log .= "-------- Output string/vars: ( " . $output_time . " ) --------\n" . $nvp . "\n" . var_export ( $response , true ) ) ) file_put_contents ( $logs_dir . "/" . $log2 , $logv . "\n" . $logm . "\n" . $log4 . "\n" . $log . "\n \n" , FILE_APPEND) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_api_response" , c_ws_plugin__s2member_paypal_utilities::_paypal_api_response_filters ( $response ) , get_defined_vars ( ) ) ; } /** * A sort of callback function that Filters PayPal® responses. * * Provides alternative explanations in some cases that require special attention. * * @package s2Member\PayPal * @since 3.5 * * @param array $response Expects an array of response variables returned by the PayPal® API. * @return array An array of variables returned by the PayPal® API, after ``$response["__error"]`` is Filtered. */ public static function _paypal_api_response_filters ( $response = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "_ws_plugin__s2member_before_paypal_api_response_filters" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( ! empty ( $response [ "__error" ] ) && ! empty ( $response [ "L_ERRORCODE0" ] ) ) { if ( $response [ "L_ERRORCODE0" ] == 10422 ) $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". Transaction declined. Please use an alternate funding source." ; /**/ else if ( $response [ "L_ERRORCODE0" ] == 10435 ) $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". Transaction declined. Express Checkout was NOT confirmed." ; /**/ else if ( $response [ "L_ERRORCODE0" ] == 10417 ) $response [ "__error" ] = "Error# " . $response [ "L_ERRORCODE0" ] . ". Transaction declined. Please use an alternate funding source." ; } /**/ return $response ; /* Filters already applied with: ``ws_plugin__s2member_paypal_api_response``. */ } /** * Converts a term `D|W|M|Y` into PayPal® Pro format. * * @package s2Member\PayPal * @since 3.5 * * @param str $term Expects one of `D|W|M|Y`. * @return bool|str A full singular description of the term *( i.e. `Day|Week|Month|Year` )*, else false. */ public static function paypal_pro_term ( $term = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_term" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $paypal_pro_terms = array ( "D" = "Day" , "W" = "Week" , "M" = "Month" , "Y" = "Year" ) ; /**/ $pro_term = ( ! empty ( $paypal_pro_terms [ strtoupper ( $term ) ] ) ) ? $paypal_pro_terms [ strtoupper ( $term ) ] : false ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_term" , $pro_term , get_defined_vars ( ) ) ; } /** * Converts a term `Day|Week|Month|Year` into PayPal® Standard format. * * @package s2Member\PayPal * @since 3.5 * * @param str $term Expects one of `Day|Week|Month|Year`. * @return bool|str A term code *( i.e. `D|W|M|Y` )*, else false. */ public static function paypal_std_term ( $term = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_std_term" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ $paypal_std_terms = array ( "DAY" = "D" , "WEEK" = "W" , "MONTH" = "M" , "YEAR" = "Y" ) ; /**/ $std_term = ( ! empty ( $paypal_std_terms [ strtoupper ( $term ) ] ) ) ? $paypal_std_terms [ strtoupper ( $term ) ] : false ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_std_term" , $std_term , get_defined_vars ( ) ) ; } /** * Get `subscr_id` from either an array with `recurring_payment_id|subscr_id`, or use an existing string. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * @return str|bool A `subscr_id` string if non-empty, else false. */ public static function paypal_pro_subscr_id ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_subscr_id" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "recurring_payment_id" ] ) ) $subscr_id = trim ( $array [ "recurring_payment_id" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "subscr_id" ] ) ) $subscr_id = trim ( $array [ "subscr_id" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $subscr_id = trim ( $string ) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_subscr_id" , ( ( ! empty ( $subscr_id ) ) ? $subscr_id : false ) , get_defined_vars ( ) ) ; } /** * Get `item_number` from either an array with `PROFILEREFERENCE|rp_invoice_id|item_number1|item_number`, or use an existing string. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * If it's a string, we make sure it is a valid `level:ccaps:eotper` or `sp:ids:expiration` combination. * @return str|bool An `item_number` string if non-empty, else false. */ public static function paypal_pro_item_number ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_item_number" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ( ! empty ( $array [ "PROFILEREFERENCE" ] ) || ! empty ( $array [ "rp_invoice_id" ] ) ) ) list ( $_reference , $_domain , $_item_number ) = array_map ( "trim" , preg_split ( "/~/" , ( ( ! empty ( $array [ "PROFILEREFERENCE" ] ) ) ? $array [ "PROFILEREFERENCE" ] : $array [ "rp_invoice_id" ] ) , 3 ) ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_number1" ] ) ) $_item_number = trim ( $array [ "item_number1" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_number" ] ) ) $_item_number = trim ( $array [ "item_number" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $_item_number = trim ( $string ) ; /**/ if ( ! empty ( $_item_number ) && preg_match ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "c" ] [ "membership_item_number_w_or_wo_level_regex" ] , $_item_number ) ) $item_number = $_item_number ; /**/ else if ( ! empty ( $_item_number ) && preg_match ( $GLOBALS [ "WS_PLUGIN__" ] [ "s2member" ] [ "c" ] [ "sp_access_item_number_regex" ] , $_item_number ) ) $item_number = $_item_number ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_item_number" , ( ( ! empty ( $item_number ) ) ? $item_number : false ) , get_defined_vars ( ) ) ; } /** * Get `item_name` from either an array with `product_name|item_name1|item_name`, or use an existing string. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * @return str|bool An `item_name` string if non-empty, else false. */ public static function paypal_pro_item_name ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_item_name" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "product_name" ] ) ) $item_name = trim ( $array [ "product_name" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_name1" ] ) ) $item_name = trim ( $array [ "item_name1" ] ) ; /**/ else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "item_name" ] ) ) $item_name = trim ( $array [ "item_name" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $item_name = trim ( $string ) ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_item_name" , ( ( ! empty ( $item_name ) ) ? $item_name : false ) , get_defined_vars ( ) ) ; } /** * Get `period1` from either an array with `PROFILEREFERENCE|rp_invoice_id|period1`, or use an existing string. * * This will also convert `1 Day`, into `1 D`, and so on. * This will also convert `1 SemiMonth`, into `2 W`, and so on. * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * If it's a string, we make sure it is a valid `period term` combination. * @return str A `period1` string if possible, or defaults to `0 D`. */ public static function paypal_pro_period1 ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_period1" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ( ! empty ( $array [ "PROFILEREFERENCE" ] ) || ! empty ( $array [ "rp_invoice_id" ] ) ) ) { list ( $_reference , $_domain , $_item_number ) = array_map ( "trim" , preg_split ( "/~/" , ( ( ! empty ( $array [ "PROFILEREFERENCE" ] ) ) ? $array [ "PROFILEREFERENCE" ] : $array [ "rp_invoice_id" ] ) , 3 ) ) ; list ( $_start_time , $_period1 , $_period3 ) = array_map ( "trim" , preg_split ( "/\:/" , $_reference , 3 ) ) ; } else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "period1" ] ) ) $_period1 = trim ( $array [ "period1" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $_period1 = trim ( $string ) ; /**/ if ( ! empty ( $_period1 ) ) /* Were we able to get a `period1` string? */ { list ( $num , $span ) = array_map ( "trim" , preg_split ( "/ /" , $_period1 , 2 ) ) ; /**/ if ( strtoupper ( $span ) === "SEMIMONTH" ) if ( is_numeric ( $num ) && $num = 1 ) eval ( '$num = "2"; $span = "W";' ) ; /**/ if ( strlen ( $span ) !== 1 ) /* To Standard format. */ $span = c_ws_plugin__s2member_paypal_utilities:: paypal_std_term ( $span ) ; /**/ $span = ( preg_match ( "/^[DWMY]$/i" , $span ) ) ? $span : "" ; $num = ( $span && is_numeric ( $num ) && $num = 0 ) ? $num : "" ; /**/ $period1 = ( $num && $span ) ? $num . " " . strtoupper ( $span ) : "0 D" ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_period1" , $period1 , get_defined_vars ( ) ) ; } else /* Default. */ return apply_filters ( "ws_plugin__s2member_paypal_pro_period1" , "0 D" , get_defined_vars ( ) ) ; } /** * Get `period3` from either an array with `PROFILEREFERENCE|rp_invoice_id|period3`, or use an existing string. * * This will also convert `1 Day`, into `1 D`, and so on. * This will also convert `1 SemiMonth`, into `2 W`, and so on. * The Regular Period can never be less than 1 day ( `1 D` ). * * @package s2Member\PayPal * @since 3.5 * * @param str|array $array_or_string Either an array of PayPal® post vars, or a string. * If it's a string, we make sure it is a valid `period term` combination. * @return str A `period3` string if possible, or defaults to `1 D`. */ public static function paypal_pro_period3 ( $array_or_string = FALSE ) { eval ( 'foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;' ) ; do_action ( "ws_plugin__s2member_before_paypal_pro_period3" , get_defined_vars ( ) ) ; unset ( $__refs , $__v ) ; /* Unset defined __refs, __v. */ /**/ if ( is_array ( $array = $array_or_string ) && ( ! empty ( $array [ "PROFILEREFERENCE" ] ) || ! empty ( $array [ "rp_invoice_id" ] ) ) ) { list ( $_reference , $_domain , $_item_number ) = array_map ( "trim" , preg_split ( "/~/" , ( ( ! empty ( $array [ "PROFILEREFERENCE" ] ) ) ? $array [ "PROFILEREFERENCE" ] : $array [ "rp_invoice_id" ] ) , 3 ) ) ; list ( $_start_time , $_period1 , $_period3 ) = array_map ( "trim" , preg_split ( "/\:/" , $_reference , 3 ) ) ; } else if ( is_array ( $array = $array_or_string ) && ! empty ( $array [ "period3" ] ) ) $_period3 = trim ( $array [ "period3" ] ) ; /**/ else if ( is_string ( $string = $array_or_string ) && ! empty ( $string ) ) $_period3 = trim ( $string ) ; /**/ if ( ! empty ( $_period3 ) ) /* Were we able to get a `period3` string? */ { list ( $num , $span ) = array_map ( "trim" , preg_split ( "/ /" , $_period3 , 2 ) ) ; /**/ if ( strtoupper ( $span ) === "SEMIMONTH" ) if ( is_numeric ( $num ) && $num = 1 ) eval ( '$num = "2"; $span = "W";' ) ; /**/ if ( strlen ( $span ) !== 1 ) /* To Standard format. */ $span = c_ws_plugin__s2member_paypal_utilities:: paypal_std_term ( $span ) ; /**/ $span = ( preg_match ( "/^[DWMY]$/i" , $span ) ) ? $span : "" ; $num = ( $span && is_numeric ( $num ) && $num = 0 ) ? $num : "" ; /**/ $period3 = ( $num && $span ) ? $num . " " . strtoupper ( $span ) : "1 D" ; /**/ return apply_filters ( "ws_plugin__s2member_paypal_pro_period3" , $period3 , get_defined_vars ( ) ) ; } else /* Default. */ return apply_filters ( "ws_plugin__s2member_paypal_pro_period3" , "1 D" , get_defined_vars ( ) ) ; } } } ? [ full view ]s2member\includes\classes\paypal-utilities.inc.php Source Code Documentation Packages ( Overview ) Classes Deprecated Todo Index Source Code(!-- :: s-words --)

Statistics: Posted by System Robot — July 9th, 2011, 6:08 am


]]>