When I worked at a rental firm a few years back, the client had to show a receipt that the carpet was indeed clean and the carpet did look clean. Or we charged a $200 fee to do the carpet cleaning.
Also, depending on the contract which states if pets are allowed or not, if pets were not allowed and urine stains were present which meant the carpet would have to be replaced... then yes, we would keep the DD to replace the carpet.
However, if your contract says you can have pets... or you paid a pet-fee then that's fine and the stains would count towards wear and tear which doesn't get taken out from the DD.