DocuSignAPI嵌入式签名会话重定向URL [英] DocuSignAPI embedded signing session redirect url

查看:73
本文介绍了DocuSignAPI嵌入式签名会话重定向URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用rest api实现嵌入式签名还很新。我可以在iframe中启动签名会话,但是在完成文档/模板后,它会将我重定向到url。
有人可以让我知道如何或在何处配置重定向网址吗,我猜该网址后面会附加我可以在我的应用程序中使用此令牌的状态。

Im fairly new to implementing the embedded signing using the rest api. I am able to start the signing session within the iframe but after finishing the document/template it is redirecting me to a url. Can anybody please let me know how or where do i configure the redirect url, i guess the url is appended with the status from where i can use this token within my app.

NeverMind ..我明白了,简直不敢相信我。

NeverMind.. i got it, can't believe i dint see that in the first place.

// STEP 3 - Get the Send View           

    String reqBody = "<recipientViewRequest xmlns=\"http://www.docusign.com/restapi\">"  +
            "<authenticationMethod>email</authenticationMethod>" + 
            "<email>test@email.com</email>" + 
            **"<returnUrl>http://www.docusign.com</returnUrl>" +** 
            "<clientUserId>1</clientUserId>" + 
            "<userName>" + recipientName + "</userName>" + 
            "</recipientViewRequest>";


推荐答案

看起来像您回答了自己的问题,但是从中受益社区中的一种DocuSign API配方演示嵌入式签名的所有步骤。

Looks like you answered your own question but for the benefit of the community, one of the DocuSign API recipes demonstrates all the steps for Embedded Signing.

这是代码的完整PHP版本。如您所知,您可以通过在请求正文中设置 returnUrl 属性来设置用户签名后重定向到的URL。

Here is the full PHP version of the code. As you've found out, you can set the URL where users get redirected to after signing by setting the returnUrl property in your request body.

这是用于嵌入式签名的完整PHP程序。您还可以在此处

Here's the full PHP program for Embedded Signing. You can also find this here

<?php

    // Input your info:
    $integratorKey = '...';
    $email = '...@....com';
    $password = '...';
    $name = "John Doe";

    // copy the templateId of an existing template here
    $templateId = "C9D9D181-CE57-.....................";

    // construct the authentication header:
    $header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // STEP 1 - Login (retrieves baseUrl and accountId)
    /////////////////////////////////////////////////////////////////////////////////////////////////
    $url = "https://demo.docusign.net/restapi/v2/login_information";
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));

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

    if ( $status != 200 ) {
        echo "error calling webservice, status is:" . $status;
        exit(-1);
    }

    $response = json_decode($json_response, true);
    $accountId = $response["loginAccounts"][0]["accountId"];
    $baseUrl = $response["loginAccounts"][0]["baseUrl"];
    curl_close($curl);

    //--- display results
    echo "accountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // STEP 2 - Create an envelope with an Embedded recipient (uses the clientUserId property)
    /////////////////////////////////////////////////////////////////////////////////////////////////
    $data = array("accountId" => $accountId, 
        "emailSubject" => "Hello World!",
        "emailBlurb" => "This comes from PHP",
        "templateId" => $templateId, 
        "templateRoles" => array(
            array( "email" => $email, "name" => $name, "roleName" => "Signer1", "clientUserId" => "1001" )),
        "status" => "sent");                                                                    

    $data_string = json_encode($data);  
    $curl = curl_init($baseUrl . "/envelopes" );
    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);
    if ( $status != 201 ) {
        echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
        print_r($json_response); echo "\n";
        exit(-1);
    }

    $response = json_decode($json_response, true);
    $envelopeId = $response["envelopeId"];
    curl_close($curl);

    //--- display results   
    echo "Envelope created! Envelope ID: " . $envelopeId . "\n"; 

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // STEP 3 - Get the Embedded Singing View 
    /////////////////////////////////////////////////////////////////////////////////////////////////
    $data = array("returnUrl" => "http://www.docusign.com/devcenter",
        "authenticationMethod" => "None", "email" => $email, 
        "userName" => $name, clientUserId => "1001"
    );                                                                    

    $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);
    if ( $status != 201 ) {
        echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
        print_r($json_response); echo "\n";
        exit(-1);
    }

    $response = json_decode($json_response, true);
    $url = $response["url"];

    //--- display results
    echo "Embedded URL is: \n\n" . $url . "\n\nNavigate to this URL to start the embedded signing view of the envelope\n"; 
?>

这篇关于DocuSignAPI嵌入式签名会话重定向URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆