Add logging for Pax8

This commit is contained in:
Chris Payne
2025-07-08 21:26:13 -04:00
parent bb96f069e4
commit 77968eef32

View File

@@ -28,7 +28,8 @@ function Get-Pax8AccessToken {
try { try {
$response = Invoke-RestMethod -Method Post -Uri "https://api.pax8.com/v1/token" -ContentType "application/json" -Body $body $response = Invoke-RestMethod -Method Post -Uri "https://api.pax8.com/v1/token" -ContentType "application/json" -Body $body
return $response.access_token return $response.access_token
} catch { }
catch {
throw "Failed to obtain Pax8 access token: $($_.Exception.Message)" throw "Failed to obtain Pax8 access token: $($_.Exception.Message)"
} }
} }
@@ -56,19 +57,19 @@ function Invoke-Pax8Provision {
$accessToken = Get-Pax8AccessToken -ClientId $clientId -ClientSecret $clientSecret $accessToken = Get-Pax8AccessToken -ClientId $clientId -ClientSecret $clientSecret
$companyPayload = @{ $companyPayload = @{
name = $CompanyName name = $CompanyName
phone = $Phone phone = $Phone
website = $Website website = $Website
externalId = "" externalId = ""
billOnBehalfOfEnabled = $false billOnBehalfOfEnabled = $false
selfServiceAllowed = $false selfServiceAllowed = $false
orderApprovalRequired = $false orderApprovalRequired = $false
address = @{ address = @{
street = $Street street = $Street
city = $City city = $City
stateOrProvince = $Province stateOrProvince = $Province
postalCode = $PostalCode postalCode = $PostalCode
country = $Country country = $Country
} }
} | ConvertTo-Json -Depth 3 } | ConvertTo-Json -Depth 3
@@ -78,7 +79,9 @@ function Invoke-Pax8Provision {
-ContentType "application/json" -Body $companyPayload -ContentType "application/json" -Body $companyPayload
Write-Host "[PAX8] Company provisioned successfully: $($response.id)" Write-Host "[PAX8] Company provisioned successfully: $($response.id)"
} catch { }
throw "[PAX8] Company creation failed: $($_.Exception.Message)" catch {
Write-Host "[ERROR] Pax8 provisioning failed: $($_.Exception.Message)"
[System.Windows.MessageBox]::Show("Pax8 provisioning failed:`n$($_.Exception.Message)", "Pax8 Error")
} }
} }