Skip to navigation

SmartCircuit events

Events your web application listens for and sends

SmartCircuit talks to the Partner Web Application (PWA) through DOM custom events. Listening events come from SmartCircuit; sending events go from the PWA to SmartCircuit with the quote, purchase or note decline data.

EventNameType
Component readyazpComponentReadyListening
Quote requestazpQuoteRequestSending
Insurance selected / declinedazpInsuranceSelected, azpInsuranceDeclinedListening
Default offerazpLoadingDefaultOfferListening
Purchase requestazpPurchaseRequestSending
Purchase responseazpPurchaseResponseListening
Note decline requestazpNoteDeclineRequestSending
Note decline responseazpNoteDeclineResponseListening
ErrorazpFatalErrorListening

Listening events

azpComponentReady

The PWA must wait for this event before interacting with SmartCircuit.

azpInsuranceSelected and azpInsuranceDeclined

The PWA needs the customer’s choice to show the insurance price in the booking total and to decide whether to send a purchase request or a note decline request.

var insuranceSelected = false;
var insurancePrice = 0;
function insuranceSelectedFunc(event) {
insuranceSelected = true;
insurancePrice = event.detail.insurancePrice;
}
// Fires when the customer selects "Yes" in the offer.
window.document.addEventListener("azpInsuranceSelected", insuranceSelectedFunc);

azpLoadingDefaultOffer

If no optimized offer arrives in time after a quote request, SmartCircuit displays a single default offer. This is rare, and it keeps the offer on the page.

azpPurchaseResponse

Handling this event is optional but recommended to confirm the purchase succeeded. A failure message includes a unique partner booking ID that can be used to reprocess payment later.

azpNoteDeclineResponse

AzP responds with SUCCESS when it receives the note decline.

azpFatalError

Something went wrong, usually with the quote service, and no quote can be displayed. Hide any insurance-related elements when this event arrives.

Sending events

azpQuoteRequest

Send this once azpComponentReady has fired and the PWA has enough information to quote. The event detail is a quote request object.

var jsonQuoteRequest = { /* quote request */ };
var quoteRequest = new CustomEvent("azpQuoteRequest", { detail: jsonQuoteRequest });
document.dispatchEvent(quoteRequest);

azpPurchaseRequest

Send this when the customer completes the core booking with insurance selected. The event detail is a purchase request object.

var jsonPurchaseRequest = { /* purchase request */ };
var purchaseRequest = new CustomEvent("azpPurchaseRequest", { detail: jsonPurchaseRequest });
document.dispatchEvent(purchaseRequest);

azpNoteDeclineRequest

Send this each time a booking completes with insurance declined. AzP matches it to the original quote request to measure performance and drive optimization. It needs no data.

var noteDeclineEvent = new CustomEvent("azpNoteDeclineRequest");
document.dispatchEvent(noteDeclineEvent);

Code examples