簡體   English   中英

DocuSign 嵌入式簽名 API

[英]DocuSign Embedded signing API

兩部分問題:

我們正在嘗試接收文件准備簽署的通知(我們並不完全清楚通知中提供的內容)。 我們不想做電子郵件通知; 我們想關閉那些。 我們假設嵌入式簽名的信息包含在非電子郵件通知中。 是否有一種簡單的方法可以將推送通知發送到另一個程序,表明文檔已准備好發送,如果是,那么跟進通知以讓簽名 API POST 並從 DocuSign 請求信息的最佳方法是什么?

在我們的測試中,我們已經能夠通過 API 調用接收嵌入的簽名 URL,但是它會將我們帶到一個頁面,該頁面沒有顯示選項卡的簽名視圖; 這意味着簽名者不能簽名,對於其他角色也是如此。 大多數情況下, 這篇SO 帖子中解釋的問題相同。 我用 JavaScript 編碼,而不是 PHP。 我不知道這是否會對回答問題產生影響,如果是這樣,請在評論中提出更多問題,我可以提供更多信息。

這就是我們得到的,但我們應該得到一個帶有簽名標簽的文檔。 這是我們得到的,但我們應該得到一個帶有簽名標簽的文檔

這是我們應該看到的。我們在手動登錄 DS 並單擊文檔時會看到此版本。 這是我們應該看到的。 我們在手動登錄 DS 並單擊文檔時會看到此版本。

我們認為 templateRoleName 字段可能是導致此問題的原因,但我們已經測試了使用和不使用它,似乎沒有什么區別。

這是我們在演練中使用的 API 調用的 JS 文件。

//
// to run this sample
//  1. copy the file in your own directory - say, example.js
//  2. change "***" to appropriate values
//  3. install async and request packages
//     npm install async
//     npm install request
//  4. execute
//     node example.js 
// 

var     async = require("async"),       // async module
    request = require("request"),       // request module
    email = "email@email.com",              // your account email
    password = "password1",         // your account password
    integratorKey = "DEEZ-010ebc24-01cc-143a-98c3-d9dbf7561cb1",            // your account Integrator Key (found on Preferences -> API page)
    recipientName = "email@email.com",          // recipient (signer) name
    templateId = "1C504DBA-B03F-4E57-B6BB-FD2ABD15837C",            // provide valid templateId from a template in your account
    templateRoleName = "Signer",        // template role that exists on template referenced above
    baseUrl = "",               // we will retrieve this
    envelopeId = "bc14310c-57c0-4168-91be-1fb71ea24c1c";            // created from step 2

async.waterfall(
    [
        //////////////////////////////////////////////////////////////////////
        // Step 1 - Login (used to retrieve accountId and baseUrl)
        //////////////////////////////////////////////////////////////////////
        function(next) {
            var url = "https://demo.docusign.net/restapi/v2/login_information";
            var body = "";  // no request body for login api call

            // set request url, method, body, and headers
            var options = initializeRequest(url, "GET", body, email, password);

            // send the request...
            request(options, function(err, res, body) {
                if(!parseResponseBody(err, res, body)) {
                    return;
                }
                baseUrl = JSON.parse(body).loginAccounts[0].baseUrl;
                next(null); // call next function
            });
        },

        //////////////////////////////////////////////////////////////////////
        // Step 2 - Send envelope with one Embedded recipient (using clientUserId property)
        //////////////////////////////////////////////////////////////////////
        function(next) {
            var url = baseUrl + "/envelopes";
            var body = JSON.stringify({
                "emailSubject": "DocuSign API call - Embedded Sending Example",
                "templateId": templateId,
                "templateRoles": [{
                    "email": email,
                    "name": recipientName,
                    "roleName": templateRoleName,
                    "clientUserId": "1001"  // user-configurable
                }],
                "status": "sent"
            });

            // set request url, method, body, and headers
            var options = initializeRequest(url, "POST", body, email, password);

            // send the request...
            request(options, function(err, res, body) {
                if(!parseResponseBody(err, res, body)) {
                    return;
                }
                // parse the envelopeId value from the response
                envelopeId = JSON.parse(body).envelopeId;
                next(null); // call next function
            });
        },

        //////////////////////////////////////////////////////////////////////
        // Step 3 - Get the Embedded Signing View (aka the recipient view)
        //////////////////////////////////////////////////////////////////////
        function(next) {
            var url = baseUrl + "/envelopes/" + envelopeId + "/views/recipient";
            var method = "POST";
            var body = JSON.stringify({
                "returnUrl": "http://www.docusign.com/devcenter",
                "authenticationMethod": "email",
                "email": email,
                "userName": recipientName,
                "clientUserId": "1001", // must match clientUserId in step 2!
            });

            // set request url, method, body, and headers
            var options = initializeRequest(url, "POST", body, email, password);

            // send the request...
            request(options, function(err, res, body) {
                if(!parseResponseBody(err, res, body))
                    return;
                else
                    console.log("\nNavigate to the above URL to start the Embedded Signing workflow...");
            });
        }
    ]);

    //***********************************************************************************************
    // --- HELPER FUNCTIONS ---
    //***********************************************************************************************
    function initializeRequest(url, method, body, email, password) {
        var options = {
            "method": method,
            "uri": url,
            "body": body,
            "headers": {}
        };
        addRequestHeaders(options, email, password);
        return options;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
    function addRequestHeaders(options, email, password) {
        // JSON formatted authentication header (XML format allowed as well)
        dsAuthHeader = JSON.stringify({
            "Username": email,
            "Password": password,
            "IntegratorKey": integratorKey  // global
        });
        // DocuSign authorization header
        options.headers["X-DocuSign-Authentication"] = dsAuthHeader;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////
    function parseResponseBody(err, res, body) {
        console.log("\r\nAPI Call Result: \r\n", JSON.parse(body));
        if( res.statusCode != 200 && res.statusCode != 201) { // success statuses
            console.log("Error calling webservice, status is: ", res.statusCode);
            console.log("\r\n", err);
            return false;
        }
        return true;
    }

編輯在此處輸入圖片說明這是此模板的 DocuSign 經典視圖中的收件人和路由部分,因為它是此問題的原始發布

這是請求日志中的 Created_RequestRecipientToken 文件:

POST https://demo.docusign.net:7802/restapi/v2/accounts/1037192/envelopes/deez83c9-b1fg-46ab-bo0c-e4576d952ac6/views/recipient
Content-Length: 185
Connection: keep-alive
Host: demo.docusign.net
X-DocuSign-Authentication: {"Username":"sender@email.com","Password":"[omitted]","IntegratorKey":"[omitted]"}
X-Forwarded-For: 543.155.155.55

{"returnUrl":"http://www.docusign.com/devcenter","authenticationMethod":"email","email":"sender@email.com","userName":"signer@email.com","clientUserId":"1002"}
201 Created
Content-Type: application/json; charset=utf-8

{
  "url": "https://demo.docusign.net/Signing/startinsession.aspx?t=3c06d2a3-e521-4e52-b669-01e24c81c3bf"
}

這是請求日志中的 Created_CreateEnvelopeFromTemplateAndForms 文件:

POST https://demo.docusign.net:7802/restapi/v2/accounts/1037192/envelopes
Content-Length: 272
Connection: keep-alive
Host: demo.docusign.net
X-DocuSign-Authentication: {"Username":"sender@email.com","Password":"[omitted]","IntegratorKey":"[omitted]"}
X-Forwarded-For: 143.115.155.55

{"emailSubject":"DocuSign API call - Embedded Sending Example","templateId":"9AF271E2-D38E-4E61-8083-928A3CCE056C",
"templateRoles":[{"email":"sender@email.com","name":"signer@email.com","roleName":"Signer","clientUserId":"1002"}],
"status":"sent"}
201 Created
Content-Type: application/json; charset=utf-8

{
  "envelopeId": "deez83c9-b1fg-46ab-bo0c-e4576d952ac6",
  "uri": "/envelopes/deez83c9-b1fg-46ab-bo0c-e4576d952ac6",
  "statusDateTime": "2015-07-08T15:56:23.5930000Z",
  "status": "sent"
}

這個這個這個不是這篇文章的解決方案。

當您從模板發送簽名請求時,如果您希望收件人繼承您之前創建的所有選項卡和工作流,那么您必須將它們與角色匹配。 要匹配它們,您需要使用roleName屬性,該屬性是通過您引用的templateRoleName示例節點腳本設置的。

首先,我想提一下,在沒有選項卡的第一個屏幕截圖中,收件人仍然可以通過將任何選項卡從左側拖到文檔上來簽名。 這稱為自由形式簽名,當它們與模板角色不匹配時,他們選擇了哪些選項卡、多少選項卡以及將它們放置在文檔上的位置。

我在您的代碼中看到您正在將模板角色名稱設置為值Signer ,只有當您在創建它時在 Web 控制台中命名占位符(模板)角色時,這才有效。 將 Web 控制台中角色名稱的值更改為Signer ,它應該可以工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM