One way to handle this is time and materials. Simply pay the subcontractor for their time and reimburse their expenses, then add your overhead and profit on top of the subcontractor's invoice when invoicing your client.
To put it another way, the important way for contractors to make money is invoicing their clients. Adding overhead and profit to the subcontractor's invoice means that the more the subcontractor charges, the larger your gross profit, more work gets done on the code base, and solving hard problems is economically tenable.
Some people might say that this is 'nickel and diming' the client. They are right, nickel and diming is what contractors do.
Good luck.