Skip to content

Commit d0e203b

Browse files
Devdocs 6128 (#48)
* add step admin4 step 4 and update text * update idv example * update comments eg023 * update error messages * IDV fix * edit eSign23 launcher homepage text * add additional workflow id check for phone auth Co-authored-by: meihDS <70775251+meihDS@users.noreply.github.com>
1 parent 22c7c5b commit d0e203b

File tree

5 files changed

+106
-84
lines changed

5 files changed

+106
-84
lines changed

app/controllers/e_sign/eg020_phone_authentication_controller.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ def create
66
if check_token(minimum_buffer_min)
77
begin
88
results = ESign::Eg020PhoneAuthenticationService.new(request, session).call
9-
session[:envelope_id] = results.envelope_id
10-
@title = 'Require Phone Authentication for a Recipient'
11-
@h1 = 'Require Phone Authentication for a Recipient'
12-
@message = "The envelope has been created and sent!<br/>Envelope ID #{results.envelope_id}."
13-
render 'ds_common/example_done'
9+
if results.to_s == "phone_auth_not_enabled"
10+
@error_code = "IDENTITY_WORKFLOW_INVALID_ID"
11+
@error_message = "The identity workflow ID specified is not valid."
12+
@error_information = "Please contact <a target='_blank' rel='noopener noreferrer' href='https://support.docusign.com/'>Support</a> to enable ID verification in your account."
13+
render 'ds_common/error'
14+
else
15+
session[:envelope_id] = results.envelope_id
16+
@title = 'Require Phone Authentication for a Recipient'
17+
@h1 = 'Require Phone Authentication for a Recipient'
18+
@message = "The envelope has been created and sent!<br/>Envelope ID #{results.envelope_id}."
19+
render 'ds_common/example_done'
20+
end
1421
rescue DocuSign_eSign::ApiError => e
1522
error = JSON.parse e.response_body
1623
@error_code = error['errorCode']

app/controllers/e_sign/eg023_idv_authentication_controller.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ def create
66
if check_token(minimum_buffer_min)
77
begin
88
results = ESign::Eg023IdvAuthenticationService.new(request, session).call
9-
if results.to_s == 'needs_idv_activated'
10-
@title = 'Error'
11-
@h1 = 'Error'
12-
@message = 'Please activate IDV on your account to use this example.'
13-
render 'ds_common/example_done'
14-
9+
if results.to_s == "idv_not_enabled"
10+
@error_code = "IDENTITY_WORKFLOW_INVALID_ID"
11+
@error_message = "The identity workflow ID specified is not valid."
12+
@error_information = "Please contact <a target='_blank' rel='noopener noreferrer' href='https://support.docusign.com/'>Support</a> to enable ID verification in your account."
13+
render 'ds_common/error'
14+
1515
else
1616
@title = 'Envelope sent'
1717
@h1 = 'Envelope sent'

app/services/e_sign/eg020_phone_authentication_service.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def initialize(request, session)
2424
end
2525

2626
def call
27+
if session[:workflow_id].blank?
28+
return "phone_auth_not_enabled"
29+
end
30+
2731
# Construct your envelope JSON body
2832
# Step 4 start
2933
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
@@ -114,10 +118,10 @@ def get_workflow(args)
114118
session[:workflow_id] = phone_auth_workflow.workflow_id
115119
return session[:workflow_id]
116120
else
117-
return None
121+
return ""
118122
end
119123
else
120-
return None
124+
return ""
121125
end
122126
# Step 3 end
123127

Lines changed: 79 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# frozen_string_literal: true
1+
# frozen_string_literal: true
22

33
class ESign::Eg023IdvAuthenticationService
44
include ApiCreator
@@ -21,75 +21,86 @@ def initialize(request, session)
2121
end
2222

2323
def call
24-
# ***DS.snippet.0.start
25-
26-
# Step 3. Obtain your workflow ID
24+
# Obtain your workflow ID
25+
# Step 3 start
2726
accounts_api = create_account_api(args)
28-
wf_res = accounts_api.get_account_identity_verification args[:account_id]
29-
workflow_id = wf_res.identity_verification[0].workflow_id
30-
27+
workflow_response = accounts_api.get_account_identity_verification args[:account_id]
28+
if workflow_response.identity_verification
29+
idv_workflow = workflow_response.identity_verification.find{ |item| item.default_name == "DocuSign ID Verification" }
30+
if idv_workflow
31+
workflow_id = idv_workflow.workflow_id
32+
end
33+
end
34+
# Step 3 end
35+
3136
if workflow_id.blank?
32-
"needs_idv_activated"
33-
34-
else
35-
# Step 4. Construct your envelope JSON body
36-
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
37-
envelope_definition.email_subject = 'Please sign this document set'
38-
39-
# Add the documents
40-
pdf_filename = "World_Wide_Corp_lorem.pdf"
41-
42-
# Create the document models
43-
document1 = DocuSign_eSign::Document.new(
44-
# Create the DocuSign Document object
45-
documentBase64: Base64.encode64(File.binread(File.join('data', pdf_filename))),
46-
name: 'Lorem', # Can be different from the actual file name
47-
fileExtension: 'pdf', # Many different document types are accepted
48-
documentId: '1' # A label used to reference the doc
49-
)
50-
51-
envelope_definition.documents = [document1]
52-
53-
# Create the signer recipient model
54-
signer1 = DocuSign_eSign::Signer.new
55-
signer1.email = envelope_args[:signer_email]
56-
signer1.name = envelope_args[:signer_name]
57-
signer1.recipient_id = '1'
58-
signer1.routing_order = '1'
59-
60-
sign_here1 = DocuSign_eSign::SignHere.new
61-
sign_here1.anchor_string = '/sn1/'
62-
sign_here1.anchor_units = 'pixels'
63-
sign_here1.anchor_x_offset = '20'
64-
sign_here1.anchor_y_offset = '10'
65-
66-
# Add the tabs model (including the sign_here tabs) to the signer
67-
# The Tabs object takes arrays of the different field/tab types
68-
signer1_tabs = DocuSign_eSign::Tabs.new ({
69-
signHereTabs: [sign_here1]
70-
})
71-
signer1.tabs = signer1_tabs
72-
73-
wf = DocuSign_eSign::RecipientIdentityVerification.new
74-
wf.workflow_id = workflow_id
75-
signer1.identity_verification = wf
76-
77-
# Add the recipients to the Envelope object
78-
recipients = DocuSign_eSign::Recipients.new(
79-
signers: [signer1]
80-
)
81-
# Request that the envelope be sent by setting status to "sent"
82-
# To request that the envelope be created as a draft, set status to "created"
83-
envelope_definition.recipients = recipients
84-
envelope_definition.status = envelope_args[:status]
85-
86-
# Step 5. Call the eSignature REST API
87-
envelope_api = create_envelope_api(args)
88-
results = envelope_api.create_envelope args[:account_id], envelope_definition
89-
session[:envelope_id] = results.envelope_id
90-
results
91-
92-
# ***DS.snippet.0.end
37+
return "idv_not_enabled"
9338
end
39+
40+
puts "WORKFLOW ID: "
41+
puts workflow_id
42+
43+
44+
# Construct your envelope JSON body
45+
# Step 4 start
46+
envelope_definition = DocuSign_eSign::EnvelopeDefinition.new
47+
envelope_definition.email_subject = 'Please sign this document set'
48+
49+
# Add the documents
50+
pdf_filename = "World_Wide_Corp_lorem.pdf"
51+
52+
# Create the document models
53+
document1 = DocuSign_eSign::Document.new(
54+
# Create the DocuSign Document object
55+
documentBase64: Base64.encode64(File.binread(File.join('data', pdf_filename))),
56+
name: 'Lorem', # Can be different from the actual file name
57+
fileExtension: 'pdf', # Many different document types are accepted
58+
documentId: '1' # A label used to reference the doc
59+
)
60+
61+
envelope_definition.documents = [document1]
62+
63+
# Create the signer recipient model
64+
signer1 = DocuSign_eSign::Signer.new
65+
signer1.email = envelope_args[:signer_email]
66+
signer1.name = envelope_args[:signer_name]
67+
signer1.recipient_id = '1'
68+
signer1.routing_order = '1'
69+
70+
sign_here1 = DocuSign_eSign::SignHere.new
71+
sign_here1.anchor_string = '/sn1/'
72+
sign_here1.anchor_units = 'pixels'
73+
sign_here1.anchor_x_offset = '20'
74+
sign_here1.anchor_y_offset = '10'
75+
76+
# Add the tabs model (including the sign_here tabs) to the signer
77+
# The Tabs object takes arrays of the different field/tab types
78+
signer1_tabs = DocuSign_eSign::Tabs.new ({
79+
signHereTabs: [sign_here1]
80+
})
81+
signer1.tabs = signer1_tabs
82+
83+
wf = DocuSign_eSign::RecipientIdentityVerification.new
84+
wf.workflow_id = workflow_id
85+
signer1.identity_verification = wf
86+
87+
# Add the recipients to the Envelope object
88+
recipients = DocuSign_eSign::Recipients.new(
89+
signers: [signer1]
90+
)
91+
# Request that the envelope be sent by setting status to "sent"
92+
# To request that the envelope be created as a draft, set status to "created"
93+
envelope_definition.recipients = recipients
94+
envelope_definition.status = envelope_args[:status]
95+
# Step 4 end
96+
97+
# Call the eSignature REST API
98+
# Step 5 start
99+
envelope_api = create_envelope_api(args)
100+
results = envelope_api.create_envelope args[:account_id], envelope_definition
101+
# Step 5 end
102+
103+
session[:envelope_id] = results.envelope_id
104+
results
94105
end
95106
end

app/views/e_sign/eg023_idv_authentication/get.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<h4>23. Send an envelope with recipient Id Verification authentication.</h4>
1+
<h4>23. Require ID verification (IDV) for a recipient</h4>
2+
<p>Sends an envelope that requires the recipient to upload a government-issued ID for the purpose of multifactor authentication.</p>
23
<p>Anchor text
34
(<a href="https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/tabs/auto-place/">AutoPlace</a>)
45
is used to position the signing fields in the documents.
56
</p>
6-
<p>This is an example of an envelope utilizing IDV authentication for multi-factor verification of a recipient. IDV is a service offered by DocuSign that allows your reicpient to upload a photo of a government issued id for verification.</p>
77

88
<% if @show_doc %>
99
<p><a target='_blank' href='<%= @documentation %>'>Documentation</a> about this example.</p>
@@ -31,4 +31,4 @@
3131
value="<%= @config.signer_name %>" required>
3232
</div>
3333
<button type="submit" class="btn btn-docu">Submit</button>
34-
</form>
34+
</form>

0 commit comments

Comments
 (0)