<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def payment_status_changed_listener(sender, instance, old_status, new_status, **kwargs):
 """ Here we will actually do something, when payment is accepted. E.g. lets change an order status. """

    logger.debug("payment_status_changed_listener, old=%s, new=%s", old_status,
                 new_status)
    if old_status != 'paid' and new_status == 'paid':
        # Ensures that we process order only one
        instance.order.status = 'P'
        instance.order.save()