You would have to first buy it activated under one of the program supported carriers. You can later move it to XFinity, but XFinity is not one of the upgrade program supported activation carriers. In the USA that means purchasing the new iPhone activated with AT&T, T-Mobile or Verizon. That would enroll it in the upgrade program, and later you can switch to XFinity, since the program phones are unlocked.
https://www.apple.com/shop/iphone/iphone-upgrade-program
”Works with your carrier.
You’re buying directly from Apple. Which means no more financing your iPhone through your carrier or committing to a multiyear service contract. We connect your new iPhone to your carrier for you. So you won’t have to make any changes to your rate plan. And if you ever decide to switch carriers after you activate your iPhone with AT&T, Sprint, T-Mobile, or Verizon, you can easily do that, too.“