use MSCommerce PS module

use MSCommerce PS module to disable AllowSelfServicePurchase in Office 365

Install-Module -Name MSCommerce

if you see above error, the fix is below –

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force

Import-Module -Name MSCommerce

Connect-MSCommerce (make sure you have login.microsoftonline.com as trusted site in the default browser.)

list all allowed product/id.

Get-MSCommercePolicy -PolicyId AllowSelfServicePurchase

Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId CFQ7TTC0KP0N -Enabled $True

Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId CFQ7TTC0KP0N -Enabled $False