Using Commerce to pay for posting entry
You will need to write a plugin with three responsibilities:


Keep track of which entries have been purchased
Set an entry to enabled when it has been purchased
Ensure that entries always have the correct status (enabled/disabled) whenever they are saved


For the first one, you will need to create a new DB table that can store records of which entries have been purchased.

In your plugin, create a records/ table with a MyPlugin_EntryPurchaseRecord.php file:



&lt;?php
namespace Craft;

class MyPlugin_EntryPurchaseRecord extends BaseRecord
{
    public function getTableName()
    {
        return 'myplugin_entrypurchases';
    }

    public function defineRelations()
    {
        return array(
            'entry' =&gt; array(static::BELONGS_TO, 'EntryRecord'),
            'order' =&gt; array(static::BELONGS_TO, 'Commerce_OrderRecord'),
        );
    }
}


With that in place, the table will automatically get created when you install your plugin.

Next, give your primary plugin class an init() method where you can set up some event listeners:

&lt;?php
namespace Craft;

class MyPluginPlugin extends BasePlugin
{
    // ...

    public function init()
    {
        craft()-&gt;on('commerce_orders.orderComplete', array($this, 'onOrderComplete'));
        craft()-&gt;on('entries.beforeSaveEntry', array($this, 'onBeforeSaveEntry'));
    }
}


Your onOrderComplete function will be responsible for recording the purchase in your entrypurchases table, and updating the entry’s status to enabled:

public function onOrderComplete(Event $event)
{
    /* @var Commerce_OrderModel $order */
    $order = $event-&gt;params['order'];

    // Look for a line item with an entryId option
    foreach ($order-&gt;lineItems as $lineItem)
    {
        if (!empty($lineItem-&gt;options['entryId']))
        {
            // Validate the entry ID
            $entryId = $lineItem-&gt;options['entryId'];
            $entry = craft()-&gt;entries-&gt;getEntryById($entryId);
            if (!$entry) continue;

            // Record the purchase
            $purchaseRecord = new MyPlugin_EntryPurchaseRecord();
            $purchaseRecord-&gt;entryId = $entryId;
            $purchaseRecord-&gt;orderId = $order-&gt;id;
            $purchaseRecord-&gt;save();

            // Enable the entry
            $entry-&gt;enabled = true;
            craft()-&gt;entries-&gt;saveEntry($entry);
        }
    }
}


And your onBeforeSaveEntry function will be responsible for making sure entries’ statuses are set correctly depending on whether they’ve been purchased:

public function onBeforeSaveEntry(Event $event)
{
    // Ignore for new entries
    if (!empty($event-&gt;params['isNewEntry']))
    {
        return;
    }

    /* @var EntryModel $entry */
    $entry = $event-&gt;params['entry'];

    // Ignore entries in other sections
    if ($entry-&gt;section-&gt;handle != 'mySection')
    {
        return;
    }

    // Has the entry been purchased?
    $purchaseCount = MyPlugin_EntryPurchaseRecord::model()-&gt;countByAttributes(array(
        'entryId' =&gt; $entry-&gt;id
    ));

    $entry-&gt;enabled = ($purchaseCount != 0);
}


Last but not least, you will need to update your entry purchase form to record the entry ID being purchased. We’ll do that as an option on the line item.

(If you look at the onOrderComplete function, we’re actually combing through the purchased order’s line items to look for these entryId options. This is where it gets set.)

&lt;form method="POST"&gt;
    &lt;input type="hidden" name="action" value="commerce/cart/updateCart"&gt;
    &lt;input type="hidden" name="redirect" value="commerce/cart"&gt;
    &lt;input type="hidden" name="qty" value="1"&gt;
    &lt;input type="hidden" name="purchasableId" value="{{ variant.purchasableId }}"&gt;

    &lt;!-- Associate the line item with this entry ID --&gt;
    &lt;input type="hidden" name="options[entryId]" value="{{ entry.id }}"&gt;

    &lt;input type="submit" value="Buy Now"&gt;
&lt;/form&gt;


Baring any typos, that should do it!