【问题标题】:How To Define A Docusign Event/Envelope Notification Python API如何定义 Docusign 事件/信封通知 Python API
【发布时间】:2018-09-01 06:36:07
【问题描述】:

对于我的公司,我一直在创建一个 web 应用程序,该应用程序将使代理信的创建和签署变得更加容易。我几乎完全完成了它。但是,我遇到的唯一问题是,在创建信封后,收件人从未收到要求签名的电子邮件。我在 docusign 的管理选项卡下进行了检查,信封列在那里,并带有正确的收件人电子邮件地址。我尝试多次重新发送它,但仍然从未收到电子邮件,尽管它被列为已发送。

我使用的代码如下:

username = "myDocusignUsername"
integrator_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
base_url = "https://demo.docusign.net/restapi"
oauth_base_url = "account-d.docusign.com"
redirect_uri = "http://myredirecturi"
private_key_filename = "path/to/pKey.txt"
user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client_user_id = 'recipient@gmail.com'

# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = "recipient@gmail.com"
signer.name = "Recipient Name"
signer.recipient_id = '1'
signer.client_user_id = client_user_id

sign_here = docusign.SignHere()
sign_here.document_id = '1'
sign_here.recipient_id = '1'
sign_here.anchor_case_sensitive = 'true'
sign_here.anchor_horizontal_alignment = 'left'
sign_here.anchor_ignore_if_not_present = 'false'
sign_here.anchor_match_whole_word = 'true'

sign_here.anchor_string = 'Signature of individual authorized to act on behalf of customer:'
sign_here.anchor_units = 'cms'
sign_here.anchor_x_offset = '0'
sign_here.anchor_y_offset = '0'
sign_here.tab_label = 'sign_here'
sign_here.IgnoreIfNotPresent = True;
tabs = docusign.Tabs()
tabs.sign_here_tabs = [sign_here]

# Create a signers list, attach tabs to signer, append signer to signers.
# Attach signers to recipients objects
signers = []
tabs = tabs
signer.tabs = tabs
signers.append(signer)
recipients = docusign.Recipients()
recipients.signers = signers

# Create an envelope to be signed
envelope_definition = docusign.EnvelopeDefinition()
envelope_definition.email_subject = 'Please Sign the Following Letter of Agency!'
envelope_definition.email_blurb = 'Please sign the following Letter of Agency (LOA) to complete the process!'

# Add a document to the envelope_definition
pdfpath = "path/to/mypdf.pdf"
with open(pdfpath, 'rb') as signfile:
    file_data = signfile.read()
    doc = docusign.Document()
    base64_doc = base64.b64encode(file_data).decode('utf-8')
    doc.document_base64 = base64_doc
    doc.name = "Signed_pdf.pdf"
    doc.document_id = '1'
    envelope_definition.documents = [doc]
    signfile.close()
envelope_definition.recipients = recipients
envelope_definition.status = 'sent'

api_client = docusign.ApiClient(base_url)

oauth_login_url = api_client.get_jwt_uri(integrator_key, redirect_uri, oauth_base_url)
print("oauth_login_url:", oauth_login_url)
print("oauth_base_url:", oauth_base_url)

api_client.configure_jwt_authorization_flow(private_key_filename, oauth_base_url, integrator_key, user_id, 3600)
docusign.configuration.api_client = api_client

auth_api = AuthenticationApi()
envelopes_api = EnvelopesApi()

try: #login here via code
    login_info = auth_api.login()
    login_accounts = login_info.login_accounts
    base_url, _ = login_accounts[0].base_url.split('/v2')
    api_client.host = base_url
    docusign.configuration.api_client = api_client

    envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition = envelope_definition)

    print(envelope_summary)
except ApiException as e:
    raise Exception("Exception when calling DocuSign API: %s" % e)
except Exception as e:
    print(e)
return HttpResponse({'sent'})

值得注意的是,我没有定义信封通知,也没有定义事件通知。我怀疑这可能是我没有收到电子邮件的原因。我浏览了文档,但我不太明白如何在 Django(我正在使用的 python 框架)中定义。这是我的电子邮件从未收到的正当理由吗?如果是这样,有人愿意在正确的方向上帮助我创建这些通知吗?

【问题讨论】:

    标签: django python-3.x docusignapi


    【解决方案1】:

    定义了 client_user_id 的收件人是“Captive”或“Embedded”收件人。在 Captive 工作流程中,您告诉 DocuSign 您将处理收件人身份验证和对信封的访问。

    如果您删除 client_user_id 参数,收件人将是标准的“远程”收件人,正常的电子邮件工作流程将继续。

    【讨论】:

    • 就是这样!太感谢了! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多