Skip to content

Commit 533a237

Browse files
committed
In Person Signer
1 parent 651cf90 commit 533a237

3 files changed

Lines changed: 17 additions & 53 deletions

File tree

app/eSignature/examples/eg039_in_person_signer.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from os import path
33

44
from docusign_esign import EnvelopesApi, RecipientViewRequest, Document, Signer, EnvelopeDefinition, SignHere, Tabs, \
5-
Recipients
5+
Recipients, InPersonSigner
66
from flask import session, url_for, request
77

88
from ...consts import authentication_method, demo_docs_path, pattern, signer_client_id
@@ -17,14 +17,11 @@ def get_args():
1717
# More data validation would be a good idea here
1818
# Strip anything other than characters listed
1919
# 1. Parse request arguments
20-
#response = DSClient.get_user(session["ds_access_token"])
21-
#print(response)
22-
host_name = "host_name"
23-
signer_name = "signer_name"
20+
signer_name = pattern.sub("", request.form.get("signer_name"))
2421
envelope_args = {
25-
"host_email": "raileendr@gmail.com",
26-
"host_name": "Raileen",
27-
"signer_name": "Fred",
22+
"host_email": session["ds_user_email"],
23+
"host_name": session["ds_user_name"],
24+
"signer_name": signer_name,
2825
"ds_return_url": url_for("ds.ds_return", _external=True),
2926
}
3027
args = {
@@ -59,13 +56,12 @@ def worker(cls, args):
5956
# 3. Create the Recipient View request object
6057
recipient_view_request = RecipientViewRequest(
6158
authentication_method=authentication_method,
62-
client_user_id=envelope_args["signer_client_id"],
6359
recipient_id="1",
6460
return_url=envelope_args["ds_return_url"],
6561
user_name=envelope_args["host_name"],
6662
email=envelope_args["host_email"]
6763
)
68-
# 4. Obtain the recipient_view_url for the embedded signing
64+
# 4. Obtain the recipient_view_url for the embedded signing session
6965
# Exceptions will be caught by the calling function
7066
results = envelope_api.create_recipient_view(
7167
account_id=args["account_id"],
@@ -100,17 +96,15 @@ def make_envelope(cls, args):
10096
document_id=1 # a label used to reference the doc
10197
)
10298

103-
# Create the signer recipient model
104-
signer = Signer(
99+
# Create the in person signer recipient model
100+
signer = InPersonSigner(
105101
# The signer
106102
host_name = args["host_name"],
107103
host_email = args["host_email"],
108104
signer_name = args["signer_name"],
109105
recipient_id="1",
110106
routing_order="1",
111-
112-
# Setting the client_user_id marks the signer as embedded
113-
#client_user_id=args["signer_client_id"]
107+
114108
)
115109

116110
# Create a sign_here tab (field on the document)
@@ -124,14 +118,14 @@ def make_envelope(cls, args):
124118

125119
# Add the tabs model (including the sign_here tab) to the signer
126120
# The Tabs object wants arrays of the different field/tab types
127-
signer.tabs = Tabs(sign_here_tabs=[sign_here])
121+
InPersonSigner.tabs = Tabs(sign_here_tabs=[sign_here])
128122

129123
# Next, create the top level envelope definition and populate it.
130124
envelope_definition = EnvelopeDefinition(
131125
email_subject="Please host this in-person signing session",
132126
documents=[document],
133127
# The Recipients object wants arrays for each recipient type
134-
recipients=Recipients(signers=[signer]),
128+
recipients=Recipients(in_person_signers=[signer]),
135129
status="sent" # requests that the envelope be created and sent.
136130
)
137131

app/eSignature/views/eg039_in_person_signer.py

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from os import path
44

55
from docusign_esign.client.api_exception import ApiException
6-
from flask import render_template, session, Blueprint, request
6+
from flask import render_template, redirect, session, Blueprint, request
77

88
from ..examples.eg039_in_person_signer import Eg039InPersonSigner
99
from ...docusign import authenticate
@@ -14,30 +14,6 @@
1414
eg = "eg039" # reference (and url) for this example
1515
eg039 = Blueprint("eg039", __name__)
1616

17-
# def get_args():
18-
# """Get request and session arguments"""
19-
20-
# # More data validation would be a good idea here
21-
# # Strip anything other than characters listed
22-
# host_email = pattern.sub("", session.get("host_email"))
23-
# host_name = pattern.sub("", session.get("host_name"))
24-
# signer_email = pattern.sub("", session.get("signer_email"))
25-
# signer_name = pattern.sub("", session.get("signer_name"))
26-
# envelope_args = {
27-
# "host_email": host_email,
28-
# "host_name": host_name,
29-
# #"signer_email": signer_email,
30-
# "signer_name": signer_name,
31-
# "status": "sent",
32-
# }
33-
# args = {
34-
# "account_id": session["ds_account_id"],
35-
# "base_path": session["ds_base_path"],
36-
# "access_token": session["ds_access_token"],
37-
# "envelope_args": envelope_args
38-
# }
39-
# return args
40-
4117
@eg039.route("/eg039", methods=["POST"])
4218
@authenticate(eg=eg)
4319
def in_person_signer():
@@ -57,13 +33,8 @@ def in_person_signer():
5733

5834
session["envelope_id"] = results["envelope_id"] # Save for use by other examples which need an envelopeId
5935

60-
# 2. Render success response with envelopeId
61-
return render_template(
62-
"example_done.html",
63-
title="Envelope sent",
64-
h1="Envelope sent",
65-
message=f"The envelope has been created and sent!<br/>Envelope ID {results['envelope_id']}."
66-
)
36+
# 2. Redirect to in person signing session
37+
return redirect(results["redirect_url"])
6738

6839

6940
@eg039.route("/eg039", methods=["GET"])
@@ -79,5 +50,4 @@ def get_view():
7950
documentation=DS_CONFIG["documentation"] + eg,
8051
show_doc=DS_CONFIG["documentation"],
8152
signer_name=DS_CONFIG["signer_name"],
82-
#signer_email=DS_CONFIG["signer_email"]
8353
)

app/templates/eg039_in_person_signer.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ <h4>Send an envelope to an In Person Signer</h4>
1818

1919
<form class="eg" action="" method="post" data-busy="form">
2020
<div class="form-group">
21-
<label for="signerName">Signer Name</label>
22-
<input type="text" class="form-control" id="signerName" placeholder="Pat Johnson" name="signerName"
23-
required />
21+
<label for="signer_name">Signer Name</label>
22+
<input type="text" class="form-control" id="signer_name" placeholder="Pat Johnson" name="signer_name"
23+
value="{{ signer_name }}" required />
2424
</div>
2525
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
2626
<button type="submit" class="btn btn-docu">Submit</button>

0 commit comments

Comments
 (0)