docusign / recipe-010-webhook-python

eSignature API Recipe that demonstrates the use of DocuSign Connect (webhook) functionality in Python. For additional recipes see: https://github.com/docusign/docusign-rest-recipes
1 stars 1 forks source link

beautiful soup parsing issue #10

Open strickon opened 4 years ago

strickon commented 4 years ago

There is a bug in the web hook code.

# If the envelope is completed, pull out the PDFs from the notification XML
    if (xml.EnvelopeStatus.Status.string == "Completed"):

Beautiful soup will recurse down to find the first Status which may not be a direct child of envelope status. There is no guarantee that it is returning the top level envelope status. That line is returning the wrong status for my webhook.

Its returning

 <EnvelopeStatus>
          <RecipientStatuses>
             <RecipientStatus>
                    <Status>

Here is my fix

    status = xml.EnvelopeStatus.findChild("Status", recursive=False).string
    if (status == "Completed"):
LarryKlugerDS commented 4 years ago

Thank you for the bug report! Note that this is an old recipe and is scheduled to be retired.

These days, best technique for implementing DocuSign webhooks is to use an intermediate queuing system to enable reliable asynchronous processing of the notification messages by your application. If you use a PaaS (Platform as a Service) system such as AWS or Azure, the cost of the intermediate system will be zero (AWS) or very low (Azure, etc) for as many as a million messages per month.

In addition, the PaaS pattern will enable your application to receive the notification messages from behind your firewall, with no changes to the firewall.

More information: https://www.docusign.com/blog/dsdev-webhook-listeners-part-4/

Code examples for AWS, Azure, Google Cloud for C# .NET Core, Java, Node.js, PHP, and Python are available from DocuSign’s GitHub repository. See the repository listing via this link. The repos all start with Connect-

After you receive a notification message, your application can use it to trigger a download/storage of the envelope’s documents; to start a new process since the envelope has now been signed, etc.

strickon commented 4 years ago

Thanks for that link. I already am using and aws lambda with the api gateway and was only referencing this code for the xml parsing of the payload.