Undefined error even when function exist

I m working on a joomla site. (i m new to joomla) i have a button cancel, which cancel a person subscription( i m using CIM) now i have the function made of xml file as said by the payment gateway SDK tut. But when i clock the button it says undefined method my method name, here is the code


if (isset($_POST['btnCancel'])){
           //echo "Cancel Subscription";exit; 
          [B] $result = $this->cancelCustomerSubscription();[/B]
}

Now the echo is working but when i comment it and run this it throws a error


//Cancel Subscription Request
function CancelSubscriptionRequest(){
$this->xml = "<?xml version='1.0' encoding='utf-8'?>
<CancelSubscriptionRequestt xmlns='AnetApi/xml/v1/schema/AnetApiSchema.xsd'>
<merchantAuthentication>
<name>" . $this->login . "</name>
<transactionKey>" . $this->transkey . "</transactionKey>
</merchantAuthentication>
    " . $this->refId() . "
    " . $this->customerProfileId() . "
</CancelSubscriptionRequest>";
}

what am i doing wrong? or missing something

Is the calling code, below:


if (isset($_POST['btnCancel'])){
           //echo "Cancel Subscription";exit; 
          $result = $this->:CancelSubscriptionRequest();
}

… part of a method inside a class? If so post that class.

It it is monstrously huge, just post the signatures of the methods (ie strip out the guts of each function except for the one which contains the calling code above).

what shld i do?

We’ll probably need to see the whole of the class definition in order to procede… I’m not very well versed in OOP, so i’m gonna look around for help at this point :stuck_out_tongue:

yes i found that, the function is not under it. i did pasted under it but i get the same error

Nope, that’d be the class definition for the Controller_register class. Your error message spells out that the object you’re calling this reference from is of type Controller_profile…

Fatal error: Call to undefined method Controller_profile::[COLOR=“Blue”]CancelSubscriptionRequest/COLOR

Red = class name, blue = method name

it should say “class Controller_profile {” at the top…

I found controller which read as class Controller_register extends JController { // register controller, is this the one ur talking about? what about it and no its not under that class

u mean the folder controller? yes its under that folder
where do i find a Controller class?

[ot]

Ah, makes sense now. :)[/ot]

Think he was trying to hilight the line throwing the error, TR :wink: BBCode tags dont work inside PHP tags, for the record, nofel.

Is function CancelSubscriptionRequest(){ inside the class definition for Controller_profile ?

lol my bad but still i got error it says
Fatal error: Call to undefined method Controller_profile::CancelSubscriptionRequest()

What are those [B] tags doing around this line: $result = $this->cancelCustomerSubscription(); ?

Were you trying to make the result bold?

The name of the function is CancelSubscriptionRequest, the function you’re calling is cancelCustomerSubscription. Not the same :slight_smile:

Off Topic:

Very nice editor and new look of fourms!

ok i am praticing OOP here is what i made, i m missing something. i wonder what. can anyone help me. why isn’t it printing?

class test{
    function world(){
        echo "Hello World";    
    }
}
$testing = new test;
$testing->world()

its not printing… why

$testing->world()

Your missing the ; at the end of that line