async def METHOD_NAME(
    app: web.Application, *, payment_id: PaymentID, success: bool, error_msg: str | None
) -> PaymentsTransactionsDB:
    optional = {}
    if error_msg:
        optional["errors"] = error_msg
    async with get_database_engine(app).acquire() as conn:
        result = await conn.execute(
            payments_transactions.update()
            .values(completed_at=func.now(), success=success, **optional)
            .where(payments_transactions.c.payment_id == payment_id)
            .returning(literal_column("*"))
        )
        row = await result.first()
        assert row  #  nosec
        return PaymentsTransactionsDB.parse_obj(dict(row.items()))