当Docusign的信封状态完成后,我可以收到请求吗? [英] Can i get a request when the Docusign envelope status is completed from Docusign

查看:105
本文介绍了当Docusign的信封状态完成后,我可以收到请求吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的客户使用Docuisign,以将其用作数字签名.我正在使用php rest API,并且我有5个模板角色,并且一切工作都很好.

I am using Docuisign for my client to use it as digital signature. I am using php rest API and i have 5 template roles and everything is working perfect.

因此,当信封状态完成时,我想从Docusign收到我的服务器上的请求.这样我也可以更新自己的状态.

So i want to get a request on my server from Docusign when the envelope status is completed. So that i can update the status on my side as well.

我心中有一个解决方案

1)解决方案1 ​​

我可以创建一个cron作业来检查信封的状态,但是我的服务器上已经在运行4 crones,所以我避免使用此解决方案

I can create a cron job to check the status of envelope but 4 crones are already running on my server so i am avoiding this solution

我的代码是

$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents($documentFileName)));
$document->setName($documentName);
$document->setDocumentId("1");
// 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");            
$templateRole->setClientUserId('12345');
$docusignlogs['Recipients'][]=array("Email"=>$recipientEmail,"Name"=>$recipientName,"Role"=>"Buyer");  

$templateRole1 = new  DocuSign\eSign\Model\TemplateRole();
$templateRole1->setEmail($agentEmail);
$templateRole1->setName($agentName);
$templateRole1->setRoleName("SA"); 
$docusignlogs['Recipients'][]=array("Email"=>$agentEmail,"Name"=>$agentName,"Role"=>"SA");    

//$templateRole1->setClientUserId('12345');
$all_template_roles = array($templateRole,$templateRole1);
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject(" E-CONTRACT – {$subname} – {$lotjobnum}");
$envelop_definition->setTemplateId($templateid);
$envelop_definition->setDocuments(array($document));
$envelop_definition->setTemplateRoles($all_template_roles);

// 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);
if(!isset($envelop_summary->errorCode)){
    $document=json_decode($envelop_summary);
    $envloped=$document->envelopeId;
    $viewrequest = new DocuSign\eSign\Model\RecipientViewRequest();
    $viewrequest->setUserName($recipientName); 
    $viewrequest->setEmail($recipientEmail);
    $viewrequest->setAuthenticationMethod('email');
    $viewrequest->setClientUserId('12345');
    $viewrequest->setReturnUrl($ReturnUrl);
    $envelopview=$envelopeApi->createRecipientView($accountId,$document->envelopeId,$viewrequest);
    $redirecturl=$envelopview->getUrl();
}else{
    $message=isset($envelop_summary->message) ? $envelop_summary->message : "unable to create envelope";
    $wpdb->update( $wpdb->prefix.'reservation', array('envelope_id'=>$message), array('id'=>$reservation_id));
    return builderUX_flash('danger',"Error occurred with connecting to DocuSign please contact us .");
}

谢谢.

推荐答案

当信封状态更改时,DocuSign Connect服务将对应用程序服务器进行HTTPS POST,因此您不必定期轮询信封以进行更改.

The DocuSign Connect service will make an HTTPS POST to your application's server when envelope status changes, so you don't have to regularly poll envelopes for changes.

此处提供了Connect的一般概述: https://www.docusign.com/blog/dsdev-adding-webhooks-application/

A general overview of Connect is available here: https://www.docusign.com/blog/dsdev-adding-webhooks-application/

此处提供了示例侦听器: https://github.com/docusign/docusign-soap-sdk/tree/master/PHP/Connect

an example listener is available here: https://github.com/docusign/docusign-soap-sdk/tree/master/PHP/Connect

您可以为整个帐户设置Connect,也可以通过在信封中包含 eventNotification 对象来请求特定信封的Connect:创建API调用.

You can set up Connect for your entire account or you can request Connect for a specific envelope by including the eventNotification object with your Envelopes: create API call.

这篇关于当Docusign的信封状态完成后,我可以收到请求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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