AutoIt Requires Chilkat v11.0.0+
AutoIt
PayPal: Submit proof of fulfillment for a dispute
See more PayPal Examples
Inspect the actions and evidence requested for a selected dispute. When PayPal requests proof of fulfillment from the seller, attach the matching carrier receipt PDF with tracking details in a multipart request. Replace the file and tracking number with those for this case.
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")
$oHttp.SetUrlVar("id","DISPUTE_ID")
$bSuccess = $oHttp.HttpNoBody("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes/{$id}",$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 $bCanSubmit = False
Local $iLinkIndex = 0
While ($iLinkIndex < $oResult.SizeOfArray("links"))
$oResult.I = $iLinkIndex
If ($oResult.StringOfEquals("links[i].rel","provide_evidence",True) = True) Then
$bCanSubmit = True
EndIf
$iLinkIndex = $iLinkIndex + 1
Wend
Local $bRequested = False
Local $i = 0
While ($i < $oResult.SizeOfArray("evidences"))
$oResult.I = $i
If (($oResult.StringOfEquals("evidences[i].evidence_type","PROOF_OF_FULFILLMENT",True) = True) And ($oResult.StringOfEquals("evidences[i].source","REQUESTED_FROM_SELLER",True) = True)) Then
$bRequested = True
EndIf
$i = $i + 1
Wend
If (($bCanSubmit <> True) Or ($bRequested <> True)) Then
ConsoleWrite("PayPal is not requesting seller fulfillment evidence for this case." & @CRLF)
Exit
EndIf
$oBody = ObjCreate("Chilkat.JsonObject")
$oBody.UpdateString("evidences[0].evidence_type","PROOF_OF_FULFILLMENT")
$oBody.UpdateString("evidences[0].evidence_info.tracking_info[0].carrier_name","FEDEX")
$oBody.UpdateString("evidences[0].evidence_info.tracking_info[0].tracking_number","123456789012")
$oBody.UpdateString("evidences[0].notes","The attached carrier receipt corresponds to this shipment.")
$oUpload = ObjCreate("Chilkat.HttpRequest")
$oUpload.HttpVerb = "POST"
$oUpload.ContentType = "multipart/form-data"
$bSuccess = $oUpload.AddStringForUpload2("input","",$oBody.Emit(),"utf-8","application/json")
If ($bSuccess <> True) Then
ConsoleWrite($oUpload.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oUpload.AddFileForUpload2("file1","carrier-receipt.pdf","application/pdf")
If ($bSuccess <> True) Then
ConsoleWrite($oUpload.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oHttp.HttpReq("https://api-m.sandbox.paypal.com/v1/customer/disputes/{$id}/provide-evidence",$oUpload,$oResp)
If ($bSuccess <> True) Then
ConsoleWrite("No HTTP response: " & $oHttp.LastErrorText & @CRLF)
Exit
EndIf
If (($oResp.StatusCode < 200) Or ($oResp.StatusCode >= 300)) Then
$oSubmitError = ObjCreate("Chilkat.JsonObject")
$oSubmitError.Load($oResp.BodyStr)
ConsoleWrite("HTTP " & $oResp.StatusCode & " " & $oSubmitError.StringOf("name") & " " & $oSubmitError.StringOf("details[0].issue") & @CRLF)
ConsoleWrite("PayPal debug ID: " & $oSubmitError.StringOf("debug_id") & @CRLF)
Exit
EndIf
ConsoleWrite("PayPal accepted the evidence." & @CRLF)