How do I edit a dropdown field in the charge.onCharge hook? I have an invoice that is sent to stripe to be paid. When the thanks.html is shown, I would like the invoices section's invoicePaid dropdown field to change from "No" to "Yes" using the charge.onCharge hook.
I tried the following( and variations ) without success.

 {
    craft()-&gt;on('charge.onCharge', function(Event $event) {
        craft()-&gt;on('entries.onSaveEntry', function(Event $event ){

            //Is the entry in the section 'invoices'?
            if ($event-&gt;params['entry']-&gt;section == 'invoices') {

            //Replace values
            $event-&gt;params['entry']-&gt;getContent()-&gt;invoicePaid = 'Yes';
            }
        });


    });
}


Where am I going wrong, or is there a better way to go about this?
In your current example, you are not actually saving an entry. You are just setting up an onSaveEntry event listener. To save the entry you will need to actually save the entry using the [saveEntry][1] method.

UPDATE: I'm not exactly sure what your setup is — but some variation on the following should work for you.


In the CMS, add a field called 'invoiceID', which you will use to store the invoice entryId to the charge (or 'invoiceEntryId' or whatever you want to call it).
Add the 'invoiceId' field to the charge field layout in charge->settings->fields.
In the charge form, add the 'invoiceId' field to your form (this assumes that you are making the charge from the invoice entry page, otherwise you will need to use a reference to the invoice entry id through whatever relationship you have set up):

&lt;input type="hidden" name="fields[invoiceId]" value="{{ entry.id }}"/&gt;

In your plugin, add the onCharge event to grab the 'invoiceId' from the charge event, then retrieve, update, and save the entry.

craft()-&gt;on('charge.onCharge', function(Event $event) {

    // get the charge model
    $charge = $event-&gt;params['charge'];

    // retrieve the invoiceId (aka entryId) saved on the charge model
    $entryId = $charge-&gt;invoiceId;

    // uncomment to test, if needed
    //LogicPlugin::log('Invoice ID: '.$charge-&gt;invoiceId, LogLevel::Info);

    // get the invoice entry from the invoiceId
    $entry = craft()-&gt;entries-&gt;getEntryById($entryId);

    // update the invoicePaid field (in this case I'm using a switch)
    $entry-&gt;getContent()-&gt;invoicePaid = '1';

    // save the entry
    $success = craft()-&gt;entries-&gt;saveEntry($entry);

    // log errors
    if (!$success) {
        LogicPlugin::log('Couldn’t save the entry "'.$entry-&gt;title.'"', LogLevel::Error);
    }

});