Skip to content

Commit 965c6df

Browse files
committed
added country fields to support verification
1 parent 9cdc4c7 commit 965c6df

File tree

9 files changed

+96
-21
lines changed

9 files changed

+96
-21
lines changed

client/public/locales/en/BuyNewInsurance.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,25 @@
7474
"HealthState": "State of health",
7575
"Street": "Street",
7676
"City": "City",
77+
"Country": "Country:",
7778
"State": "State",
7879
"ZipCode": "Zip code",
7980
"Options": [
80-
{ "name": "Car", "detail1": "Car model", "detail2": "Year" },
81-
{ "name": "Home", "detail1": "Home year", "detail2": "Worth" },
82-
{ "name": "Life", "detail1": "Age", "detail2": "State of health" }
81+
{
82+
"name": "Car",
83+
"detail1": "Car model",
84+
"detail2": "Year"
85+
},
86+
{
87+
"name": "Home",
88+
"detail1": "Home year",
89+
"detail2": "Worth"
90+
},
91+
{
92+
"name": "Life",
93+
"detail1": "Age",
94+
"detail2": "State of health"
95+
}
8396
],
8497
"Error": {
8598
"FirstName": "First name is required.",
@@ -89,6 +102,7 @@
89102
"State": "State is required.",
90103
"ZipCode": "Zip code is required.",
91104
"Email": "Email is required.",
105+
"Country": "Country is required.",
92106
"insuranceDetails": "Please provide your insurance details."
93107
},
94108
"ApiDecription": {

client/public/locales/en/SubmitClaim.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Street": "Street:",
1313
"City": "City:",
1414
"State": "State:",
15+
"Country": "Country:",
1516
"ZipCode": "Zip code:",
1617
"DescriptionPlaseholder": "",
1718
"Date": "Date:",
@@ -96,11 +97,12 @@
9697
"Street": "Street is required.",
9798
"City": "City is required.",
9899
"State": "State is required.",
100+
"Country": "Country is required.",
99101
"ZipCode": "Zip code is required.",
100102
"Description": "Description is required."
101103
},
102104
"ApiDecription": {
103105
"SeeMore": "- See behind the scenes",
104106
"CodeFlow": "<p>View source files <a href='https://github.com/docusign/sample-app-mysure-python/blob/master/app/document.py#L26-L132' target='blank' rel='norefferer noopener'>document.py</a> and <a href='https://github.com/docusign/sample-app-mysure-python/blob/master/app/envelope.py#L10-L65' target='blank' rel='norefferer noopener'>envelope.py</a> on GitHub.</p><h3>This sample features:</h3><ul><li>Update recipient information</li><li>Create envelope from HTML Import</li><li>Fill tab data</li><li>Embedded signing (recipient view)</li<li>Optional tab</li><li>Attachment tab></ul><h3>Code flow:</h3><h5>Step 1</h5><p>When the form is submitted, we use the <a target=\"_blank\" href='https://developers.docusign.com/docs/esign-rest-api/reference/Envelopes/Envelopes/create'>Envelopes: create</a> method to send the signature request with the corresponding form information. The envelope we construct contains various data: specifically, a <code>document</code> object, a <code>recipient</code> object with the type <code>signer</code>, and <code>tabs</code> objects, which contain form field information. Since we are using embedded signing, we must also set the <code>clientUserId</code> property on the recipient.</p><p>We place the tabs on the document by specifying a <code>SignHereTab</code> element and an <code>InitialTab</code> element as part of the <code>signer</code> element. The tab elements are positioned using <em>x/y</em> coordinates on the <code>document</code>.</p><p>Last, we include the status \"sent\" in the request so that the envelope is sent for signing.</p><p>The eSignature REST API request is sent to the following endpoint:</p><pre>POST /v2.1/accounts/{accountId}/envelopes</pre><h5>Step 2</h5><p>To enable embedded signing of the envelope inside our application, we next use the <a target=\"_blank\" href='https://developers.docusign.com/docs/esign-rest-api/reference/Envelopes/EnvelopeViews/createRecipient'>EnvelopeViews: createRecipient</a> method to generate a signing URL for the recipient. For this to work, the <code>clientUserId</code> property must be set on the recipient when the envelope is sent during step 1 above.</p><p>Once the envelope is sent, we save the envelope ID and recipient information to our session. Then, we retrieve the envelope ID and recipient info from our session and create the recipient view by generating the URL and displaying the recipient view in a full-width and full-height iframe inside our page.</p><p>To create the recipient view of the envelope, we send an API request to:</p><pre>POST /v2.1/accounts/{accountId}/envelopes/{envelopeId}/views/recipient</pre>"
105107
}
106-
}
108+
}

client/src/pages/buyNewInsurance/components/RequestForm.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const RequestForm = ({
164164
error={errors.city}
165165
/>
166166
<div className="row">
167-
<div className="col-md-6">
167+
<div>
168168
<InputSelect
169169
name="state"
170170
label={t("State")}
@@ -176,6 +176,13 @@ export const RequestForm = ({
176176
error={errors.state}
177177
/>
178178
</div>
179+
<InputText
180+
name="country"
181+
label={t("Country")}
182+
value={request.country}
183+
onChange={onChange}
184+
error={errors.country}
185+
/>
179186
<div className="col-md-6">
180187
<InputText
181188
name="zipCode"

client/src/pages/buyNewInsurance/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const initialState = {
2323
name: "",
2424
value: "",
2525
detail1: "",
26-
detail2: ""
26+
detail2: "",
27+
country: ""
2728
}
2829
};
2930

@@ -63,7 +64,8 @@ export const BuyNewInsurance = () => {
6364
street: request.street,
6465
city: request.city,
6566
state: request.state,
66-
zip_code: request.zipCode
67+
zip_code: request.zipCode,
68+
country: request.country
6769
},
6870
useWithoutExtension: useWithoutExtension,
6971
insurance: {
@@ -146,6 +148,7 @@ export const BuyNewInsurance = () => {
146148
street,
147149
state,
148150
city,
151+
country,
149152
zipCode,
150153
detail1,
151154
detail2
@@ -172,6 +175,9 @@ export const BuyNewInsurance = () => {
172175
if (!zipCode) {
173176
errors.zipCode = t("Error.ZipCode");
174177
}
178+
if (!country) {
179+
errors.country = t("Error.Country");
180+
}
175181
if (!detail1 || !detail2) {
176182
errors.insuranceDetails = t("Error.insuranceDetails");
177183
}

client/src/pages/submitClaim/components/RequestForm.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const RequestForm = ({
176176
error={errors.city}
177177
/>
178178
<div className="row">
179-
<div className="col-md-6">
179+
<div>
180180
<InputSelect
181181
name="state"
182182
label={t("State")}
@@ -188,6 +188,13 @@ export const RequestForm = ({
188188
error={errors.state}
189189
/>
190190
</div>
191+
<InputText
192+
name="country"
193+
label={t("Country")}
194+
value={request.country}
195+
onChange={onChange}
196+
error={errors.country}
197+
/>
191198
<div className="col-md-6">
192199
<InputText
193200
name="zipCode"

client/src/pages/submitClaim/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const initialState = {
2121
zipCode: "",
2222
email: "",
2323
type: "",
24-
description: ""
24+
description: "",
25+
country: ""
2526
}
2627
};
2728

@@ -62,6 +63,7 @@ export const SubmitClaim = () => {
6263
street: request.street,
6364
city: request.city,
6465
state: request.state,
66+
country: request.country,
6567
zip_code: request.zipCode,
6668
type: option.name,
6769
timestamp: date.toGMTString(),
@@ -145,6 +147,9 @@ export const SubmitClaim = () => {
145147
if (!state) {
146148
errors.state = t("Error.State");
147149
}
150+
if (!state) {
151+
errors.country = t("Error.Country");
152+
}
148153
if (!city) {
149154
errors.city = t("Error.City");
150155
}

server/app/document.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _render_claim_template(cls, tpl, claim, remove_white_styles=False):
4141

4242
if remove_white_styles:
4343
# Fields that should be replaced
44-
fields_to_replace = ['zip_code', 'street', 'city', 'state']
44+
fields_to_replace = ['zip_code', 'street', 'city', 'state', 'country']
4545
for field in fields_to_replace:
4646
pattern = rf'<span[^>]*style="color:\s*white"[^>]*>\s*/{field}/\s*</span>'
4747
replacement = f'<span class="user-info">{{{{ {field} }}}}</span>'
@@ -55,6 +55,7 @@ def _render_claim_template(cls, tpl, claim, remove_white_styles=False):
5555
street=claim['street'],
5656
city=claim['city'],
5757
state=claim['state'],
58+
country=claim['country'],
5859
zip_code=claim['zip_code'],
5960
type=claim['type'],
6061
timestamp=claim['timestamp'],
@@ -154,8 +155,9 @@ def create_claim(cls, tpl, claim, envelope_args, extensions):
154155
# Address fields mapping
155156
address_fields = {
156157
"street": "VerifyPostalAddressInput[0].street1",
157-
"city": "VerifyPostalAddressInput[0].subdivision",
158-
"state": "VerifyPostalAddressInput[0].countryOrRegion",
158+
"city": "VerifyPostalAddressInput[0].locality",
159+
"state": "VerifyPostalAddressInput[0].subdivision",
160+
"country": "VerifyPostalAddressInput[0].countryOrRegion",
159161
"zip_code": "VerifyPostalAddressInput[0].postalCode",
160162
}
161163

@@ -407,14 +409,16 @@ def create_with_payment(cls, tpl, user, insurance_info, envelope_args, extension
407409
render_context = dict(
408410
user_name=f"{user['first_name']} {user['last_name']}",
409411
user_email=user['email'],
410-
address=f"{user['street']}, {user['city']}, {user['state']}",
412+
street=user['street'],
413+
city=user['city'],
414+
state=user['state'],
415+
country=user['country'],
411416
zip_code=user['zip_code'],
412417
detail_1=insurance_info['detail1']['name'],
413418
detail_2=insurance_info['detail2']['name'],
414419
value_detail_1=insurance_info['detail1']['value'],
415420
value_detail_2=insurance_info['detail2']['value']
416421
)
417-
user['address'] = f"{user['street']}, {user['city']}, {user['state']}"
418422

419423
content_bytes = cls._read_and_render_template(tpl, render_context)
420424
base64_file_content = base64.b64encode(content_bytes.encode('utf-8')).decode('ascii')
@@ -449,7 +453,10 @@ def create_with_payment(cls, tpl, user, insurance_info, envelope_args, extension
449453

450454
# Address text tabs
451455
address_fields = {
452-
"address": "VerifyPostalAddressInput[0].street1",
456+
"street": "VerifyPostalAddressInput[0].street1",
457+
"city": "VerifyPostalAddressInput[0].locality",
458+
"state": "VerifyPostalAddressInput[0].subdivision",
459+
"country": "VerifyPostalAddressInput[0].countryOrRegion",
453460
"zip_code": "VerifyPostalAddressInput[0].postalCode",
454461
}
455462
text_tabs = []
@@ -495,15 +502,18 @@ def create_with_payment_without_extension(cls, tpl, user, insurance_info, envelo
495502
render_context = dict(
496503
user_name=f"{user['first_name']} {user['last_name']}",
497504
user_email=user['email'],
498-
address=f"{user['street']}, {user['city']}, {user['state']}",
505+
street=user['street'],
506+
city=user['city'],
507+
state=user['state'],
508+
country=user['country'],
499509
zip_code=user['zip_code'],
500510
detail_1=insurance_info['detail1']['name'],
501511
detail_2=insurance_info['detail2']['name'],
502512
value_detail_1=insurance_info['detail1']['value'],
503513
value_detail_2=insurance_info['detail2']['value']
504514
)
505515

506-
fields_to_replace = ['address', 'zip_code', 'user_email']
516+
fields_to_replace = ['street', 'city', 'country', 'state', 'zip_code', 'user_email']
507517
content_bytes = cls._read_and_render_template(tpl, render_context, fields_to_replace)
508518
base64_file_content = base64.b64encode(content_bytes.encode('utf-8')).decode('ascii')
509519

server/app/templates/new-insurance.html

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,29 @@ <h3 class="info-title">Ordered by</h3>
255255
<span class="label">Name:</span>
256256
<span class="user-info">{{ user_name }}</span>
257257
</div>
258-
<div class="line">
259-
<span class="label">Address:</span>
260-
<span style="color: white" class="user-info">/address/</span>
258+
<h3 class="info-title">Address details</h3>
259+
<div style="display: flex; justify-content: row;">
260+
<div style="display: flex; flex-direction: column; gap: 8px; width: 45%;">
261+
<div class="line">
262+
<span class="label">Street:</span>
263+
<span style="color: white" class="user-info">/street/</span>
264+
</div>
265+
<div class="line">
266+
<span class="label">City:</span>
267+
<span style="color: white" class="user-info">/city/</span>
268+
</div>
269+
</div>
270+
271+
<div style="display: flex; flex-direction: column; gap: 8px; width: 45%;">
272+
<div class="line">
273+
<span class="label">State:</span>
274+
<span style="color: white" class="user-info">/state/</span>
275+
</div>
276+
<div class="line">
277+
<span class="label">Country:</span>
278+
<span style="color: white" class="user-info">/country/</span>
279+
</div>
280+
</div>
261281
</div>
262282
<div class="line">
263283
<span class="label">Zip code:</span>
@@ -304,7 +324,7 @@ <h3 style="margin-top:3em;">Agreed: <span style="color:white;">/sn1/</span></h3>
304324
</section>
305325
</form>
306326
</main>
307-
<br /><br /><br />
327+
<br />
308328
<p>Use this credit card number for testing purposes - 4242-4242-4242-4242 (with any date and code).</p>
309329
</body>
310330

server/app/templates/submit-claim.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ <h3 class="info-title">Address details</h3>
292292
<span class="label">State:</span>
293293
<span style="color: white" class="user-info">/state/</span>
294294
</div>
295+
<div class="line">
296+
<span class="label">Country:</span>
297+
<span style="color: white" class="user-info">/country/</span>
298+
</div>
295299
<div class="line">
296300
<span class="label">Zip code:</span>
297301
<span style="color: white" class="user-info">/zip_code/</span>

0 commit comments

Comments
 (0)