That’s entirely up to you and dependent on the method of payment.
You have to find the payment in the relevant payment provider, such as in your PayPal or Stripe account in the first instance.
You should have the option to refund the payment. If your aim is to provide a partial refund then whether you can or not may depend on whether the payment provider supports that. For PayPal you may need to send a payment to their PayPal account directly rather than issuing a refund. I can’t recall if there is a partial refund option with Stripe.
Once you have sent the money back in some form the user upgrade should get cancelled automatically on the XF side. In case it doesn’t then you can do that manually in your Admin CP.