.. _cb.onMediaPurchase:

========================
cb.onMediaPurchase(func)
========================

Receive a notification when a registered member purchases media from the broadcaster. The ``func``
argument should be a function that receives 2 arguments, :ref:`user` and :ref:`media`.

Example Usage
-------------

.. sourcecode:: javascript

    cb.onMediaPurchase((user, media) => {
        cb.sendNotice(`${user.user} has purchased media ${media.name}`);
    });

Example Output
--------------

.. sourcecode:: text

    Notice: testuser has purchased media testphotos!