You will not be able to get the unlock code as the device still has an outstanding balance that needs to be paid off. You can check the status here, and it will show money is still owed on it.
Check if Your Phone is Eligible for the T-Mobile 4G Network | IMEI Status Check