Hey Anthony,
We don't do proration on cancelation which is why you're seeing this behaviour. What you should do is follow those steps:
1/ Preview the upcoming invoice with a downgrade of the quantity to 0. This tells you how much credit the customer would get but it doesn't change anything, it just helps you preview it or know in advance.
2/ Cancel the subscription.
3/ Update the customer and set their credit on their account balance so that it can be used on future invoices or subscriptions automatically.
4/ Create the new subscription which automatically uses the credit.
Separately, if you already plan to create a brand new subscription, you should be able to have all of those steps happen with just one API request instead. You would simply call the Update Subscription API [1] and pass the new plan id in the `plan` parameter. Doing so will automatically calculate the proration for you of how much credit you owe the customer for the subscription he's canceling and how much the customer owes you for the new plan so that you end up charging exactly what's expected.
Cheers,
Remi