@@ -34,7 +34,35 @@ public static function setTabValues(array $args, $demoDocsPath, $clientService):
3434 # 1. Create the envelope request object
3535 $ envelope_definition = SetTabValuesService::makeEnvelope ($ args ["envelope_args " ], $ demoDocsPath );
3636
37- return SetTemplateTabValuesService::sendEnvelopeFromCreatedTemplate ($ clientService , $ args , $ envelope_definition );
37+ return SetTabValuesService::sendEnvelope ($ clientService , $ args , $ envelope_definition );
38+ }
39+
40+ public static function sendEnvelope ($ clientService , $ args , $ envelope_definition ): array
41+ {
42+ # Call Envelopes::create API method
43+ # Exceptions will be caught by the calling function
44+ #ds-snippet-start:eSign16Step4
45+ $ envelope_api = $ clientService ->getEnvelopeApi ();
46+ $ envelopeResponse = $ envelope_api ->createEnvelope ($ args ['account_id ' ], $ envelope_definition );
47+ $ envelope_id = $ envelopeResponse ->getEnvelopeId ();
48+ #ds-snippet-end:eSign16Step4
49+
50+ # Create the Recipient View request object
51+ #ds-snippet-start:eSign16Step5
52+ $ authentication_method = 'None ' ; # How is this application authenticating
53+ # the signer? See the `authentication_method' definition
54+ # https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeViews/createRecipient
55+ $ recipient_view_request = $ clientService ->getRecipientViewRequest (
56+ $ authentication_method ,
57+ $ args ["envelope_args " ]
58+ );
59+
60+ # Obtain the recipient_view_url for the embedded signing
61+ # Exceptions will be caught by the calling function
62+ $ recipientView = $ clientService ->getRecipientView ($ args ['account_id ' ], $ envelope_id , $ recipient_view_request );
63+ #ds-snippet-end:eSign16Step5
64+
65+ return ['envelope_id ' => $ envelope_id , 'redirect_url ' => $ recipientView ['url ' ]];
3866 }
3967
4068 /**
@@ -46,7 +74,7 @@ public static function setTabValues(array $args, $demoDocsPath, $clientService):
4674 * @return mixed -- returns an envelope definition
4775 */
4876
49- # Step 4 start
77+ #ds-snippet- start:eSign16Step3
5078 public static function makeEnvelope (array $ args , $ demoDocsPath ): EnvelopeDefinition
5179 {
5280 # document 1 (pdf) has tags
@@ -68,7 +96,6 @@ public static function makeEnvelope(array $args, $demoDocsPath): EnvelopeDefinit
6896 $ content_bytes = file_get_contents ($ demoDocsPath . $ doc_name );
6997 $ base64_file_content = base64_encode ($ content_bytes );
7098
71- # Step 3 start
7299 # Create the document model
73100 $ document = new Document ([ # create the DocuSign document object
74101 'document_base64 ' => $ base64_file_content ,
@@ -156,7 +183,7 @@ public static function makeEnvelope(array $args, $demoDocsPath): EnvelopeDefinit
156183 $ custom_fields = new CustomFields ([
157184 'text_custom_fields ' => [$ salary_custom_field ]]);
158185
159- # Step 3 end
186+
160187 # Next, create the top level envelope definition and populate it.
161188 return new EnvelopeDefinition ([
162189 'email_subject ' => "Please sign this document sent from the PHP SDK " ,
@@ -167,5 +194,5 @@ public static function makeEnvelope(array $args, $demoDocsPath): EnvelopeDefinit
167194 'custom_fields ' => $ custom_fields
168195 ]);
169196 }
170- # Step 4 end
197+ #ds-snippet- end:eSign16Step3
171198}
0 commit comments