Your solution is called income based repayment, and already exists - the US has about a dozen different IBR / PAYE (Pay As You Earn) plans. Generally speaking, people with student loan debt can opt into them. Obama's version from his first term even has debt forgiveness for those who have made 120 monthly payments while working for a nonprofit / government (PSLF - public service loan forgiveness). Though the Devos Education department was running the show when those applications started coming in, and they rejected something like 98% of them out of some combination of malice and incompetence.
My favorite silver bullet solution for the mounting debt and affordability crisis is to allow student loans to be discharged in bankruptcy, and force colleges and universities to carry some substantial amount (20-30%) of the debt load they force their students to take on.
It has all kinds of negative consequences for admission of at-risk / low-income students at risk-averse institutions, but it does solve some of the game theoretical problems with rising tuition costs.