MyBB Community Forums

Full Version: Pay Register plugin question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm using the Pay Register plugin to require users to pay a fee to register.

The payment goes through, but the user is not added to our database. Does anyone have any experience with this plugin or have an idea what might be going on?

Thanks for reading



More info:

So I've narrowed it down to this code
$mc_gross = $db->escape_string($_POST['mc_gross']);
			$payer_status = $db->escape_string($_POST['payer_status']);
			$receiver_email = $db->escape_string($_POST['receiver_email']);
			$mc_currency = $db->escape_string($_POST['mc_currency']);
if ($payment_status == "Completed" && $mc_gross == $setting['payregister_price']['price'] && $receiver_email == $setting['payregister_email']['value'] && $mc_currency == $setting['payregister_currency']['value']) 
			{
				$lang->load("member");
				require_once MYBB_ROOT."inc/datahandlers/user.php";
				$userhandler = new UserDataHandler("insert");
				$userinfo = $cache->read("payregister");
				$user = stripslashes($userinfo['user']);
				$user = urldecode($user);
				$user = unserialize($user); 
				$user['payregistered'] = 1;
				$userhandler->set_data($user);
				$userhandler->validate_user();
				$user_info = $userhandler->insert_user();
				$db->delete_query("datacache", "title='payregister'");
				my_setcookie("mybbuser", $user_info['uid']."_".$user_info['loginkey'], null, true);
				$lang->redirect_registered = $lang->sprintf($lang->redirect_registered, $mybb->settings['bbname'], $user_info['username']);
				redirect("index.php", $lang->redirect_registered);
			}
			my_mail($email, "Live-VERIFIED IPN", $emailtext . "\n\n" . $req); 

The reason I think it's that code is because I just happened to look in the mailerrors table for another reason and saw that the my_mail function is failing, with the subject 'Live-VERIFIED IPN' as found in the condition above. So for some reason one of those is failing and I'm not sure which one. (FWIW - the mailerror 'fromaddress' field all hold "" <> which is probably why that's failing. Does it have something to do with my registration errors? Huh)

I double checked to see that the amount we expect through paypal is what is being sent so I think that condition passes.

I don't see anywhere in the file where $payment_status gets set, but it must from somewhere. Also, a few lines before it sets a $payer_status but I don't see it using it..could that be just a typo?

This plugin has a number of downloads so my assumtion is that it must be working for people.

Can any other eyes help me spot what's going on?

Thanks for reading



More Info:

I've managed to verify the passing of all those conditions except the first two ($payment_status and $mc_gross)

As I said above, I don't see where $payment_status gets set, and looking at the contents of the message that are supposed to have all the POST vars appended I don't see mc_gross as a key, but it's used to make $mc_gross

Anyway...that's where I'm stuck.

Actually, looking through ALL the email errors there are some that contain them and some that doen't so now I'm back to why is it failing.

Also, I get anywhere from 1 to 3 mailerrors.

I wrote in a else condition to send me an email with the data when it fails and I get anywhere from 1 to 3 there too.

The condition from above is definitely failing.
Bump

One thing I did notice is that there are three different emails being sent, one on payment setup, one when the transaction runs and one when I cancel the recurring payment. Mostly, I just get the first and last, but as of the last time I got the transaction one, it still didn't add the user.

I know that I've been trying to dig this out for too long now, so I just need a fresh opinion. Any opinion.

Thanks guys.

Anyone?

I've tried contacting the author too, but no response.
Well, I've tried everything I can think of. Paypal shows a successful transaction and response from my server. No user added.

Has anyone ever successfully used this plugin? Or is it flawed?



After talking to paypal tech support, I've confirmed everything is ok on their side.

By adding an email to myself at the start and end of the add user condition, I've found that we enter the add user code but something is causing a fatal error which nevers gets to the email, so it looked as though the response wasn't coming.

Nothing is logged in my webserver error log, so this may be a b*tch to find.

Anybody notice anything wrong with this code?
$lang->load("member");
				require_once MYBB_ROOT."inc/datahandlers/user.php";
				$userhandler = new UserDataHandler("insert");
				$userinfo = $cache->read("payregister");
				$user = stripslashes($userinfo['user']);
				$user = urldecode($user);
				$user = unserialize($user); 
				$user['payregistered'] = 1;
				$userhandler->set_data($user);
				$userhandler->validate_user();
				$user_info = $userhandler->insert_user();
				$db->delete_query("datacache", "title='payregister'");
				my_setcookie("mybbuser", $user_info['uid']."_".$user_info['loginkey'], null, true);
				$lang->redirect_registered = $lang->sprintf($lang->redirect_registered, $mybb->settings['bbname'], $user_info['username']);
				redirect("index.php", $lang->redirect_registered);



By placing emails to myself all through the condition, I get through validation, but the actual insertion fails. Not sure why yet.

Inside the datahandler, there's only two things that would cause it; not validated (which we've proven is happening) and errors. The validation returns no errors, and insert only dies on those two conditions, so I'm not understanding...

If anyone has a guess, I'm all ears.

It fails in validation. Says password length error, but my password is between the 6-30 chars set in the board config (I checked) so I'm not sure why that's happening.

Well, I'm down to a password error so I'm closing this. MyBB's password settings aren't being populated in the user datahandler. Not a plugin issue.

If anyone ever reads this:
you must add
$payment_status = $db->escape_string($_POST['payment_status']);

above
$mc_gross = $db->escape_string($_POST['mc_gross']);

or it will never catch the condition. I'm surprised if I'm the first one to notice this.

Also, you'll get alot of mail errors because at the top of the script
$email = $_GET['ipn_email']; 

it tries to grab a get variable that just isn't there. Wasn't a big deal to me, but you could just add your email in there.

Onward and upward.
Well, turns out it is most likely a plugin thing. Asked in general support about the password length issue and got the response that it has to be that the core isn't loading. Fleshed it out, and even though the plugin requires global.php, for some reason that I have yet to figure out, the global $mybb is not set when this plugin does the user validation function.

My first thought is somehow, the response and verification to paypal is somehow the culprit, but have yet to prove that.

Placing this
$mybb->settings['minpasswordlength'] = (!isset($mybb->settings['minpasswordlength']) || empty($mybb->settings['minpasswordlength'])) ? 6 : $mybb->settings['minpasswordlength'];
$mybb->settings['maxpasswordlength'] = (!isset($mybb->settings['maxpasswordlength']) || empty($mybb->settings['maxpasswordlength'])) ? 30 : $mybb->settings['maxpasswordlength'];

directly before the validate method in payregister.php is my temporary fix.

Any better ideas, let me know.
I am running 1.6.9 and have tried to install this plugin but it will not work. Can you give me some install tips.

Thanks
Cary
did you manage to get this plugin working
(2013-06-14, 10:42 AM)mash123 Wrote: [ -> ]did you manage to get this plugin working

I got your PM but will respond here so others can gain from our conversation.

Define work..what is it not doing for you. But yes, users can successfully use this to pay for my forum, but it's not perfect. In certain circumstances users can skip the payment, although as far as I've been able to determine, it's not intentional on their part, just a flaw in the way the plugin and paypal communicate. But I did have to make the tweaks posted above just to get it to that point.

@cary - if you're having issues installing, my guess is this will help: Plugin Changes coming in 1.6.5
the plugin i use dosent make the members but it recieves payment
can u tell me what to do

were do i add this code

(2012-11-12, 07:44 PM)TOA Wrote: [ -> ]Placing this
$mybb->settings['minpasswordlength'] = (!isset($mybb->settings['minpasswordlength']) || empty($mybb->settings['minpasswordlength'])) ? 6 : $mybb->settings['minpasswordlength'];
$mybb->settings['maxpasswordlength'] = (!isset($mybb->settings['maxpasswordlength']) || empty($mybb->settings['maxpasswordlength'])) ? 30 : $mybb->settings['maxpasswordlength'];

directly before the validate method in payregister.php is my temporary fix.


were do i add this

can you upload your files thanks
(2013-06-14, 03:03 PM)mash123 Wrote: [ -> ]the plugin i use dosent make the members but it recieves payment
can u tell me what to do

were do i add this code

(2012-11-12, 07:44 PM)TOA Wrote: [ -> ]Placing this
$mybb->settings['minpasswordlength'] = (!isset($mybb->settings['minpasswordlength']) || empty($mybb->settings['minpasswordlength'])) ? 6 : $mybb->settings['minpasswordlength'];
$mybb->settings['maxpasswordlength'] = (!isset($mybb->settings['maxpasswordlength']) || empty($mybb->settings['maxpasswordlength'])) ? 30 : $mybb->settings['maxpasswordlength'];

directly before the validate method in payregister.php is my temporary fix.


were do i add this

can you upload your files thanks

Add it directly before the validate method in payregister.php

I don't have the files on me but I will later.
there isnt validate method

yes please upload later thank you so much
do you have any ideas when u will upload them
Pages: 1 2