致命错误:在非对象中调用成员函数deleteCustomer()

I'm new to PHP and Magento, I'm trying to delete a Customer from Magento and I get this error -

Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 30

At other times I get -

Fatal error: Call to a member function deleteCustomer() on a non-object in /home/c42gor/public_html/app/code/local/Braintree/controllers/CustomerController.php on line 15

The CustomerController.php file contains this code -

<?php

require('Mage/Adminhtml/controllers/CustomerController.php');

class Braintree_CustomerController extends Mage_Adminhtml_CustomerController
{

    public function deleteAction()
    {
        $braintree = Mage::getModel('braintree/paymentMethod');
        $customerId = $this->getRequest()->getParam('id');

        if ($customerId)
        {
            $braintree->deleteCustomer($customerId);
        }

        parent::deleteAction();
    }

    public function massDeleteAction()
   {
        $customerIds = $this->getRequest()->getParam('customer');

        if(is_array($customerIds))
        {
            $braintree = Mage::getModel('braintree/paymentMethod');
            foreach ($customerIds as $customerId)
            {
                $braintree->deleteCustomer($customerId);
            }
        }

        parent::massDeleteAction();
    }
}

Change

$braintree = Mage::getModel('braintree/paymentMethod');

To

$braintree = Mage::getModel('braintree/paymentmethod');

Then rename

/app/code/local/Braintree/{Modulename}/Model/PaymentMethod.php

To

 /app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php

Then change the class name by edit file /app/code/local/Braintree/{Modulename}/Model/Paymentmethod.php

Change

  class Braintree_{Modulename}_Model_PaymentMethod ...

To

  class Braintree_{Modulename}_Model_Paymentmethod ...

you shall not use camel case class names like paymentMethod!

$braintree = Mage::getModel('braintree/paymentMethod');

Rename your class to Paymentmethod.php, rename the class label inside the class file accordingly.

Then do a

$braintree = Mage::getModel('braintree/paymentmethod');
Mage::log(get_class(braintree);

if the result in the Mage::log is empty you made a mistake with you factory...

Good luck!