VBScript Requires Chilkat v11.0.0+
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' 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.
set http = CreateObject("Chilkat.Http")
http.AuthToken = "SANDBOX_ACCESS_TOKEN"
set resp = CreateObject("Chilkat.HttpResponse")
set since = CreateObject("Chilkat.CkDateTime")
success = since.SetFromCurrentSystemTime()
success = since.AddDays(-30)
set query = CreateObject("Chilkat.JsonObject")
success = query.UpdateString("update_time_after",since.GetAsTimestamp(0))
success = query.UpdateInt("page_size",50)
page = 1
more = 1
Do While (more = 1)
success = query.UpdateInt("page",page)
success = http.HttpParams("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes",query,resp)
If (success <> 1) Then
outFile.WriteLine("No HTTP response: " & http.LastErrorText)
WScript.Quit
End If
If ((resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
set errorInfo = CreateObject("Chilkat.JsonObject")
success = errorInfo.Load(resp.BodyStr)
outFile.WriteLine("HTTP " & resp.StatusCode & " " & errorInfo.StringOf("name") & " " & errorInfo.StringOf("details[0].issue"))
outFile.WriteLine("PayPal debug ID: " & errorInfo.StringOf("debug_id"))
WScript.Quit
End If
set result = CreateObject("Chilkat.JsonObject")
parsedResult = result.Load(resp.BodyStr)
If (parsedResult <> 1) Then
outFile.WriteLine("Expected a JSON response; HTTP " & resp.StatusCode)
WScript.Quit
End If
i = 0
Do While (i < result.SizeOfArray("items"))
result.I = i
If (result.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",1) = 1) Then
outFile.WriteLine(result.StringOf("items[i].dispute_id") & " " & result.StringOf("items[i].reason"))
If (result.HasMember("items[i].seller_response_due_date") = 1) Then
outFile.WriteLine("Respond by " & result.StringOf("items[i].seller_response_due_date"))
End If
End If
i = i + 1
Loop
hasNext = 0
linkIndex = 0
Do While (linkIndex < result.SizeOfArray("links"))
result.I = linkIndex
If (result.StringOfEquals("links[i].rel","next",1) = 1) Then
hasNext = 1
End If
linkIndex = linkIndex + 1
Loop
more = hasNext
page = page + 1
Loop
outFile.Close