2017-12-19 41 views
2

私はdocusign apiの新人です。私はdocu sign apiを使用して私のアプリで署名付きドキュメントの実装を試みています。私の要件は、単一の文書で2人の人に署名する必要があります。私はいくつかの例を見てきましたが、私はシングルユーザ署名のためのURLを取得しましたが、私は正しい解決策を得られませんでした。私を助けてください。事前のおかげで、あなたのコードで埋め込みサインに複数の署名者を追加する方法docusign api

ここに私のサンプルコードがある

var docusign = require('docusign-esign'); 
var async = require('async'); 
var integratorKey = '*************', 
email   = '***********', 
password   = '***********',  
recipientName = '*********', 
recipientEmail = '**********'; 
recipientName1 = '***********', 
recipientEmail1 = '*************'; 
var basePath = "https://demo.docusign.net/restapi"; 
const SignTest1File = "sample.pdf"; 
var envelopeId = ''; 
var apiClient = new docusign.ApiClient(); 
apiClient.setBasePath(basePath); 
var creds = JSON.stringify({ 
Username: email, 
Password: password, 
IntegratorKey: integratorKey 
}); 
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); 
docusign.Configuration.default.setDefaultApiClient(apiClient); 
async.waterfall([ 
function login (next) { 
    var authApi = new docusign.AuthenticationApi(); 
    var loginOps = new authApi.LoginOptions(); 
    loginOps.setApiPassword("true"); 
    loginOps.setIncludeAccountIdGuid("true"); 
    authApi.login(loginOps, function (err, loginInfo, response) { 
    if (err) { 
     return next(err); 
    } 
    if (loginInfo) { 
     var loginAccounts = loginInfo.getLoginAccounts(); 
     console.log("LoginInformation: " + JSON.stringify(loginAccounts)); 
     next(null, loginAccounts); 
    } 
    }); 
}, 
function createAndSendEnvelopeWithEmbeddedRecipient (loginAccounts, next) { 
    var fileBytes = null; 
    try { 
    var fs = require('fs'), 
    path = require('path'); 
    fileBytes = fs.readFileSync(path.resolve('controllers/'+SignTest1File)); 
    } catch (ex) { 
    console.log("Exception: " + ex); 
    } 
    var envDef = new docusign.EnvelopeDefinition(); 
    envDef.setEmailSubject("Please sign this doc"); 
    var doc = new docusign.Document(); 
    var base64Doc = new Buffer(fileBytes).toString('base64'); 
    doc.setDocumentBase64(base64Doc); 
    doc.setName("sample.pdf"); 
    doc.setDocumentId("1"); 
    var docs = []; 
    docs.push(doc); 
    envDef.setDocuments(docs); 
    var signer = new docusign.Signer(); 
    signer.setName(recipientName); 
    signer.setEmail(recipientEmail); 
    signer.setRecipientId("1"); 
    signer.setClientUserId("1234"); 
    var signHere = new docusign.SignHere(); 
    signHere.setDocumentId("1"); 
    signHere.setPageNumber("1"); 
    signHere.setRecipientId("1"); 
    signHere.setXPosition("100"); 
    signHere.setYPosition("100"); 
    var signHereTabs = []; 
    signHereTabs.push(signHere); 
    var tabs = new docusign.Tabs(); 
    tabs.setSignHereTabs(signHereTabs); 
    signer.setTabs(tabs); 
    envDef.setRecipients(new docusign.Recipients());  
    envDef.getRecipients().setSigners([]); 
    envDef.getRecipients().getSigners().push(signer); 
    envDef.setStatus("sent"); 
    var envelopesApi = new docusign.EnvelopesApi(); 
    envelopesApi.createEnvelope(loginAccounts[0].accountId, envDef, null, function(error, envelopeSummary, response) { 
    if (error) { 
     return next(error); 
    } 
    if (envelopeSummary) { 
     console.log("EnvelopeSummary: " + JSON.stringify(envelopeSummary)); 
     envelopeId = envelopeSummary.envelopeId; 
     next(null, envelopeId, loginAccounts); 
    } 
    }); 
}, 
function requestRecipientView (envelopeId, loginAccounts, next) { 
    const returnUrl = "http://www.docusign.com/developer-center"; 
    var recipientView = new docusign.RecipientViewRequest(); 
    recipientView.setUserName(recipientName); 
    recipientView.setEmail(recipientEmail); 
    recipientView.setReturnUrl(returnUrl); 
    recipientView.setAuthenticationMethod("email"); 
    recipientView.setClientUserId("1234"); 
    var envelopesApi = new docusign.EnvelopesApi(); 
    envelopesApi.createRecipientView(loginAccounts[0].accountId, envelopeId, recipientView, function(error, viewUrl, response) { 
    if (error) { 
     return next(error); 
    } 
    if (viewUrl) { 
     console.log("RecipientViewUrl = " + JSON.stringify(viewUrl)); 
     next() 
    } 
    }); 
} 
], function end (error) { 
if (error) { 
    console.log('Error: ', error); 
    process.exit(1); 
} 
process.exit(); 
}); 

答えて

2

は、あなたが現在あなたがこのコレクションで唯一の署名者を推進している

envDef.getRecipients().getSigners().push(signer); 

を持っています。 name, email, routingorder and clientUserId and its associated tabsで新しい署名者を作成します。次に、この新しい署名者を署名者コレクションにプッシュします。この方法で、複数の署名者を封筒に追加できます。埋め込み署名URLを作成する際には、URLを作成するname、email、およびclientUserIdを正しく参照する必要があります。また、受信者が受信者URLに到達していない場合は受信者URLを生成できません。

+0

最初のユーザーが文書に署名すると、自分のウェブサイトにリダイレクトされます。このメソッドは、envelopeId、accountId&options {returnUrl: 'asd'、clientUserId: '1234'、AuthenticationMethod: 'email'およびusername、email}の3つのパラメータを取るため、CreateRecipientView()の2回目以降のリクエストをどのように行うのですか。 envelopIdはもう存在しません。 –

関連する問題