Skip to navigation

Integrate SmartCircuit

Reference the bundle, place the element and authenticate

A SmartCircuit integration has three parts: a reference to the hosted SmartCircuit JavaScript bundle, an HTML element where the offer is displayed, and partner scripting that exchanges events with the component.

1

Reference the SmartCircuit bundle

AzP hosts the bundle on the AWS CDN. A static inclusion is usually enough because the bundle is small; use a dynamic inclusion to load it only when the page flow needs it.

Reference the bundle in the head of each page where a quote or purchase happens.

index.html
<html>
<head>
<script src="https://sc-uat.allianzpartnergateway.com/wci/bundles/default/allianzinsurance-uat-default.js"></script>
</head>
<body>
<allianz-insurance accam="code" allow-price-validation="false" access-token="accessToken" type="TRAVEL" log-level="debug"></allianz-insurance>
</body>
</html>

On a single-page application, moving between pages that each initialize SmartCircuit leaves two listeners for the same event, and the customer can receive a different quote for their search criteria.

2

Get an access token

Your server calls the SmartCircuit authorize endpoint. The access token is valid for 1 hour, and the refresh token renews it for 24 hours. Once the access token expires, call the authorize endpoint again with the refresh token.

{
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD"
}
// Required variables to get the token
$scAuthEndpoint = "https://pg-uat-api-partnermgmt.allianzpartnergateway.com/authorize";
$scUsername = "PartnerUsername";
$scPassword = "PartnerPassword";
$scAccam = "F000000";
// Get an authorization token using scGetToken below.
$scToken = scGetToken($scUsername, $scPassword, $scAuthEndpoint);
// Create the allianz-insurance element with the token.
$html = '<allianz-insurance id="trip-protection" allow-price-validation="false" log-level="1" access-token="' . $scToken . '" type="TRAVEL" accam="' . $scAccam . '"></allianz-insurance>';
function scGetToken($scUsername, $scPassword, $authEndpoint) {
$data = array(
'username' => $scUsername,
'password' => $scPassword
);
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode($data),
'header' => "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
)
);
$context = stream_context_create($options);
$result = file_get_contents($authEndpoint, false, $context);
$response = json_decode($result);
return $response->accessToken;
}
3

Place the allianz-insurance element

Put the element where the offer should appear. SmartCircuit injects the offer into it.

<allianz-insurance id="trip-protection" accam="F000000" allow-price-validation="false" access-token="eyJraWQiOiJGcFh2TFU4cXhr...VLvWaZ0kgNlTEWPidiAxKQAlRTkNc5Fg" type="TRAVEL" log-level="warn"></allianz-insurance>
access-token
stringRequired

Access token from the server-side authentication call. SmartCircuit uses it to authenticate the page.

accam
stringRequired

Which of the partner’s ACCAMs to use when the partner has more than one.

type
"TRAVEL" | "EVENT"Required

Whether the quote is for travel or an event.

allow-price-validation
booleanDefaults to false

Verify the quoted price before a purchase. On a mismatch, SmartCircuit returns Price in Purchase Request does not match price was returned in quote request. TotalPrice should be XXX passed as YYY.

log-level
"debug" | "info" | "warn" | "error"

How much SmartCircuit logs to the console, from debug (most) to error (errors only). Use debug during development and warn or error in production.

4

Listen for and send events

Wire your checkout to the SmartCircuit events: wait for azpComponentReady, send azpQuoteRequest, track the customer’s choice, then send a purchase or note decline.

Residency of the insured

US travel insurance is regulated by each state, so benefits, limits and pricing depend on the insured’s state of residence. Every quote request must include:

AttributeObjectTypeNotesExample
regioncustomerAddressString2-letter billing state code of the insuredVA
postalCodecustomerAddressStringBilling ZIP code of the insured23111
businessUnitrequestDetailString2-letter country codeUS