Skip to content

Commit a0a5d89

Browse files
2 parents 0a5e065 + 2a47352 commit a0a5d89

6 files changed

Lines changed: 135 additions & 29 deletions

File tree

‎Dockerfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ RUN docker-php-ext-install \
5858
WORKDIR /var/www/html
5959
COPY src src/
6060
COPY --from=composer_stage /usr/bin/composer /usr/bin/composer
61-
COPY composer.json /var/www/html/
61+
COPY composer.json composer.lock /var/www/html/
6262
# Install composer dependencies
63-
RUN composer install --no-dev --optimize-autoloader
63+
RUN composer install --no-dev --optimize-autoloader --no-interaction --no-progress
6464

6565
CMD ["php-fpm"]
6666

‎azure-pipelines.yml‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ steps:
7171
cp $(php_private_key.secureFilePath) code-examples-php-private/private.key
7272
displayName: 'place private.key'
7373

74-
- task: DownloadSecureFile@1
75-
name: php_dockerfile
76-
displayName: 'download Dockerfile'
77-
inputs:
78-
secureFile: 'php.Dockerfile'
79-
80-
81-
- script: |
82-
echo "place Dockerfile"
83-
cp $(php_dockerfile.secureFilePath) code-examples-php-private/Dockerfile
84-
displayName: 'place Dockerfile'
85-
8674
- script: dir $(Build.SourcesDirectory)
8775

8876
- script: dir $(Build.SourcesDirectory)/code-examples-php-private
@@ -104,6 +92,14 @@ steps:
10492
docker system prune -f
10593
displayName: 'cleanup docker env'
10694

95+
- script: |
96+
cd code-examples-php-private
97+
echo "Verify Dockerfile and lockfile in workspace"
98+
test -f Dockerfile
99+
test -f composer.lock
100+
grep -n "COPY composer.json composer.lock" Dockerfile
101+
displayName: 'verify docker inputs'
102+
107103
- script: |
108104
cd code-examples-php-private
109105
docker compose up -d --build

‎src/Controllers/Examples/eSignature/EG044FocusedView.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,18 @@ public function createController(): void
6666
*/
6767
public function getTemplateArgs(): array
6868
{
69+
$countryCode = isset($_POST['country_code']) && $_POST['country_code'] !== ''
70+
? $this->checkInputValues($_POST['country_code'])
71+
: null;
72+
$phoneNumber = isset($_POST['phone_number']) && $_POST['phone_number'] !== ''
73+
? $this->checkInputValues($_POST['phone_number'])
74+
: null;
75+
6976
$envelope_args = [
7077
'signer_email' => $this->checkInputValues($_POST['signer_email']),
7178
'signer_name' => $this->checkInputValues($_POST['signer_name']),
79+
'phone_number' => $phoneNumber,
80+
'country_code' => $countryCode,
7281
'signer_client_id' => $this->signer_client_id,
7382
'ds_return_url' => $GLOBALS['app_url'] . 'index.php?page=ds_return'
7483
];

‎src/Services/Examples/eSignature/FocusedViewService.php‎

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,50 @@
66
use DocuSign\eSign\Client\ApiException;
77
use DocuSign\eSign\Model\Document;
88
use DocuSign\eSign\Model\EnvelopeDefinition;
9+
use DocuSign\eSign\Model\RecipientIdentityInputOption;
10+
use DocuSign\eSign\Model\RecipientIdentityPhoneNumber;
11+
use DocuSign\eSign\Model\RecipientIdentityVerification;
912
use DocuSign\eSign\Model\Recipients;
1013
use DocuSign\eSign\Model\Signer;
11-
use DocuSign\eSign\Model\SignHere;
12-
use DocuSign\eSign\Model\Tabs;
1314
use DocuSign\Services\SignatureClientService;
1415

1516
class FocusedViewService
1617
{
1718
public static function worker(array $args, SignatureClientService $client_service, string $demo_path, string $pdf_file): array
1819
{
20+
if (!empty($args['envelope_args']['phone_number'])) {
21+
try {
22+
$accounts_api = $client_service->getAccountsApi();
23+
$accounts_response = $accounts_api->getAccountIdentityVerificationWithHttpInfo($args['account_id']);
24+
25+
$remaining = $accounts_response[2]['X-RateLimit-Remaining'] ?? null;
26+
$reset = $accounts_response[2]['X-RateLimit-Reset'] ?? null;
27+
28+
if ($remaining !== null && $reset !== null) {
29+
$reset_instant = (new DateTime())->setTimestamp((int)$reset);
30+
error_log("API calls remaining: $remaining");
31+
error_log("Next Reset: " . $reset_instant->format(\DateTime::ATOM));
32+
}
33+
34+
$workflow_id = '';
35+
$workflows_data = $accounts_response[0]->getIdentityVerification();
36+
foreach ($workflows_data as $workflow) {
37+
if ($workflow['default_name'] === 'Phone Authentication') {
38+
$workflow_id = $workflow['workflow_id'];
39+
}
40+
}
41+
42+
if ($workflow_id === '') {
43+
throw new ApiException('IDENTITY_WORKFLOW_INVALID_ID');
44+
}
45+
46+
$args['envelope_args']['workflow_id'] = $workflow_id;
47+
} catch (ApiException $e) {
48+
$client_service->showErrorTemplate($e);
49+
exit;
50+
}
51+
}
52+
1953
#ds-snippet-start:eSign44Step3
2054
$envelope_definition = FocusedViewService::makeEnvelope($args['envelope_args'], $demo_path, $pdf_file);
2155
$envelope_api = $client_service->getEnvelopeApi();
@@ -80,16 +114,22 @@ public static function makeEnvelope(array $args, string $demo_path, string $pdf_
80114
]
81115
);
82116

83-
$sign_here = new SignHere(
84-
[
85-
'anchor_string' => '/sn1/',
86-
'anchor_units' => 'pixels',
87-
'anchor_y_offset' => '10',
88-
'anchor_x_offset' => '20'
89-
]
90-
);
117+
if (!empty($args['phone_number'])) {
118+
$phone_number = new RecipientIdentityPhoneNumber();
119+
$phone_number->setCountryCode($args['country_code'] ?? '');
120+
$phone_number->setNumber($args['phone_number']);
91121

92-
$signer->settabs(new Tabs(['sign_here_tabs' => [$sign_here]]));
122+
$input_option = new RecipientIdentityInputOption();
123+
$input_option->setName('phone_number_list');
124+
$input_option->setValueType('PhoneNumberList');
125+
$input_option->setPhoneNumberList([$phone_number]);
126+
127+
$identity_verification = new RecipientIdentityVerification();
128+
$identity_verification->setWorkflowId($args['workflow_id']);
129+
$identity_verification->setInputOptions([$input_option]);
130+
131+
$signer->setIdentityVerification($identity_verification);
132+
}
93133

94134
return new EnvelopeDefinition(
95135
[

‎templates/esignature/eg044_focused_view.html‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
{% set formNumber = 0 %}
44
{% set signerEmailInputNumber = 0 %}
55
{% set signerNameInputNumber = 1 %}
6+
{% set phoneAuthFormNumber = 1 %}
7+
{% set countryCodeInputNumber = 0 %}
8+
{% set phoneNumberInputNumber = 1 %}
69

710
<h4>{{ code_example_text['ExampleName'] | raw }}</h4>
811
<p>{{ code_example_text["ExampleDescription"] | raw }}</p>
@@ -67,6 +70,45 @@ <h4>{{ code_example_text['ExampleName'] | raw }}</h4>
6770
value="{{ signer_name }}"
6871
required>
6972
</div>
73+
74+
<br/>
75+
{% if code_example_text['Forms'] is defined and code_example_text['Forms'][phoneAuthFormNumber] is defined and code_example_text['Forms'][phoneAuthFormNumber]['FormName'] is defined %}
76+
{{ code_example_text['Forms'][phoneAuthFormNumber]['FormName'] | raw }}
77+
{% endif %}
78+
79+
<div class="form-group">
80+
<label for="country_code">
81+
{% if code_example_text['Forms'] is defined and code_example_text['Forms'][phoneAuthFormNumber] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][countryCodeInputNumber] is defined %}
82+
{{ code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][countryCodeInputNumber]['InputName'] | raw }}
83+
{% else %}
84+
Country code
85+
{% endif %}
86+
</label>
87+
88+
<input type="text"
89+
class="form-control"
90+
id="country_code"
91+
name="country_code"
92+
placeholder="{% if code_example_text['Forms'] is defined and code_example_text['Forms'][phoneAuthFormNumber] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][countryCodeInputNumber] is defined %}{{ code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][countryCodeInputNumber]['InputPlaceholder'] }}{% else %}e.g. 1{% endif %}">
93+
</div>
94+
95+
<div class="form-group">
96+
<label for="phone_number">
97+
{% if code_example_text['Forms'] is defined and code_example_text['Forms'][phoneAuthFormNumber] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][phoneNumberInputNumber] is defined %}
98+
{{ code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][phoneNumberInputNumber]['InputName'] | raw }}
99+
{% else %}
100+
Phone number
101+
{% endif %}
102+
</label>
103+
104+
<input type="text"
105+
class="form-control"
106+
id="phone_number"
107+
name="phone_number"
108+
aria-describedby="phoneHelp"
109+
placeholder="{% if code_example_text['Forms'] is defined and code_example_text['Forms'][phoneAuthFormNumber] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'] is defined and code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][phoneNumberInputNumber] is defined %}{{ code_example_text['Forms'][phoneAuthFormNumber]['Inputs'][phoneNumberInputNumber]['InputPlaceholder'] }}{% else %}e.g. 5551234567{% endif %}">
110+
<small id="phoneHelp" class="form-text text-muted">Provide a phone number to enable phone authentication for the signer.</small>
111+
</div>
70112

71113
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
72114
<button type="submit" class="btn btn-docu">{{ common_texts["SubmitButton"] | raw }}</button>

‎templates/esignature/embed.html‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ <h2>The document has been embedded with focused view.</h2>
3232
</body>
3333
</html>
3434

35-
<p><a href="/public/">Continue</a></p>
36-
3735
<script src='https://js.docusign.com/bundle.js'></script>
3836
<script>
3937
window.DocuSign.loadDocuSign('{{ integration_key }}')
@@ -46,7 +44,7 @@ <h2>The document has been embedded with focused view.</h2>
4644
branding: {
4745
primaryButton: {
4846
/** Background color of primary button */
49-
backgroundColor: '#333',
47+
backgroundColor: '#50C878',
5048
/** Text color of primary button */
5149
color: '#fff',
5250
}
@@ -55,7 +53,27 @@ <h2>The document has been embedded with focused view.</h2>
5553
/** High-level components we allow specific overrides for */
5654
signingNavigationButton: {
5755
finishText: 'You have finished the document! Hooray!',
58-
position: 'bottom-center'
56+
position: 'bottom-center',
57+
shape: 'pill'
58+
},
59+
60+
signingAgreeButton: {
61+
finishText: 'I Agree'
62+
},
63+
64+
signingDeclineButton: {
65+
show: true,
66+
finishText: 'Decline',
67+
backgroundColor: '#ff0000',
68+
color: '#ffffff'
69+
},
70+
71+
downloadModal: {
72+
show: true
73+
},
74+
75+
declineModal: {
76+
show: true
5977
}
6078
}
6179
});
@@ -67,6 +85,7 @@ <h2>The document has been embedded with focused view.</h2>
6785
signing.on('sessionEnd', (event) => {
6886
/** The event here denotes what caused the sessionEnd to trigger, such as signing_complete, ttl_expired etc../ **/
6987
console.log('sessionend', event);
88+
window.location.href = '/public/';
7089
});
7190

7291
signing.mount('#agreement');

0 commit comments

Comments
 (0)