1
votes

I am new to DocuSign and trying to use embedded signing with a local document and not a template. I am using PHP and a Sandbox developer account. I am able to successfully negotiate part one (Login API) and part two (Create and Send Envelope) but part three (Request Signing URL) fails with a UNKNOWN_ENVELOPE_RECIPIENT errorCode.

The code I am using looks like this (sensitive info redacted):

    $integratorKey   = "XXX-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
    $accountEmail    = "[email protected]"; 
    $accountPassword = "xxxxxxxxxxx"; 
    $recipientName   = "Recipient Name"; 
    $recipientEmail  = "[email protected]";
    $documentName    = "DocumentName.pdf";
    $clientUserId    = "1234";

    // Construct the authentication header:
    $header = "<DocuSignCredentials><Username>" . $accountEmail . "</Username><Password>" . $accountPassword . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

    // Skipping code for parts one and two as they work fine.

    // By this point I have the value of EnvelopId in $envelopeId

    // STEP 3 - Get the Embedded Singing View
    $data = array(
    "returnUrl" => "http://unform.com/",
    "authenticationMethod" => "None",
    "email" => $accountEmail,
    "userName" => $recipientName,
    "clientUserId" => $clientUserId
  );

  $data_string = json_encode($data);

  $curl = curl_init($baseUrl . "/envelopes/$envelopeId/views/recipient" );
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string),
    "X-DocuSign-Authentication: $header" )
  );

  $json_response = curl_exec($curl);
  $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

After these calls the $status = 400 And the full $json_response I get is:

{ "errorCode": "UNKNOWN_ENVELOPE_RECIPIENT", "message": "The recipient you have identified is not a valid recipient of the specified envelope." }

I do have clientUserId defined and the $recipientName is the same that is used in step 2 in the signers array, however the field names are different, i.e. "name" => "$recipientName" in step two's signers array and "userName" => $recipientName in step 3.

For the sake of completeness here is the data array used in step two:

  $data = array(
    "accountId" => $accountId,
    "emailSubject" => "DocuSign API Sample - Please Sign This Document!",
    "documents" => array(
      array(
        "documentId" => "1",
        "name" => "$documentName"
      ),
    ),
    "recipients" => array(
      "signers" => array(
        array(
          "email" => "$accountEmail",
          "name" => "$recipientName",
          "recipientId" => "1",
          "tabs" => array(
            "signHereTabs" => array(
              array(
                "xPosition" => "100",
                "yPosition" => "150",
                "documentId" => "1",
                "pageNumber" => "1"
              )
            )
          ),
          "routingOrder" =>  "1",
          "recipientId" =>  "1",
          "clientUserId" =>  $clientUserId,
          "name" =>  "Daryl Williams",
          "email" =>  "[email protected]"
        ),
      ),
    ),
    "status" => "sent"
  );

Any help would be much appreciated. If I can provide any further details please let me know.

Thanks,

Daryl

2

2 Answers

1
votes

It looks like you are including the recipient name and recipient email twice in your second request, which I suspect is the issue. If you look at your code for creating the envelope it has two copies of each:

array(
      "email" => "$accountEmail",
      "name" => "$recipientName",
      "recipientId" => "1",
      "tabs" => array(
        "signHereTabs" => array(
          array(
            "xPosition" => "100",
            "yPosition" => "150",
            "documentId" => "1",
            "pageNumber" => "1"
          )
        )
      ),
      "routingOrder" =>  "1",
      "recipientId" =>  "1",
      "clientUserId" =>  $clientUserId,
      "name" =>  "Daryl Williams",
      "email" =>  "[email protected]"
    ),

Try removing the extra email and name at the bottom and then make sure you request the signing url using the first set of recipient name and email you provide and that will probably fix it. You can also make the GET Recipient info call after you create the envelope to verify exactly what info is being set.

0
votes

Thanks for your reply. Not only was I including the recipient name and email twice, I also had two different values for the recipient email, once with the account email and later with the recipient email. My confusion was over whom the fields: "name" and "email" refer to, the dev account or the recipient. Of course I should have figured it out since both fields belong to the signers element. Anyway it's working now and I now understand that the "name" and "email" fields refer to the recipient. Thanks for your help. For anyone interested here is sample of the code I am now using:

   "recipients" => array(
      "signers" => array(
        array(
          "name"  => "$recipientName",
          "email" =>  $recipientEmail,
          "routingOrder" =>  "1",
          "recipientId"  =>  "1",
          "clientUserId" =>  $clientUserId,
          "tabs" => array(
            "signHereTabs" => array(
              array(
                "xPosition" => "100",
                "yPosition" => "150",
                "documentId" => "1",
                "pageNumber" => "1"
              )
            )
          ),
        ),
      ),
    ),