Sample code for 30+ languages & platforms
Go Requires Chilkat v11.0.0+

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.

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()

    http.SetUrlVar("id","DISPUTE_ID")

    success = http.HttpNoBody("GET","https://api-m.sandbox.paypal.com/v1/customer/disputes/{$id}",resp)
    if success != true {
        fmt.Println("No HTTP response: ", http.LastErrorText())
        http.DisposeHttp()
        resp.DisposeHttpResponse()
        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()
        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()
        errorInfo.DisposeJsonObject()
        result.DisposeJsonObject()
        return
    }

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

        linkIndex = linkIndex + 1
    }

    requested := false
    i := 0
    for (i < result.SizeOfArray("evidences")) {
        result.SetI(i)
        if (result.StringOfEquals("evidences[i].evidence_type","PROOF_OF_FULFILLMENT",true) == true) && (result.StringOfEquals("evidences[i].source","REQUESTED_FROM_SELLER",true) == true) {
            requested = true
        }

        i = i + 1
    }

    if (canSubmit != true) || (requested != true) {
        fmt.Println("PayPal is not requesting seller fulfillment evidence for this case.")
        http.DisposeHttp()
        resp.DisposeHttpResponse()
        errorInfo.DisposeJsonObject()
        result.DisposeJsonObject()
        return
    }

    body := chilkat.NewJsonObject()
    body.UpdateString("evidences[0].evidence_type","PROOF_OF_FULFILLMENT")
    body.UpdateString("evidences[0].evidence_info.tracking_info[0].carrier_name","FEDEX")
    body.UpdateString("evidences[0].evidence_info.tracking_info[0].tracking_number","123456789012")
    body.UpdateString("evidences[0].notes","The attached carrier receipt corresponds to this shipment.")
    upload := chilkat.NewHttpRequest()
    upload.SetHttpVerb("POST")
    upload.SetContentType("multipart/form-data")
    success = upload.AddStringForUpload2("input","",*body.Emit(),"utf-8","application/json")
    if success != true {
        fmt.Println(upload.LastErrorText())
        http.DisposeHttp()
        resp.DisposeHttpResponse()
        errorInfo.DisposeJsonObject()
        result.DisposeJsonObject()
        body.DisposeJsonObject()
        upload.DisposeHttpRequest()
        return
    }

    success = upload.AddFileForUpload2("file1","carrier-receipt.pdf","application/pdf")
    if success != true {
        fmt.Println(upload.LastErrorText())
        http.DisposeHttp()
        resp.DisposeHttpResponse()
        errorInfo.DisposeJsonObject()
        result.DisposeJsonObject()
        body.DisposeJsonObject()
        upload.DisposeHttpRequest()
        return
    }

    success = http.HttpReq("https://api-m.sandbox.paypal.com/v1/customer/disputes/{$id}/provide-evidence",upload,resp)
    if success != true {
        fmt.Println("No HTTP response: ", http.LastErrorText())
        http.DisposeHttp()
        resp.DisposeHttpResponse()
        errorInfo.DisposeJsonObject()
        result.DisposeJsonObject()
        body.DisposeJsonObject()
        upload.DisposeHttpRequest()
        return
    }

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

    fmt.Println("PayPal accepted the evidence.")

    http.DisposeHttp()
    resp.DisposeHttpResponse()
    errorInfo.DisposeJsonObject()
    result.DisposeJsonObject()
    body.DisposeJsonObject()
    upload.DisposeHttpRequest()
    submitError.DisposeJsonObject()