Jump to content

Problem with processing multiple inbound webhooks in succession


billsinc

Recommended Posts

I'm trying to process inbound webhoks from a subscription provider. The problem I'm having is that they come in very fast. So for instance I'm unable to enable a new account because the account is not even created by the time the subscription hook comes in. I tried sleep(); before processing the subscription notification but that doesn't seem to work. I would appreciate some direction on how to handle this including the creation of a webhook queue if that's the best solution. Thanks!

// If new account, enter information into database 		
	if ($notification_type == "new_account_notification") {
	$insert = "INSERT INTO users (accountcode,firstname, lastname, email, username, password, companyname, approved)
	 			VALUES ('".$account_code."','".$first_name."','".$last_name."','".$email."','".$email."', '".$user_password_plain."','".$company_name."','0')";
	 $add_member = mysql_query($insert);		 
	 }

	// If subscription, sleep for X seconds to wait for account creation then approve account 
	if ($notification_type == "new_subscription_notification" || $notification_type == "reactivated_account_notification") {
		//sleep(15);
		$check = mysql_query("SELECT accountcode FROM users WHERE accountcode = '$account_code'") 
		 or die(mysql_error());
		 $check2 = mysql_num_rows($check);

		 // If the user exists, set approved=1
		 if ($check2 != 0) {
		 		$update_approved = mysql_query("UPDATE users SET approved=1 WHERE accountcode = '$account_code'")
		 		or die(mysql_error());
		}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.