|
1 | 1 | <?php
|
2 |
| - |
3 |
| -// Load dependent packages and env data |
4 |
| -require_once __DIR__ . '/bootstrap.php'; |
5 |
| - |
6 |
| -// Get the token |
7 |
| -$token = isset($_GET['token']) ? $_GET['token'] : ''; |
8 |
| -$profileAttributes = []; |
9 |
| - |
10 |
| -try { |
11 |
| - $yotiConnectApi = getenv('YOTI_CONNECT_API') ?: Yoti\YotiClient::DEFAULT_CONNECT_API; |
12 |
| - $yotiClient = new Yoti\YotiClient( |
13 |
| - getenv('YOTI_SDK_ID'), |
14 |
| - getenv('YOTI_KEY_FILE_PATH'), |
15 |
| - $yotiConnectApi |
16 |
| - ); |
17 |
| - $activityDetails = $yotiClient->getActivityDetails($token); |
18 |
| - $profile = $activityDetails->getProfile(); |
19 |
| - $ageVerifications = $profile->getAgeVerifications(); |
20 |
| - $ageVerification = current($ageVerifications); |
21 |
| - |
22 |
| - $profileAttributes = [ |
23 |
| - [ |
24 |
| - 'name' => 'Given names', |
25 |
| - 'obj' => $profile->getGivenNames(), |
26 |
| - 'icon' => 'yoti-icon-profile', |
27 |
| - ], |
28 |
| - [ |
29 |
| - 'name' => 'Family names', |
30 |
| - 'obj' => $profile->getFamilyName(), |
31 |
| - 'icon' => 'yoti-icon-profile', |
32 |
| - ], |
33 |
| - [ |
34 |
| - 'name' => 'Mobile number', |
35 |
| - 'obj' => $profile->getPhoneNumber(), |
36 |
| - 'icon' => 'yoti-icon-phone', |
37 |
| - ], |
38 |
| - [ |
39 |
| - 'name' => 'Email address', |
40 |
| - 'obj' => $profile->getEmailAddress(), |
41 |
| - 'icon' => 'yoti-icon-email', |
42 |
| - ], |
43 |
| - [ |
44 |
| - 'name' => 'Date of birth', |
45 |
| - 'obj' => $profile->getDateOfBirth(), |
46 |
| - 'icon' => 'yoti-icon-calendar', |
47 |
| - ], |
48 |
| - [ |
49 |
| - 'name' => 'Age Verification', |
50 |
| - 'obj' => $ageVerification, |
51 |
| - 'icon' => 'yoti-icon-calendar', |
52 |
| - ], |
53 |
| - [ |
54 |
| - 'name' => 'Address', |
55 |
| - 'obj' => $profile->getPostalAddress(), |
56 |
| - 'icon' => 'yoti-icon-address', |
57 |
| - ], |
58 |
| - [ |
59 |
| - 'name' => 'Gender', |
60 |
| - 'obj' => $profile->getGender(), |
61 |
| - 'icon' => 'yoti-icon-gender', |
62 |
| - ], |
63 |
| - [ |
64 |
| - 'name' => 'Nationality', |
65 |
| - 'obj' => $profile->getNationality(), |
66 |
| - 'icon' => 'yoti-icon-nationality', |
67 |
| - ] |
68 |
| - ]; |
69 |
| - |
70 |
| - $fullName = $profile->getFullName(); |
71 |
| - $selfie = $profile->getSelfie(); |
72 |
| - $selfieFileName = 'selfie.jpeg'; |
73 |
| - |
74 |
| - // Create selfie image file. |
75 |
| - if ($selfie && is_writable(__DIR__)) { |
76 |
| - file_put_contents($selfieFileName, $selfie->getValue()->getContent(), LOCK_EX); |
77 |
| - } |
78 |
| -} catch(\Exception $e) { |
79 |
| - header('Location: /error.php?msg='.$e->getMessage()); |
80 |
| - exit; |
81 |
| -} |
| 2 | +require_once __DIR__ . '/profile.inc.php'; |
82 | 3 | ?>
|
83 | 4 | <!DOCTYPE html>
|
84 | 5 | <html class="yoti-html">
|
|
101 | 22 |
|
102 | 23 | <div class="yoti-profile-picture-section">
|
103 | 24 | <?php if ($profile->getSelfie()) : ?>
|
104 |
| - <div class="yoti-profile-picture-area"> |
105 |
| - <img src="./<?php echo $selfieFileName ?>" class="yoti-profile-picture-image" alt="Yoti" /> |
106 |
| - <i class="yoti-profile-picture-verified-icon"></i> |
107 |
| - </div> |
| 25 | + <div class="yoti-profile-picture-area"> |
| 26 | + <img src="./<?php echo $selfieFileName ?>" class="yoti-profile-picture-image" alt="Yoti" /> |
| 27 | + <i class="yoti-profile-picture-verified-icon"></i> |
| 28 | + </div> |
108 | 29 | <?php endif; ?>
|
109 | 30 |
|
110 | 31 | <div class="yoti-profile-name">
|
111 |
| - <?php echo $fullName? $fullName->getValue() : '' ?> |
| 32 | + <?php echo $fullName ? $fullName->getValue() : '' ?> |
112 | 33 | </div>
|
113 | 34 | </div>
|
114 | 35 | </section>
|
|
148 | 69 | <?php
|
149 | 70 | $name = $item['name'];
|
150 | 71 | $attributeObj = $item['obj'];
|
151 |
| - switch($name) { |
152 |
| - case 'Date of birth': |
153 |
| - $value = $item['obj']->getValue()->format('d-m-Y'); |
154 |
| - break; |
155 |
| - case 'Age Verification': |
156 |
| - $attributeObj = $item['obj']->getAttribute(); |
157 |
| - $result = $ageVerification->getResult() ? 'Yes' : 'No'; |
158 |
| - $value = $ageVerification->getChecktype() . ':' . $ageVerification->getAge() |
159 |
| - . ' ' . $result; |
160 |
| - break; |
161 |
| - default: |
162 |
| - $value = $item['obj']->getValue(); |
| 72 | + if ($name === 'Date of birth') { |
| 73 | + $value = $item['obj']->getValue()->format('d-m-Y'); |
| 74 | + } |
| 75 | + elseif ($name === 'Age Verification') { |
| 76 | + // Because AgeVerification::class has a different structure |
| 77 | + $attributeObj = $item['obj']->getAttribute(); |
| 78 | + $value = $ageVerificationStr; |
| 79 | + } |
| 80 | + else { |
| 81 | + $value = $item['obj']->getValue(); |
163 | 82 | }
|
164 |
| - |
165 | 83 | $anchors = $attributeObj->getAnchors();
|
166 | 84 | ?>
|
167 | 85 | <div class="yoti-attribute-value-text"><?php echo $value; ?></div>
|
|
172 | 90 | <div class="yoti-attribute-anchors-head -subtype">Sub type</div>
|
173 | 91 |
|
174 | 92 | <?php foreach($anchors as $anchor) : ?>
|
175 |
| - <div class="yoti-attribute-anchors -s-v"><?php echo $anchor->getType(); ?></div> |
| 93 | + <div class="yoti-attribute-anchors -s-v"><?php echo $anchor->getType() ?></div> |
176 | 94 | <div class="yoti-attribute-anchors -value"><?php echo $anchor->getValue() ?></div>
|
177 | 95 | <div class="yoti-attribute-anchors -subtype"><?php echo $anchor->getSubType() ?></div>
|
178 | 96 | <?php endforeach; ?>
|
|
0 commit comments