From 77968eef321467d946f11e51c94ddc39764d5d49 Mon Sep 17 00:00:00 2001 From: Chris Payne Date: Tue, 8 Jul 2025 21:26:13 -0400 Subject: [PATCH] Add logging for Pax8 --- tools/pax8.ps1 | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/pax8.ps1 b/tools/pax8.ps1 index 9092c02..37db59a 100644 --- a/tools/pax8.ps1 +++ b/tools/pax8.ps1 @@ -28,7 +28,8 @@ function Get-Pax8AccessToken { try { $response = Invoke-RestMethod -Method Post -Uri "https://api.pax8.com/v1/token" -ContentType "application/json" -Body $body return $response.access_token - } catch { + } + catch { throw "Failed to obtain Pax8 access token: $($_.Exception.Message)" } } @@ -56,19 +57,19 @@ function Invoke-Pax8Provision { $accessToken = Get-Pax8AccessToken -ClientId $clientId -ClientSecret $clientSecret $companyPayload = @{ - name = $CompanyName - phone = $Phone - website = $Website - externalId = "" + name = $CompanyName + phone = $Phone + website = $Website + externalId = "" billOnBehalfOfEnabled = $false - selfServiceAllowed = $false + selfServiceAllowed = $false orderApprovalRequired = $false - address = @{ - street = $Street - city = $City + address = @{ + street = $Street + city = $City stateOrProvince = $Province - postalCode = $PostalCode - country = $Country + postalCode = $PostalCode + country = $Country } } | ConvertTo-Json -Depth 3 @@ -78,7 +79,9 @@ function Invoke-Pax8Provision { -ContentType "application/json" -Body $companyPayload 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") } } \ No newline at end of file