latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

About: mark lion

Sorry, I've not written a description yet. I'll get to it soon!


Topics I've Started

Viewing topic 1 (of 1 total)
Topic Count Last Reply
IPN Proxy *return_url variable not processed

By:  mark lion in: Community Forum

voices: 4
replies: 10

4 years, 8 months ago  Raam Dev

Viewing topic 1 (of 1 total)

My Latest Replies (From Various Topics)

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Wednesday May 2nd, 2012 at 9:59 pm #12409

Call this one resolved, tho I came up with an entirely different solution. I decided to make another attempt at leveraging as much of the s2 codebase as possible and wound up finding just a few derivations in the NMI gateway’s API that could mostly be adjusted for with a filter. So just to sum up, I’m using authnet pro forms and then filtering some of the API values before wordpress cURLs it.

In case anyone’s interested, I’m using this filter hook:
add_filter( ‘http_request_args’, ‘my_filter_function’, 10, 2 );

found in the WP_Http->request() method. This also passes the api url as the second parameter so I use it to make sure I’m altering the right requests.

Speaking of the api url, this is the only thing I had to manually edit as it’s hardcoded in to the authnet-utilities.inc.php file. Jason, ever thought of dropping some filter hooks in your c_ws_plugin__s2member_utils_urls::remote() method? Being able to hook into the $url value would be pretty handy, unless I’m overlooking another way.

And thanks for giving this some of your attention!

Posted: Tuesday May 1st, 2012 at 4:03 pm #12312

Jason,

Thanks very much for having a look here. I’ve pasted my code that preps and passes user and gateway response data to the remote() method. It ought to look very familiar :)

The wp_new_user_notification() function is now doing its thing properly, so the problem is down to the remote() method not processing the new subscription the way I’d like. The new user is always created as a free subscriber, and nothing is captured in the $s2[“s2member_paypal_proxy_return_url”] element (hence, wp_redirect() is not happening).

You’ll notice a section labeled MANUALLY ADD AUTO_EOT, which is commented out. Your last response made me think this could be interfering somehow, but I get the same result whether it’s in or out.

$GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"] = array (); /* This holds the global response details. */
$global_response = &$GLOBALS["ws_plugin__s2member_pro_paypal_checkout_response"]; /* This is a shorter reference. */

// QUERY STRING FOR S2 IPN PROCESSOR
$q_url = 's2member_paypal_notify=1';
$q_url .= '&s2member_paypal_proxy=nmi';
$q_url .= '&s2member_paypal_proxy_verification=' . urlencode ( c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen () );
$q_url .= '&s2member_paypal_proxy_use=pro-emails,subscr-signup-as-subscr-payment';
$q_url .= '&s2member_paypal_proxy_return_url=' . rawurlencode ( self::$successURI );

// IPN DATA
$s2[ 'first_name' ]						= $userData[ 'firstname' ];
$s2[ 'last_name' ]						= $userData[ 'lastname' ];
$s2[ 'username' ]						= $userData[ 'username' ];
$s2[ 'option_name1' ]					= 'Originating Domain';
$s2[ 'option_selection1' ]				= $_SERVER[ 'HTTP_HOST' ];
$s2[ 'option_name2' ]					= 'Customer IP Address';
$s2[ 'option_selection2' ]				= $_SERVER[ 'REMOTE_ADDR' ];	
$s2[ 'txn_id' ]							= $nmiResponse[ 'transactionid' ];
$s2[ 'subscr_id' ]						= $nmiResponse[ 'transactionid' ];
$s2[ 'custom' ]							= self::$custom;			
$s2[ 'payer_email' ]					= $userData[ 'email' ];
$s2[ 'item_name' ]						= 'Subscription';
$s2[ 'item_number' ]					= $userData[ 'level' ];
$s2[ 'txn_type' ]						= self::$txn_type;
$s2[ 'period3' ]						= self::$period3;
$s2[ 'mc_amount3' ]						= $userData[ 'amount' ];
$s2[ 'mc_gross' ]						= $userData[ 'amount' ];
$s2[ 'recurring' ]						= self::$recurring;
$s2[ 'payment_type' ]					= self::$payment_type;
$s2[ 'payment_status' ]					= self::$payment_status;

if (!($create_user = array ())) /* Build post fields for registration configuration, and then the creation array. */
{
	$_POST["ws_plugin__s2member_custom_reg_field_user_pass1"] = $userData["password1"]; /* Fake this for registration configuration. */
	$_POST["ws_plugin__s2member_custom_reg_field_first_name"] = $s2["first_name"]; /* Fake this for registration configuration. */
	$_POST["ws_plugin__s2member_custom_reg_field_last_name"] = $s2["last_name"]; /* Fake this for registration configuration. */
	$_POST["ws_plugin__s2member_custom_reg_field_opt_in"] = $userData["custom_fields"]["opt_in"]; /* Fake this too. */
	/**/
	if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
		foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
		{
			$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
			$field_id_class = preg_replace ("/_/", "-", $field_var);
			/**/
			if (isset ($s2["custom_fields"][$field_var]))
			$_POST["ws_plugin__s2member_custom_reg_field_" . $field_var] = $s2["custom_fields"][$field_var];
		}
	/**/
	$_COOKIE["s2member_subscr_gateway"] = c_ws_plugin__s2member_utils_encryption::encrypt ("nmi"); /* Fake this for registration configuration. */
	$_COOKIE["s2member_subscr_id"] = c_ws_plugin__s2member_utils_encryption::encrypt ( $nmiResponse[ 'transactionid' ] ); /* Fake this for registration configuration. */
	$_COOKIE["s2member_custom"] = c_ws_plugin__s2member_utils_encryption::encrypt ($s2["custom"]); /* Fake this for registration configuration. */
	$_COOKIE["s2member_item_number"] = c_ws_plugin__s2member_utils_encryption::encrypt ( $s2[ 'item_number' ] ); /* Fake this too. */
	/**/
	$create_user["user_login"] = $s2["username"]; /* Copy this into a separate array for `wp_create_user()`. */
	$create_user["user_pass"] = wp_generate_password (); /* Which may fire `c_ws_plugin__s2member_registrations::generate_password()`. */
	$create_user["user_email"] = $s2["payer_email"]; /* Copy this into a separate array for `wp_create_user()`. */
}

if ( ( ( $new__user_id = wp_create_user ($create_user["user_login"], $create_user["user_pass"], $create_user["user_email"] ) ) ) && !is_wp_error ( $new__user_id ) )
{
			
	update_user_option ($new__user_id, "default_password_nag", true, true); /* Password nag. */
	wp_new_user_notification ($new__user_id, $create_user["user_pass"]);
	/**/
	$s2["s2member_paypal_proxy_return_url"] = trim (c_ws_plugin__s2member_utils_urls::remote (site_url ("/?" . $q_url), $s2, array ("timeout" => 20)));

	// MANUALLY ADD AUTO_EOT
	// this gateway will not be sending IPN notifications 
	// ---------------------------------------------------
	// update_user_option ($new__user_id, "s2member_auto_eot_time", strtotime( '+1 year' ) );

	/**/
	$global_response = array ("response" => _x ($s2["s2member_paypal_proxy_return_url"] . ' ' . $new__user_id . ' ' . '<strong>Thank you.</strong> Your account has been approved.<br />&mdash; You\'ll receive an email momentarily.', "s2member-front", "s2member"));
	/**/
	
	if (substr ($s2["s2member_paypal_proxy_return_url"], 0, 2) === substr (self::$successURI, 0, 2) && ($custom_success_url = str_ireplace (array ("%%s_response%%", /* Deprecated in v111106 ». */ "%%response%%"), array (urlencode (c_ws_plugin__s2member_utils_encryption::encrypt ($global_response["response"])), urlencode ($global_response["response"])), $s2["s2member_paypal_proxy_return_url"])) && ($custom_success_url = trim (preg_replace ("/%%(.+?)%%/i", "", $custom_success_url))))
		wp_redirect ( c_ws_plugin__s2member_utils_urls::add_s2member_sig ( $custom_success_url, "s2p-v" ) ) . exit ();
	
}

Thanks again!

Posted: Wednesday Apr 25th, 2012 at 5:04 pm #11861

Jason,

Thanks very much for the response. I’ve verified that a new wordpress user is being created before the remote() method is called.

In fact, I’ve modified the authnet.checkout-in.inc.php routines to accomodate the new gateway because the response is very similar to what authnet produces, so my processor is going through the same steps.

I’ve verified that wp_create_user returns a valid user ID but it seems wp_new_user_notification is not successful because the new user never receives an email (and the admin is also not notified).

The remote() method then seems to run fine, but as you can see in my previous post it is not actually setting up all the subscription details for the new user.

After this is done the new user gets the “Congratulations” confirmation email and a new user has in fact been added to the users table, but only as a level 0 free subscriber.

Can you think of why remote() has a problem with the freshly generated user account?

Again, any help is hugely appreciated!

Posted: Thursday Apr 19th, 2012 at 1:42 pm #11278

Okay, thanks very much Cristián, I’m really in a bind here. Just to reiterate more concisely:

1. I’m trying to signup a new member at the same time the transaction is bring processed (like the standard pro forms do).

2. Even though I get a success response, no redirection is happening.

3. The new user gets a transaction confirmation email but no username and password followup email.

4. I get this message in the log: (‘Storing IPN signup vars into a Transient Queue. These will be processed on registration.’) instead of the desired message: (‘Storing IPN signup vars now. These are associated with a User\’s account record; for future reference.’).

I imagine Jason might know at a glance what’s going on with item 4. as it’s indicative of some processing conditional that’s not being triggered properly (or the way I want it to be). Again, I’d be very grateful of any clues you could give me.

Thank You.

Posted: Tuesday Apr 17th, 2012 at 11:17 am #11006

Raam,

Thanks for getting back. I understand this is outside the scope of your support, however, you do have this line as part of that support policy (which I read before posting the first time):

“Technical support will thus take priority over any assistance with customization or modifications. If you are requesting assistance in this regard, and it only requires us to publish a couple lines of code, we will gladly help you. Or at least point you in the right direction.”

Viewing 5 replies - 1 through 5 (of 5 total)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.