我正在为我的公司开发Django网络应用程序,该应用程序将允许用户(或我们的销售伙伴)输入客户信息,Weasyprint将从中生成包含所有信息的PDF,并允许用户签名使用Docusign的Python SDK以数字方式进行docusign。此时一切正常,减去发送给要签名的收件人的电子邮件。我不确定为什么会这样,在向Docusign的员工寻求帮助之后,他们似乎都不知道发生了什么问题。这是我用来创建和发送信封的代码:
loa = LOA.objects.filter().order_by('-id')[0] #Model in my SQLite database being used to retrieve the saved PDF for sending.
localbillingname = loa.billingname.replace(" ", "_")
username = "myusername"
integrator_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
base_url = "https://demo.docusign.net/restapi"
oauth_base_url = "account-d.docusign.com"
redirect_uri = "http://MyRedirectUrl.com/"
private_key_filename = "path/to/pKey.txt"
user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client_user_id = 'Your Local System ID' #This is the actual string being used
# Add a recipient to sign the document
signer = docusign.Signer()
signer.email = loa.email
signer.name = loa.ainame
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 Document!'
envelope_definition.email_blurb = 'Please sign the following document to complete the service transfer process!'
# Add a document to the envelope_definition
pdfpath = "Path/to/my/pdf.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 = "mypdf.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'})
当我检查沙盒页面时,我看到信封被列为已发送到正确的电子邮件,其中包含要签名的正确文档以及正确的信息。但是,无论我设置为谁,都永远不会收到电子邮件。有人知道为什么会这样吗?
提前谢谢!