Help with a little bit of code...

Discussion in 'aMember Pro v.4' started by kinitex, Oct 2, 2012.

  1. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    PHP:
     $invoice->getItem(0)->getBillingPlanData("regnow_id");
    This works fine in the Am_Paysystem_Regnow class, but wont work in Am_Paysystem_Transaction_Regnow class. How do I call this in the validateSource function so it returns true.

    PHP:
    class Am_Paysystem_Regnow extends Am_Paysystem_Abstract
    {
        public function 
    init()
        {
            
    parent::init();
            
    $this->getDi()->billingPlanTable->customFields()
                ->
    add(new Am_CustomFieldText('regnow_id'"Regnow Product ID"
                
    "You must enter the product id of Regnow product.<br/>Must have the same settings as amember product."));
        }
     
    public function 
    _process(Invoice $invoiceAm_Request $requestAm_Paysystem_Result $result)
    {
    $a->item  $invoice->getItem(0)->getBillingPlanData("regnow_id");
    }
    }
    PHP:
    abstract class Am_Paysystem_Transaction_Regnow extends Am_Paysystem_Transaction_Incoming
    {
       
     
        public function 
    validateSource()
        {
            
    $this->_checkIp($this->plugin->getConfig('ip'));
            if (
    $invoice->getItem(0)->getBillingPlanData("regnow_id"); != $this->request->get('item'))
                throw new 
    Am_Exception_Paysystem_TransactionInvalid("Wrong [pc] passed, this transaction is not related to aMember?");
            return 
    true;
        }
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    replace
    $invoice
    to
    $this->invoice
  3. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    Repeat Action Handling (return)


    Fatal error: Call to a member function getItem() on a non-object in/regnow.php on line 120
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Inside validateSource, $this->invoice is not yet loaded. Do the same check inside validateTerms()
  5. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    Im not sure I know what you mean. I tried I few things that failed miserably.

    As far as I can see I'm supposed to use this in validateSource() and validateTerms()? I tried and no dice.

    $this->invoice->getItem(0)->getBillingPlanData("regnow_id");
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Move your check from validateSource to validateTerms:
    PHP:
    public function validateSource()
    {
            
    $this->_checkIp($this->plugin->getConfig('ip'));
            return 
    true
    }
    public function 
    validateTerms()
    {
      if (
    $invoice->getItem(0)->getBillingPlanData("regnow_id"); != $this->request->get('item'))
         throw new 
    Am_Exception_Paysystem_TransactionInvalid("Wrong [pc] passed, this transaction is not related to aMember?");
         return 
    true;
    }

Share This Page