Sample code for 30+ languages & platforms
Visual Basic 6.0 Requires Chilkat v11.0.0+

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.

PayPal documentation

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
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.
Dim http As New ChilkatHttp
http.AuthToken = "SANDBOX_ACCESS_TOKEN"
Dim resp As New ChilkatHttpResponse
Dim since As New CkDateTime
success = since.SetFromCurrentSystemTime()
success = since.AddDays(-30)
Dim query As New ChilkatJsonObject
success = query.UpdateString("update_time_after",since.GetAsTimestamp(0))
success = query.UpdateInt("page_size",50)
Dim page As Long
page = 1
Dim more As Long
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
        Debug.Print "No HTTP response: " & http.LastErrorText
        Exit Sub
    End If

    If ((resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
        Dim errorInfo As New ChilkatJsonObject
        success = errorInfo.Load(resp.BodyStr)
        Debug.Print "HTTP " & resp.StatusCode & " " & errorInfo.StringOf("name") & " " & errorInfo.StringOf("details[0].issue")
        Debug.Print "PayPal debug ID: " & errorInfo.StringOf("debug_id")
        Exit Sub
    End If

    Dim result As New ChilkatJsonObject
    Dim parsedResult As Long
    parsedResult = result.Load(resp.BodyStr)
    If (parsedResult <> 1) Then
        Debug.Print "Expected a JSON response; HTTP " & resp.StatusCode
        Exit Sub
    End If

    Dim i As Long
    i = 0
    Do While (i < result.SizeOfArray("items"))
        result.I = i
        If (result.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",1) = 1) Then
            Debug.Print result.StringOf("items[i].dispute_id") & "  " & result.StringOf("items[i].reason")
            If (result.HasMember("items[i].seller_response_due_date") = 1) Then
                Debug.Print "Respond by " & result.StringOf("items[i].seller_response_due_date")
            End If

        End If

        i = i + 1
    Loop
    Dim hasNext As Long
    hasNext = 0
    Dim linkIndex As Long
    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