If the court determines that the defendant has the ability to pay all or part of the costs, the court may set the amount to be reimbursed and order the defendant to pay that sum to the local or state agency or other person or entity incurring the cost in the manner in which the court believes reasonable and compatible with the defendant's financial ability. 3.