Classic ASP Requires Chilkat v11.0.0+
Classic ASP
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 Classic ASP Downloads
<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")
success = http.SetUrlVar("id","DISPUTE_ID")
success = http.HttpNoBody("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes/{$id}",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
canSubmit = 0
linkIndex = 0
Do While (linkIndex < result.SizeOfArray("links"))
result.I = linkIndex
If (result.StringOfEquals("links[i].rel","provide_evidence",1) = 1) Then
canSubmit = 1
End If
linkIndex = linkIndex + 1
Loop
requested = 0
i = 0
Do While (i < result.SizeOfArray("evidences"))
result.I = i
If ((result.StringOfEquals("evidences[i].evidence_type","PROOF_OF_FULFILLMENT",1) = 1) And (result.StringOfEquals("evidences[i].source","REQUESTED_FROM_SELLER",1) = 1)) Then
requested = 1
End If
i = i + 1
Loop
If ((canSubmit <> 1) Or (requested <> 1)) Then
Response.Write "<pre>" & Server.HTMLEncode( "PayPal is not requesting seller fulfillment evidence for this case.") & "</pre>"
Response.End
End If
set body = Server.CreateObject("Chilkat.JsonObject")
success = body.UpdateString("evidences[0].evidence_type","PROOF_OF_FULFILLMENT")
success = body.UpdateString("evidences[0].evidence_info.tracking_info[0].carrier_name","FEDEX")
success = body.UpdateString("evidences[0].evidence_info.tracking_info[0].tracking_number","123456789012")
success = body.UpdateString("evidences[0].notes","The attached carrier receipt corresponds to this shipment.")
set upload = Server.CreateObject("Chilkat.HttpRequest")
upload.HttpVerb = "POST"
upload.ContentType = "multipart/form-data"
success = upload.AddStringForUpload2("input","",body.Emit(),"utf-8","application/json")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( upload.LastErrorText) & "</pre>"
Response.End
End If
success = upload.AddFileForUpload2("file1","carrier-receipt.pdf","application/pdf")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( upload.LastErrorText) & "</pre>"
Response.End
End If
success = http.HttpReq("https://api-m.sandbox.paypal.com/v1/customer/disputes/{$id}/provide-evidence",upload,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 submitError = Server.CreateObject("Chilkat.JsonObject")
success = submitError.Load(resp.BodyStr)
Response.Write "<pre>" & Server.HTMLEncode( "HTTP " & resp.StatusCode & " " & submitError.StringOf("name") & " " & submitError.StringOf("details[0].issue")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "PayPal debug ID: " & submitError.StringOf("debug_id")) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "PayPal accepted the evidence.") & "</pre>"
%>
</body>
</html>