Sample code for 30+ languages & platforms
Classic ASP 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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
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 = Server.CreateObject("Chilkat.Http")
http.AuthToken = "SANDBOX_ACCESS_TOKEN"
set resp = Server.CreateObject("Chilkat.HttpResponse")
set since = Server.CreateObject("Chilkat.CkDateTime")
success = since.SetFromCurrentSystemTime()
success = since.AddDays(-30)
set query = Server.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
        Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response: " & http.LastErrorText) & "</pre>"
        Response.End
    End If

    If ((resp.StatusCode < 200) Or (resp.StatusCode >= 300)) Then
        set errorInfo = Server.CreateObject("Chilkat.JsonObject")
        success = errorInfo.Load(resp.BodyStr)
        Response.Write "<pre>" & Server.HTMLEncode( "HTTP " & resp.StatusCode & " " & errorInfo.StringOf("name") & " " & errorInfo.StringOf("details[0].issue")) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "PayPal debug ID: " & errorInfo.StringOf("debug_id")) & "</pre>"
        Response.End
    End If

    set result = Server.CreateObject("Chilkat.JsonObject")
    parsedResult = result.Load(resp.BodyStr)
    If (parsedResult <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON response; HTTP " & resp.StatusCode) & "</pre>"
        Response.End
    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
            Response.Write "<pre>" & Server.HTMLEncode( result.StringOf("items[i].dispute_id") & "  " & result.StringOf("items[i].reason")) & "</pre>"
            If (result.HasMember("items[i].seller_response_due_date") = 1) Then
                Response.Write "<pre>" & Server.HTMLEncode( "Respond by " & result.StringOf("items[i].seller_response_due_date")) & "</pre>"
            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

%>
</body>
</html>