PowerShell Requires Chilkat v11.0.0+
PowerShell
PayPal: Find disputes awaiting a seller response
See more PayPal Examples
Scan cases updated in the past 30 days and page through the results. Show each case waiting on the seller and its response deadline when PayPal includes one in the summary.
Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# See Unlock Chilkat before making requests.
# For the merchant's internal backoffice application. Load the sandbox token
# from the merchant's credential store. Keep it out of publicly distributed apps.
# See Get a PayPal access token.
$http = New-Object Chilkat.Http
$http.AuthToken = "SANDBOX_ACCESS_TOKEN"
$resp = New-Object Chilkat.HttpResponse
$since = New-Object Chilkat.CkDateTime
$since.SetFromCurrentSystemTime()
$since.AddDays(-30)
$query = New-Object Chilkat.JsonObject
$query.UpdateString("update_time_after",$since.GetAsTimestamp($false))
$query.UpdateInt("page_size",50)
$page = 1
$more = $true
while (($more -eq $true)) {
$query.UpdateInt("page",$page)
$success = $http.HttpParams("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes",$query,$resp)
if ($success -ne $true) {
$("No HTTP response: " + $http.LastErrorText)
exit
}
if (($resp.StatusCode -lt 200) -or ($resp.StatusCode -ge 300)) {
$errorInfo = New-Object Chilkat.JsonObject
$errorInfo.Load($resp.BodyStr)
$("HTTP " + $resp.StatusCode + " " + $errorInfo.StringOf("name") + " " + $errorInfo.StringOf("details[0].issue"))
$("PayPal debug ID: " + $errorInfo.StringOf("debug_id"))
exit
}
$result = New-Object Chilkat.JsonObject
$parsedResult = $result.Load($resp.BodyStr)
if ($parsedResult -ne $true) {
$("Expected a JSON response; HTTP " + $resp.StatusCode)
exit
}
$i = 0
while (($i -lt $result.SizeOfArray("items"))) {
$result.I = $i
if ($result.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",$true) -eq $true) {
$($result.StringOf("items[i].dispute_id") + " " + $result.StringOf("items[i].reason"))
if ($result.HasMember("items[i].seller_response_due_date") -eq $true) {
$("Respond by " + $result.StringOf("items[i].seller_response_due_date"))
}
}
$i = $i + 1
}
$hasNext = $false
$linkIndex = 0
while (($linkIndex -lt $result.SizeOfArray("links"))) {
$result.I = $linkIndex
if ($result.StringOfEquals("links[i].rel","next",$true) -eq $true) {
$hasNext = $true
}
$linkIndex = $linkIndex + 1
}
$more = $hasNext
$page = $page + 1
}