1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Potential user upgrade problem

Discussion in 'XenForo Questions and Support' started by mikel, Aug 30, 2012.

  1. mikel

    mikel Member

    We have run some tests and think we might have discovered a problem with user upgrades, but wanted to ask here in case we're missing something obvious.

    We have created a user upgrade that expires monthly and have checked the box to automatically charge recurring payments. At some point, we will want to disallow new purchases, but allow those who have already purchased to continue making their recurring payments and enjoy the upgrade benefits. It seems, however, that if we uncheck the "Can be purchased" checkbox, the upgrade is disabled, and when the cron is run users who've reached an expiration date are downgraded.

    So, in short, if we're understanding this correctly, users can only remain active if the user upgrade is available for purchase.

    Is that correct? Are we missing something?

    If this is correct, perhaps a future XF upgrade could include an option "First time purchases allowed" or something to that effect, which if unchecked would allow for recurring members to keep their account active while disallowing new purchases.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I looked at the code:

    XenForo_Model_UserUpgrade::upgradeUser

    It only checks "can_purchase" when applying a new upgrade. If the upgrade is already active for the user then it doesn't check that. So the problem you described is possible if their upgrade expires before the automated renewal payment comes in. I am not sure of the timing of automated payments though.

    I see a flag in that function which disables the check ($allowInsertUnpurchasable). You can enable this flag by editing this function:

    XenForo_UserUpgradeProcessor_PayPal::processTransaction

    Add the red code:

    Code:
    	public function processTransaction()
    	{
    		switch ($this->_filtered['txn_type'])
    		{
    			case 'web_accept':
    			case 'subscr_payment':
    				if ($this->_filtered['payment_status'] == 'Completed')
    				{
    					$this->_upgradeRecordId = $this->_upgradeModel->upgradeUser($this->_user['user_id'], $this->_upgrade, true);
    
    					return array('payment', 'Payment received, upgraded/extended');
    				}
    				break;
    		}
    
    		if ($this->_filtered['payment_status'] == 'Refunded' || $this->_filtered['payment_status'] == 'Reversed')
    		{
    			if ($this->_upgradeRecord)
    			{
    				$this->_upgradeModel->downgradeUserUpgrade($this->_upgradeRecord);
    
    				return array('cancel', 'Payment refunded/reversed, downgraded');
    			}
    		}
    
    		return array('info', 'OK, no action');
    	}
    
    That may fix your problem.
     
  3. mikel

    mikel Member

    Thanks Jake, we'll give that a try.
     

Share This Page