Xbase++ Requires Chilkat v11.0.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oResp
LOCAL oSince
LOCAL oQuery
LOCAL nPage
LOCAL nMore
LOCAL oErrorInfo
LOCAL oResult
LOCAL nParsedResult
LOCAL i
LOCAL nHasNext
LOCAL nLinkIndex
nSuccess := 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.
oHttp := CreateObject("Chilkat.Http")
oHttp:AuthToken := "SANDBOX_ACCESS_TOKEN"
oResp := CreateObject("Chilkat.HttpResponse")
oSince := CreateObject("Chilkat.CkDateTime")
oSince:SetFromCurrentSystemTime()
oSince:AddDays(-30)
oQuery := CreateObject("Chilkat.JsonObject")
oQuery:UpdateString("update_time_after", oSince:GetAsTimestamp(0))
oQuery:UpdateInt("page_size", 50)
nPage := 1
nMore := 1
DO WHILE (nMore == 1)
oQuery:UpdateInt("page", nPage)
nSuccess := oHttp:HttpParams("GET", "https://api-m.sandbox.paypal.com/v1/customer/disputes", oQuery, oResp)
IF (nSuccess != 1)
? "No HTTP response: " + oHttp:LastErrorText
oHttp:destroy()
oResp:destroy()
oSince:destroy()
oQuery:destroy()
RETURN
ENDIF
IF ((oResp:StatusCode < 200) .OR. (oResp:StatusCode >= 300))
oErrorInfo := CreateObject("Chilkat.JsonObject")
oErrorInfo:Load(oResp:BodyStr)
? "HTTP " + Str(oResp:StatusCode) + " " + oErrorInfo:StringOf("name") + " " + oErrorInfo:StringOf("details[0].issue")
? "PayPal debug ID: " + oErrorInfo:StringOf("debug_id")
oHttp:destroy()
oResp:destroy()
oSince:destroy()
oQuery:destroy()
oErrorInfo:destroy()
RETURN
ENDIF
oResult := CreateObject("Chilkat.JsonObject")
nParsedResult := oResult:Load(oResp:BodyStr)
IF (nParsedResult != 1)
? "Expected a JSON response; HTTP " + Str(oResp:StatusCode)
oHttp:destroy()
oResp:destroy()
oSince:destroy()
oQuery:destroy()
oErrorInfo:destroy()
oResult:destroy()
RETURN
ENDIF
i := 0
DO WHILE (i < oResult:SizeOfArray("items"))
oResult:I := i
IF (oResult:StringOfEquals("items[i].status", "WAITING_FOR_SELLER_RESPONSE", 1) == 1)
? oResult:StringOf("items[i].dispute_id") + " " + oResult:StringOf("items[i].reason")
IF (oResult:HasMember("items[i].seller_response_due_date") == 1)
? "Respond by " + oResult:StringOf("items[i].seller_response_due_date")
ENDIF
ENDIF
i := i + 1
ENDDO
nHasNext := 0
nLinkIndex := 0
DO WHILE (nLinkIndex < oResult:SizeOfArray("links"))
oResult:I := nLinkIndex
IF (oResult:StringOfEquals("links[i].rel", "next", 1) == 1)
nHasNext := 1
ENDIF
nLinkIndex := nLinkIndex + 1
ENDDO
nMore := nHasNext
nPage := nPage + 1
ENDDO
oHttp:destroy()
oResp:destroy()
oSince:destroy()
oQuery:destroy()
oErrorInfo:destroy()
oResult:destroy()