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

Go
    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 := chilkat.NewHttp()
    http.SetAuthToken("SANDBOX_ACCESS_TOKEN")
    resp := chilkat.NewHttpResponse()
    since := chilkat.NewCkDateTime()
    since.SetFromCurrentSystemTime()
    since.AddDays(-30)
    query := chilkat.NewJsonObject()
    query.UpdateString("update_time_after",*since.GetAsTimestamp(false))
    query.UpdateInt("page_size",50)
    page := 1
    more := true
    for (more == true) {
        query.UpdateInt("page",page)
        success = http.HttpParams("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes",query,resp)
        if success != true {
            fmt.Println("No HTTP response: ", http.LastErrorText())
            http.DisposeHttp()
            resp.DisposeHttpResponse()
            since.DisposeCkDateTime()
            query.DisposeJsonObject()
            return
        }

        if (resp.StatusCode() < 200) || (resp.StatusCode() >= 300) {
            errorInfo := chilkat.NewJsonObject()
            errorInfo.Load(resp.BodyStr())
            fmt.Println("HTTP ", resp.StatusCode(), " ", *errorInfo.StringOf("name"), " ", *errorInfo.StringOf("details[0].issue"))
            fmt.Println("PayPal debug ID: ", *errorInfo.StringOf("debug_id"))
            http.DisposeHttp()
            resp.DisposeHttpResponse()
            since.DisposeCkDateTime()
            query.DisposeJsonObject()
            errorInfo.DisposeJsonObject()
            return
        }

        result := chilkat.NewJsonObject()
        parsedResult := result.Load(resp.BodyStr())
        if parsedResult != true {
            fmt.Println("Expected a JSON response; HTTP ", resp.StatusCode())
            http.DisposeHttp()
            resp.DisposeHttpResponse()
            since.DisposeCkDateTime()
            query.DisposeJsonObject()
            errorInfo.DisposeJsonObject()
            result.DisposeJsonObject()
            return
        }

        i := 0
        for (i < result.SizeOfArray("items")) {
            result.SetI(i)
            if result.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",true) == true {
                fmt.Println(*result.StringOf("items[i].dispute_id"), "  ", *result.StringOf("items[i].reason"))
                if result.HasMember("items[i].seller_response_due_date") == true {
                    fmt.Println("Respond by ", *result.StringOf("items[i].seller_response_due_date"))
                }

            }

            i = i + 1
        }

        hasNext := false
        linkIndex := 0
        for (linkIndex < result.SizeOfArray("links")) {
            result.SetI(linkIndex)
            if result.StringOfEquals("links[i].rel","next",true) == true {
                hasNext = true
            }

            linkIndex = linkIndex + 1
        }

        more = hasNext
        page = page + 1
    }


    http.DisposeHttp()
    resp.DisposeHttpResponse()
    since.DisposeCkDateTime()
    query.DisposeJsonObject()
    errorInfo.DisposeJsonObject()
    result.DisposeJsonObject()