2017-01-23 2 views
0

Docusign PHP 휴식 API를 작성 중입니다. 모든 것이 작동했지만, 이제는이 템플릿을 사용해야합니다. 나는 이것을위한 대본을 썼다. 하지만 지금은이 오류가 발생합니다.UNKNOWN_ENVELOPE_RECIPIENT docusign php API 템플릿 사용

오류 코드 : UNKNOWN_ENVELOPE_RECIPIENT 오류 메시지 : 당신이 발견 한 받는 사람은 지정된 봉투의 올바른받는 사람이 아닙니다.

하지만 난 내가 오류를

오류 코드 점점 오전 ClientUserId

$viewrequest->setClientUserId('12345'); 

을 제거하는 경우 : ACCOUNT_NOT_AUTHORIZED_FOR_ENVELOPE 오류 메시지 :이 계정이 요청 된 봉투에 액세스 할 권한이 없습니다.

다음은 docusign 요청을 작성하는 기능입니다.

include_once('DocuSign/bootstrap.php'); 

echo signatureRequestFromTemplate(); 
function signatureRequestFromTemplate() 
{ 
    $recipientEmail= "[email protected]"; 
    $recipientName = "test"; 
    $username = "[email protected]"; 
    $password = "telemate"; 
    $integrator_key = "SALE-252453454-54b3-4a86-bb25-1f21cb2edc21"; 
    $documentFileName = __DIR__ ."/Contract.pdf"; 
    $documentName = "datedDoc.txt"; 
    $host = "https://demo.docusign.net/restapi"; 

    // create configuration object and configure custom auth header 
    $config = new DocuSign\eSign\Configuration(); 
    $config->setHost($host); 
    $config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}"); 

    // instantiate a new docusign api client 
    $apiClient = new DocuSign\eSign\ApiClient($config); 
    $accountId = null; 

    try 
    { 
     //*** STEP 1 - Login API: get first Account ID and baseURL 
     $authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient); 
     $options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions(); 
     $loginInformation = $authenticationApi->login($options); 
     if(isset($loginInformation) && count($loginInformation) > 0) 
     { 
      $loginAccount = $loginInformation->getLoginAccounts()[0]; 
      $host = $loginAccount->getBaseUrl(); 
      $host = explode("/v2",$host); 
      $host = $host[0]; 

      // UPDATE configuration object 
      $config->setHost($host); 

      // instantiate a NEW docusign api client (that has the correct baseUrl/host) 
      $apiClient = new DocuSign\eSign\ApiClient($config); 

      if(isset($loginInformation)) 
      { 
       $accountId = $loginAccount->getAccountId(); 
       if(!empty($accountId)) 
       { 
        //*** STEP 2 - Signature Request from a Template 
        // create envelope call is available in the EnvelopesApi 
        $envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient); 
        // assign recipient to template role by setting name, email, and role name. Note that the 
        // template role name must match the placeholder role name saved in your account template. 
        $templateRole = new DocuSign\eSign\Model\TemplateRole(); 
        $templateRole->setEmail($recipientEmail); 
        $templateRole->setName($recipientName); 
        $templateRole->setRoleName("Buyer");    

        // instantiate a new envelope object and configure settings 
        $envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition(); 
        $envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Signature Request Sample"); 
        $envelop_definition->setTemplateId("EDAA30DE-551F-46C7-A7D3-9B6CA33AD07A"); 
        $envelop_definition->setTemplateRoles(array($templateRole)); 

        // set envelope status to "sent" to immediately send the signature request 
        $envelop_definition->setStatus("sent"); 

        // optional envelope parameters 
        $options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions(); 
        $options->setCdseMode(null); 
        $options->setMergeRolesOnDraft(null); 

        // create and send the envelope (aka signature request) 
        $envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options); 

        $document=json_decode($envelop_summary); 
        $envloped=$document->envelopeId; 

        $ReturnUrl="http://www.test.com/demo2/?action=docusign_request&uid=10&envelopid=" . $envloped; 
        $viewrequest = new DocuSign\eSign\Model\RecipientViewRequest(); 
        $viewrequest->setUserName($recipientName); 
        $viewrequest->setEmail($recipientEmail); 
        //$viewrequest->setRecipientId(1); 
        //$viewrequest->setClientUserId('12345'); 
        $viewrequest->setAuthenticationMethod('email'); 
        $viewrequest->setReturnUrl($ReturnUrl); 
        $envelopview=$envelopeApi->createRecipientView($accountId,$document->envelopeId,$viewrequest); 
        echo $redirecturl=$envelopview->getUrl(); 
        if(!empty($envelop_summary)) 
        { 
         //echo "$envelop_summary"; 
        } 
       } 
      } 
     } 
    } 
    catch (DocuSign\eSign\ApiException $ex) 
    { 
     echo "Exception: " . $ex->getMessage() . "\n"; 
    } 
} 

나는 그것이 나에게 나는이 Errror를 해결 한이 응답

DocuSign\eSign\Model\Recipients Object 
(
    [signers:protected] => Array 
     (
      [0] => DocuSign\eSign\Model\Signer Object 
       (
        [signature_info:protected] => 
        [default_recipient:protected] => 
        [tabs:protected] => 
        [sign_in_each_location:protected] => false 
        [offline_attributes:protected] => 
        [require_signer_certificate:protected] => 
        [require_sign_on_paper:protected] => 
        [can_sign_offline:protected] => 
        [is_bulk_recipient:protected] => false 
        [bulk_recipients_uri:protected] => 
        [recipient_supplies_tabs:protected] => 
        [excluded_documents:protected] => 
        [name:protected] => test 
        [email:protected] => [email protected] 
        [email_recipient_post_signing_url:protected] => 
        [signing_group_id:protected] => 
        [signing_group_name:protected] => 
        [signing_group_users:protected] => 
        [recipient_id:protected] => 1 
        [recipient_id_guid:protected] => e074bc90-44a0-4a0f-a9a6-68dd2ae3747c 
        [access_code:protected] => 
        [add_access_code_to_email:protected] => 
        [require_id_lookup:protected] => false 
        [id_check_configuration_name:protected] => 
        [social_authentications:protected] => 
        [phone_authentication:protected] => 
        [saml_authentication:protected] => 
        [sms_authentication:protected] => 
        [user_id:protected] => a36eb466-1b84-47a4-9e0d-733d16637444 
        [client_user_id:protected] => 
        [embedded_recipient_start_url:protected] => 
        [custom_fields:protected] => 
        [routing_order:protected] => 1 
        [id_check_information_input:protected] => 
        [recipient_attachments:protected] => 
        [note:protected] => 
        [role_name:protected] => Buyer 
        [status:protected] => sent 
        [signed_date_time:protected] => 
        [delivered_date_time:protected] => 
        [declined_date_time:protected] => 
        [sent_date_time:protected] => 
        [declined_reason:protected] => 
        [delivery_method:protected] => 
        [fax_number:protected] => 
        [template_locked:protected] => 
        [template_required:protected] => 
        [email_notification:protected] => 
        [inherit_email_notification_configuration:protected] => 
        [error_details:protected] => 
        [recipient_authentication_status:protected] => 
        [total_tab_count:protected] => 
       ) 

     ) 

    [agents:protected] => Array 
     (
     ) 

    [editors:protected] => Array 
     (
     ) 

    [intermediaries:protected] => Array 
     (
     ) 

    [carbon_copies:protected] => Array 
     (
     ) 

    [certified_deliveries:protected] => Array 
     (
     ) 

    [in_person_signers:protected] => Array 
     (
     ) 

    [recipient_count:protected] => 1 
    [current_routing_order:protected] => 1 
    [error_details:protected] => 
) 
+0

비밀번호와 통합 자 키를 공개하지 마십시오. 나는 당신이 그들을 변경하는 것이 좋습니다. –

+0

이들은 실제 값이 아닙니다. – MKD

+0

이 값은 실제 값이 아닙니다. –

답변

1

을 제공 listRecipients를 사용하여 테스트합니다. 사실 나는 템플릿 설정에서도 ClientId를 추가해야합니다. 방금 추가했습니다. $templateRole->setClientUserId('12345');

$templateRole = new DocuSign\eSign\Model\TemplateRole(); 
$templateRole->setEmail($recipientEmail); 
$templateRole->setName($recipientName); 
$templateRole->setRoleName("Buyer");    
$templateRole->setClientUserId('12345'); // added this