Xojo Plugin Requires Chilkat v11.0.0+
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
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.
Dim http As New Chilkat.Http
http.AuthToken = "SANDBOX_ACCESS_TOKEN"
Dim resp As New Chilkat.HttpResponse
Dim since As New Chilkat.CkDateTime
success = since.SetFromCurrentSystemTime()
success = since.AddDays(-30)
Dim query As New Chilkat.JsonObject
success = query.UpdateString("update_time_after",since.GetAsTimestamp(False))
success = query.UpdateInt("page_size",50)
Dim page As Int32
page = 1
Dim more As Boolean
more = True
While (more = True)
success = query.UpdateInt("page",page)
success = http.HttpParams("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes",query,resp)
If (success <> True) Then
System.DebugLog("No HTTP response: " + http.LastErrorText)
Return
End If
If ((resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
Dim errorInfo As New Chilkat.JsonObject
success = errorInfo.Load(resp.BodyStr)
System.DebugLog("HTTP " + Str(resp.StatusCode) + " " + errorInfo.StringOf("name") + " " + errorInfo.StringOf("details[0].issue"))
System.DebugLog("PayPal debug ID: " + errorInfo.StringOf("debug_id"))
Return
End If
Dim result As New Chilkat.JsonObject
Dim parsedResult As Boolean
parsedResult = result.Load(resp.BodyStr)
If (parsedResult <> True) Then
System.DebugLog("Expected a JSON response; HTTP " + Str(resp.StatusCode))
Return
End If
Dim i As Int32
i = 0
While (i < result.SizeOfArray("items"))
result.I = i
If (result.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",True) = True) Then
System.DebugLog(result.StringOf("items[i].dispute_id") + " " + result.StringOf("items[i].reason"))
If (result.HasMember("items[i].seller_response_due_date") = True) Then
System.DebugLog("Respond by " + result.StringOf("items[i].seller_response_due_date"))
End If
End If
i = i + 1
Wend
Dim hasNext As Boolean
hasNext = False
Dim linkIndex As Int32
linkIndex = 0
While (linkIndex < result.SizeOfArray("links"))
result.I = linkIndex
If (result.StringOfEquals("links[i].rel","next",True) = True) Then
hasNext = True
End If
linkIndex = linkIndex + 1
Wend
more = hasNext
page = page + 1
Wend