Skip to content

Commit b35c449

Browse files
committed
SDK-1039: Update example with modal QR
1 parent 0535152 commit b35c449

File tree

10 files changed

+139
-74
lines changed

10 files changed

+139
-74
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ examples/selfie.jpeg
77
examples/vendor
88
examples/*.pem
99
examples/keys/*.pem
10+
examples/sdk
1011

1112
logs
1213

examples/.env.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This file is a template for defining the environment variables
22
# Set the application config values here
33

4-
YOTI_APP_ID=xxxxxxxxxxxxxxxxxx
54
YOTI_SCENARIO_ID=xxxxxxxxxxxxxxxx
65
YOTI_SDK_ID=xxxxxxxxxxxxxxxxxxxxx
76
# Below is the private key (in .pem format) associated with the Yoti Application you created on Dashboard

examples/assets/css/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
margin: 30px 0;
4545
}
4646

47+
#yoti-share-button {
48+
width: 130px;
49+
height: 45px;
50+
}
51+
4752
.yoti-login-or-separator {
4853
text-transform: uppercase;
4954
font-family: Roboto;

examples/assets/css/profile.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,20 @@
308308
margin-left: 12px;
309309
}
310310

311+
.yoti-attribute-value-text table {
312+
font-size: 14px;
313+
border-spacing: 0;
314+
}
315+
316+
.yoti-attribute-value-text table td:first-child {
317+
font-weight: bold;
318+
}
319+
320+
.yoti-attribute-value-text table td {
321+
border-bottom: 1px solid #f7f8f9;
322+
padding: 5px;
323+
}
324+
311325
.yoti-attribute-value {
312326
grid-column: 2 / 3;
313327

examples/composer.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
{
22
"description": "testing yoti-php-sdk",
33
"require": {
4-
"yoti/yoti-php-sdk": "2.0.*",
4+
"yoti/yoti-php-sdk": "*",
55
"symfony/dotenv": "3.3.0"
6+
},
7+
"repositories": [
8+
{
9+
"type": "path",
10+
"url": "./sdk",
11+
"options": {
12+
"symlink": false
13+
}
14+
}
15+
],
16+
"scripts": {
17+
"copy-sdk-src": [
18+
"rm -rf ./vendor/yoti && rm -rf ./sdk && mkdir ./sdk",
19+
"cd .. && cp -R `ls -A | grep -v \"examples\"` ./examples/sdk && cd -"
20+
],
21+
"pre-install-cmd": [
22+
"@copy-sdk-src"
23+
],
24+
"pre-update-cmd": [
25+
"@copy-sdk-src"
26+
]
627
}
728
}

examples/composer.lock

Lines changed: 27 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ services:
1717
composer:
1818
image: composer/composer:php7
1919
volumes:
20-
- ./:/usr/share/nginx/html
21-
working_dir: /usr/share/nginx/html
20+
- ../:/usr/share/nginx/html
21+
working_dir: /usr/share/nginx/html/examples
2222
command: update

examples/index.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
<h1 class="yoti-top-header">We now accept Yoti</h1>
2525

2626
<div class="yoti-sdk-integration-section">
27-
<button data-yoti-application-id="<?php echo getenv('YOTI_APP_ID') ?>"
28-
data-yoti-type="inline"
29-
data-yoti-scenario-id="<?php echo getenv('YOTI_SCENARIO_ID') ?>">
30-
Use Yoti
31-
</button>
27+
<div id="yoti-share-button"></div>
3228
</div>
3329

3430
<div class="yoti-login-or-separator">or</div>
@@ -69,9 +65,17 @@
6965
</section>
7066
</main>
7167

72-
<script src="https://sdk.yoti.com/clients/browser.2.2.0.js"></script>
68+
<script src="https://www.yoti.com/share/client/"></script>
7369
<script>
74-
_ybg.init()
70+
window.Yoti.Share.init({
71+
"elements": [{
72+
"domId": "yoti-share-button",
73+
"scenarioId": "<?php echo htmlspecialchars(getenv('YOTI_SCENARIO_ID')); ?>",
74+
"button": {
75+
"label": "Use Yoti"
76+
}
77+
}]
78+
});
7579
</script>
7680
</body>
7781
</html>

examples/profile.inc.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
'name' => 'Nationality',
6262
'obj' => $profile->getNationality(),
6363
'icon' => 'yoti-icon-nationality',
64+
],
65+
[
66+
'name' => 'Structured Postal Address',
67+
'obj' => $profile->getStructuredPostalAddress(),
68+
'icon' => 'yoti-icon-profile',
6469
]
6570
];
6671

examples/profile.php

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,61 +35,73 @@
3535
</section>
3636

3737
<section class="yoti-attributes-section">
38-
<a href="/">
39-
<img class="yoti-company-logo" src="assets/images/company-logo.jpg" alt="company logo">
40-
</a>
38+
<a href="/">
39+
<img class="yoti-company-logo" src="assets/images/company-logo.jpg" alt="company logo">
40+
</a>
4141

42-
<div class="yoti-attribute-list-header">
43-
<div class="yoti-attribute-list-header-attribute">Attribute</div>
44-
<div class="yoti-attribute-list-header-value">Value</div>
45-
<div>Anchors</div>
46-
</div>
42+
<div class="yoti-attribute-list-header">
43+
<div class="yoti-attribute-list-header-attribute">Attribute</div>
44+
<div class="yoti-attribute-list-header-value">Value</div>
45+
<div>Anchors</div>
46+
</div>
4747

48-
<div class="yoti-attribute-list-subheader">
49-
<div class="yoti-attribute-list-subhead-layout">
50-
<div>S / V</div>
51-
<div>Value</div>
52-
<div>Sub type</div>
53-
</div>
54-
</div>
48+
<div class="yoti-attribute-list-subheader">
49+
<div class="yoti-attribute-list-subhead-layout">
50+
<div>S / V</div>
51+
<div>Value</div>
52+
<div>Sub type</div>
53+
</div>
54+
</div>
5555

56-
<div class="yoti-attribute-list">
56+
<div class="yoti-attribute-list">
5757

58-
<?php foreach($profileAttributes as $item): ?>
59-
<?php if ($item['obj']) : ?>
60-
<div class="yoti-attribute-list-item">
61-
<div class="yoti-attribute-name">
62-
<div class="yoti-attribute-name-cell">
63-
<i class="<?php echo $item['icon'] ?>"></i>
64-
<span class="yoti-attribute-name-cell-text"><?php echo $item['name'] ?></span>
65-
</div>
66-
</div>
58+
<?php foreach($profileAttributes as $item): ?>
59+
<?php if ($item['obj']) : ?>
60+
<div class="yoti-attribute-list-item">
61+
<div class="yoti-attribute-name">
62+
<div class="yoti-attribute-name-cell">
63+
<i class="<?php echo $item['icon'] ?>"></i>
64+
<span class="yoti-attribute-name-cell-text"><?php echo htmlspecialchars($item['name']) ?></span>
65+
</div>
66+
</div>
6767

68-
<div class="yoti-attribute-value">
68+
<div class="yoti-attribute-value">
69+
<div class="yoti-attribute-value-text">
6970
<?php
70-
$name = $item['name'];
71-
$attributeObj = $item['obj'];
72-
if ($name === 'Date of birth') {
73-
$value = $item['obj']->getValue()->format('d-m-Y');
74-
}
75-
elseif ($name === 'Age Verification') {
71+
$attributeObj = $item['obj'];
72+
switch ($item['name']) {
73+
case 'Date of birth';
74+
echo htmlspecialchars($item['obj']->getValue()->format('d-m-Y'));
75+
break;
76+
case 'Age Verification':
7677
// Because AgeVerification::class has a different structure
7778
$attributeObj = $item['obj']->getAttribute();
78-
$value = $ageVerificationStr;
79-
}
80-
else {
81-
$value = $item['obj']->getValue();
82-
}
83-
$anchors = $attributeObj->getAnchors();
79+
echo htmlspecialchars($ageVerificationStr);
80+
break;
81+
case 'Structured Postal Address':
82+
?>
83+
<table>
84+
<?php foreach ($item['obj']->getValue() as $key => $value): ?>
85+
<tr>
86+
<td><?php echo htmlspecialchars($key); ?></td>
87+
<td><?php echo htmlspecialchars($value); ?></td>
88+
</tr>
89+
<?php endforeach; ?>
90+
</table>
91+
<?php
92+
break;
93+
default:
94+
echo htmlspecialchars($item['obj']->getValue());
95+
}
8496
?>
85-
<div class="yoti-attribute-value-text"><?php echo $value; ?></div>
97+
</div>
8698
</div>
8799
<div class="yoti-attribute-anchors-layout">
88100
<div class="yoti-attribute-anchors-head -s-v">S / V</div>
89101
<div class="yoti-attribute-anchors-head -value">Value</div>
90102
<div class="yoti-attribute-anchors-head -subtype">Sub type</div>
91103

92-
<?php foreach($anchors as $anchor) : ?>
104+
<?php foreach($attributeObj->getAnchors() as $anchor) : ?>
93105
<div class="yoti-attribute-anchors -s-v"><?php echo $anchor->getType() ?></div>
94106
<div class="yoti-attribute-anchors -value"><?php echo $anchor->getValue() ?></div>
95107
<div class="yoti-attribute-anchors -subtype"><?php echo $anchor->getSubType() ?></div>

0 commit comments

Comments
 (0)