来自docusign的eventNotification没有响应

时间:2018-07-12 19:12:59

标签: docusignapi webhooks

希望使用webhook通过nodejs SDK进行事件通知,但没有对我的端点执行任何ping操作,并且在DocuSign沙箱站点的Connect部分中看不到任何故障。

试图使用此食谱中的代码:https://github.com/docusign/recipe-010-webhook-node-但这是针对较旧版本的API的,并且已损坏。

这是我最后要做的事情:

    function setNotifications() {

    // and an eventNotification object which sets the parameters for
    // webhook notifications to us from the DocuSign platform
    var envelopeEvents = [];
    var envelopeEvent = new docusign.EnvelopeEvent();
    envelopeEvent.envelopeEventStatusCode = "sent";
    envelopeEvents.push(envelopeEvent);
    envelopeEvent = new docusign.EnvelopeEvent();
    envelopeEvent.envelopeEventStatusCode  = "delivered";
    envelopeEvents.push(envelopeEvent);
    envelopeEvent = new docusign.EnvelopeEvent();
    envelopeEvent.envelopeEventStatusCode = "completed";
    envelopeEvents.push(envelopeEvent);
    envelopeEvent = new docusign.EnvelopeEvent();
    envelopeEvent.envelopeEventStatusCode = "declined";
    envelopeEvents.push(envelopeEvent);
    envelopeEvent = new docusign.EnvelopeEvent();
    envelopeEvent.envelopeEventStatusCode = "voided";
    envelopeEvents.push(envelopeEvent);

    var recipientEvents = [];
    var recipientEvent = new docusign.RecipientEvent();
    recipientEvent.recipientEventStatusCode = "Sent";
    recipientEvents.push(recipientEvent);
    recipientEvent = new docusign.RecipientEvent();
    recipientEvent.recipientEventStatusCode = "Delivered";
    recipientEvents.push(recipientEvent);
    recipientEvent = new docusign.RecipientEvent();
    recipientEvent.recipientEventStatusCode = "Completed";
    recipientEvents.push(recipientEvent);
    recipientEvent = new docusign.RecipientEvent();
    recipientEvent.recipientEventStatusCode = "Declined";
    recipientEvents.push(recipientEvent);
    recipientEvent = new docusign.RecipientEvent();
    recipientEvent.recipientEventStatusCode = "AuthenticationFailed";
    recipientEvents.push(recipientEvent);
    recipientEvent = new docusign.RecipientEvent();
    recipientEvent.recipientEventStatusCode = "AutoResponded";
    recipientEvents.push(recipientEvent);

    var eventNotification = new docusign.EventNotification();
    eventNotification.url = "https://MY_PUBLICLY_OPEN_URL";
    eventNotification.loggingEnabled = "true";
    eventNotification.requireAcknowledgment = "false" ;
    eventNotification.useSoapInterface = "false";
    eventNotification.includeCertificateWithSoap = "false";
    eventNotification.signMessageWithX509Cert = "false";
    eventNotification.includeDocuments = "false";
    eventNotification.includeEnvelopeVoidReason = "true";
    eventNotification.includeTimeZone = "true";
    eventNotification.includeSenderAccountAsCustomField = "true";
    eventNotification.includeDocumentFields = "true";
    eventNotification.includeCertificateOfCompletion = "true";
    eventNotification.envelopeEvents = envelopeEvents;
    eventNotification.recipientEvents = recipientEvents;

    return eventNotification;
}

var envDef = new docusign.EnvelopeDefinition();
envDef.eventNotification = setNotifications();

编辑->这是来自DocuSign日志的请求的踪迹

POST https://demo.docusign.net:7802/restapi/v2/accounts/cc9747f3-0484-481c-8517-9a4cf0b23fc7/envelopes

TraceToken: bf38acf5-7cda-43ad-86e8-c89e36c5bb36
Timestamp: 2018-07-13T21:57:42.4983873Z

Content-Length: 1130
Content-Type: application/json


{
"envelopeId": "a uuid",
"uri": "/envelopes/a uuid",
"statusDateTime": "2018-07-13T21:57:42.1234037Z",
"status": "sent"
}
Accept: application/json
Authorization: Bearer [omitted]
Host: demo.docusign.net
User-Agent: node-superagent/3.8.2
X-DocuSign-SDK: Node
X-Cnection: close
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: nope
x-forwarded-for: nope

{"emailSubject":"a subject",
"templateId":"a uuid",
"templateRoles": [{"roleName":"Signee","name":"Chris Watkins","email":"an email"}],
"status":"sent",
"eventNotification":{
"url":"a url",
"loggingEnabled":"true",
"requireAcknowledgment":"false",
"useSoapInterface":"false",
"includeCertificateWithSoap":"false",
"signMessageWithX509Cert":"false",
"includeDocuments":"false",
"includeEnvelopeVoidReason":"true",
"includeTimeZone":"true",
"includeSenderAccountAsCustomField":"true",
"includeDocumentFields":"true",
"includeCertificateOfCompletion":"true",
"envelopeEvents":[
{"envelopeEventStatusCode":"Sent"},
{"envelopeEventStatusCode":"Delivered"}, 
{"envelopeEventStatusCode":"Completed"}, 
{"envelopeEventStatusCode":"Declined"}, 
{"envelopeEventStatusCode":"Voided"}],
"recipientEvents":
[
{"recipientEventStatusCode":"Sent"}, 
{"recipientEventStatusCode":"Delivered"}, 
{"recipientEventStatusCode":"Completed"}, 
{"recipientEventStatusCode":"Declined"}, 
{"recipientEventStatusCode":"AuthenticationFailed"}, 
{"recipientEventStatusCode":"AutoResponded"}]}}
201 Created
Content-Type: application/json; charset=utf-8
X-DocuSign-TraceToken: bf38acf5-7cda-43ad-86e8-c89e36c5bb36

其余工作正常-发送文档,我可以使用API​​检查信封状态(这是我的备份)。有任何想法吗?我不确定如何捕获nodejs发送的实际HTTP请求,但如果有帮助,很高兴通过指令进行捕获。

此外,更新文档将非常有帮助。

谢谢!

1 个答案:

答案 0 :(得分:0)

临时,您的代码看起来不错。

建议:

  1. 出于测试目的,请使用“管理工具”(“连接”部分)为同一服务器启动帐户级连接(webhook)订阅。如果可行,那么您的问题就在代码中。如果这不起作用,那么您的问题出在您的侦听器(您的服务器)或其他地方。一个信封可以被多个Connect订阅覆盖,因此在测试时无需更改信封创建代码。

  2. 使用API trace feature获取信封创建调用的跟踪信息,然后使用跟踪信息更新您的问题。可能有些问题导致底层的EvenNotification不正确。

  3. 您正在将信封设置为“已发送”,是吗?信封是否可以正常工作?

  4. 检查连接日志(通过管理工具),以查看是否有任何消息。 EventNotification日志记录转到Connect日志。

ps。对不起这个示例,我正在努力更新所有示例。

更新

感谢您的跟踪。由于似乎可以使用帐户级连接,因此eventNotification对象设置存在问题。检查事项:

  1. url设置是否以“ https://whatever.com”开头?仅支持https。
  2. 我建议将requireAcknowledgment设置为“ true”

如果仍有问题,我们可以继续进行调查。