Custom action with Charge I'm trying to use a custom action with Charge. When a successful charge has been made I want to edit a user field. Charge appears to have Actions but little documentation on how they should be used ( http://demos.squarebit.co.uk/charge/actions )

So, I had opened charge/services/Charge_ActionsService.php and created a new one in there, which worked...

private function triggerActionCredits($details, ChargeModel $chargeModel)
{
    craft()-&gt;charge_log-&gt;action('Credits action triggered successfully');

    if (!is_array($details)) {
        craft()-&gt;charge_log-&gt;action("Details passed were: $details");
    } else {
        $detailsAsString = print_r($details);
        craft()-&gt;charge_log-&gt;action("Details passed were: $detailsAsString");
    }

    $userID = $chargeModel-&gt;userId;
    $theUser = craft()-&gt;users-&gt;getUserById($userId);
    $currentCredits = $theUser-&gt;creditsAvailable;

    craft()-&gt;charge_log-&gt;action("Got the user: $theUser");
    craft()-&gt;charge_log-&gt;action("Current credits: $currentCredits");
    craft()-&gt;charge_log-&gt;action("Details passed were: $detailsAsString");

    ... do stuff ...

    return true;
}


However, this should really be a plugin - so I've tried to port that code out of the Actions file and into its own plugin as follows:

public function init()
{
    craft()-&gt;on('charge.onCharge', function($charge){
        craft()-&gt;charge_log-&gt;action('Credits action triggered successfully');

        $pounds = $charge-&gt;amount;
        ...
}


The problem is that the line $pounds = $charge-&gt;amount; is throwing an error:

Property "Craft\Event.amount" is not defined


But; the event should be getting a Charge model? What am I doing wrong? http://squarebit.co.uk/software/craft/charge/usage/developer/hooks-and-events &amp; http://squarebit.co.uk/software/craft/charge/usage/models/charge-model
You want something like this:

craft()-&gt;on('charge.onCharge', function($event)
{
    $charge = $event-&gt;params['charge'];

    $pounds = $charge-&gt;amount;
}