AutoIt Requires Chilkat v11.0.0+
AutoIt
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 AutoIt Downloads
Local $bSuccess = 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.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.AuthToken = "SANDBOX_ACCESS_TOKEN"
$oResp = ObjCreate("Chilkat.HttpResponse")
$oSince = ObjCreate("Chilkat.CkDateTime")
$oSince.SetFromCurrentSystemTime()
$oSince.AddDays(-30)
$oQuery = ObjCreate("Chilkat.JsonObject")
$oQuery.UpdateString("update_time_after",$oSince.GetAsTimestamp(False))
$oQuery.UpdateInt("page_size",50)
Local $iPage = 1
Local $bMore = True
While ($bMore = True)
$oQuery.UpdateInt("page",$iPage)
$bSuccess = $oHttp.HttpParams("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes",$oQuery,$oResp)
If ($bSuccess <> True) Then
ConsoleWrite("No HTTP response: " & $oHttp.LastErrorText & @CRLF)
Exit
EndIf
If (($oResp.StatusCode < 200) Or ($oResp.StatusCode >= 300)) Then
$oErrorInfo = ObjCreate("Chilkat.JsonObject")
$oErrorInfo.Load($oResp.BodyStr)
ConsoleWrite("HTTP " & $oResp.StatusCode & " " & $oErrorInfo.StringOf("name") & " " & $oErrorInfo.StringOf("details[0].issue") & @CRLF)
ConsoleWrite("PayPal debug ID: " & $oErrorInfo.StringOf("debug_id") & @CRLF)
Exit
EndIf
$oResult = ObjCreate("Chilkat.JsonObject")
Local $bParsedResult = $oResult.Load($oResp.BodyStr)
If ($bParsedResult <> True) Then
ConsoleWrite("Expected a JSON response; HTTP " & $oResp.StatusCode & @CRLF)
Exit
EndIf
Local $i = 0
While ($i < $oResult.SizeOfArray("items"))
$oResult.I = $i
If ($oResult.StringOfEquals("items[i].status","WAITING_FOR_SELLER_RESPONSE",True) = True) Then
ConsoleWrite($oResult.StringOf("items[i].dispute_id") & " " & $oResult.StringOf("items[i].reason") & @CRLF)
If ($oResult.HasMember("items[i].seller_response_due_date") = True) Then
ConsoleWrite("Respond by " & $oResult.StringOf("items[i].seller_response_due_date") & @CRLF)
EndIf
EndIf
$i = $i + 1
Wend
Local $bHasNext = False
Local $iLinkIndex = 0
While ($iLinkIndex < $oResult.SizeOfArray("links"))
$oResult.I = $iLinkIndex
If ($oResult.StringOfEquals("links[i].rel","next",True) = True) Then
$bHasNext = True
EndIf
$iLinkIndex = $iLinkIndex + 1
Wend
$bMore = $bHasNext
$iPage = $iPage + 1
Wend