> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://allianz.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://allianz.ferndocs.com/_mcp/server.

# Code examples

## SmartCircuit integration code example

The sandbox's event-ticket example listens for the customer's choice, sends a quote and sends the purchase.

#### SmartCircuit event example (JavaScript)

```javascript
//Insurance Selected function
function insuranceSelectedFunc(event) {
  insuranceSelected = true;
  insurancePrice = event.detail.insurancePrice;
  console.log(insurancePrice);
}
//Event Listener for when the insurance radio button for "yes" is selected. Calls function above.
window.document.addEventListener("azpInsuranceSelected", insuranceSelectedFunc);
//Quote function
function sendQuote() {
   var jsonQuoteRequest = 
      {
        "customers":[{
            "address": {
              "city": "Richmond",
              "country": "US",
              "postalCode": "23238",
              "region": "VA"
            },
            "age": 55,
            "birthDate": "1963-07-01",
            "customerId": "45348962",
            "customerType": "PRIMARY",
            "firstName": "Jane",
            "gender": "Female",
            "lastName": "Doe",
            "sequence": 1
          }, {
            "customerType": "OTHER",
            "sequence": 2
          }
        ],
        "events": [{
            "artistId": 10804,
            "artistName": "Eagles",
            "endDate": "2020-09-16T22:00:00",
            "eventName": "Hotel California 2020 Tour",
            "majorCategory": "MUSIC_EVENT",
            "sequence": 1,
            "startDate": "2020-09-16T20:00:00",
            "ticketType": "General Admission",
            "totalCost": 1250.0,
            "venue": {
              "city": "Denver",
              "country": "US",
              "region": "CO"
            },
            "venueCode": "Pep449",
            "venueName": "Pepsi Center",
            "venuePostalCode": "80204"
          }
        ],
        "gadget": {
          "browserType": "Safari",
          "browserVersion": "13.0.1",
          "deviceCategory": "Mobile",
          "deviceType": "iPhone",
          "ipAddress": "192.11.111.111",
          "operatingSystem": "iOS",
          "operatingSystemVersion": "13.1.3",
          "requestingPlatform": "Mobile App"
        },
        "requestDetail": {
          "businessUnit": "US",
          "currency": "USD",
          "itemDeliveryMethod": "email",
          "language": "en",
          "offerVersionId": 1,
          "requestCategories": ["Event"],
          "requestChannel": "Online",
          "requestedDate": "2020-05-01T14:57:02",
          "requestOrigin": "Standard",
          "sessionId": "1234567",
          "trafficSource": "Google",
          "transactionId": "643e6808-e547-49e1-938e-4d725017"
        }
      };
  var quoteRequestEvent = new CustomEvent('azpQuoteRequest', {
      detail: jsonQuoteRequest
    });
  document.dispatchEvent(quoteRequestEvent);
  console.log("insurancePrice " + insurancePrice);
  }
//Purchase Function
function sendPurchase(isInsuranceSelected) {
  console.log("sendPurchase " + isInsuranceSelected);
  if (isInsuranceSelected == true) {
     var jsonPurchaseRequest = {
       "BusinessUnit": "US",
       "TransactionID": "643e6808-e547-49e1-938e-4d725017",
       "Purchases": {
         "Purchase": [{
             "PartnerBookingID": "12455678",
             "InsuranceBookingDetails": {
               "PurchaseDateTime": "2020-05-01T11:26:35",
               "Method": "Online",
               "Status": "NEW",
               "Type": "ADD",
               "Currency": "USD",
               "TotalCoverageAmount": numberCost,
               "TotalPrice": insurancePrice,
               "TotalPremiumPrice": insurancePrice,
               "Purchaser":{
                 "FirstName": document.getElementById('firstname').value,
                 "LastName": document.getElementById('lastname').value,
                 "BillingAddress": {
                   "Street": document.getElementById('address1').value,
                   "City": document.getElementById('city').value,
                   "Region": document.getElementById('state').value,
                   "Country": document.getElementById('country').value
                 },
                 "EmailAddress": document.getElementById('email').value,
                 "PhoneNumber": document.getElementById('phone').value
               },
               "FulfillmentMethod": "EMAIL",
               "PaymentMethod": "CC",
               "CreditCard":{
                 "CardholderName": "Jane Doe",
                 "ExpireMonth": "5",
                 "ExpireYear": "2021",
                 "Number": "4012xxxxxxxx0026",
                 "Type": "VI",
                 "SecurityCode": "123"
               }
             },
             "EventTicketBookingDetails":{
               "Currency": "USD",
               "TotalTicketCost": numberCost,
               "Method": "Online",
               "Path": "Music",
               "DepositDate": "2020-05-01T11:26:35",
               "Language": "en"
             },
             "EventTicketDetails": {
               "EventDate": "2020-09-16",
               "Location": {
                 "City": "Denver",
                 "Region": "CO",
                 "Name": "Pepsi Center",
                 "Country": "USA"
               }
             },
             "ProductDetails": {
               "Product": [{
                   "Sequence": "0",
                   "ProductID": "001004663",
                   "QuoteID": "2677731051208440470",
                   "InsuredDetails": {
                     "Insured": [{
                         "Sequence": "0",
                         "Type": "PRIMARY",
                         "FirstName": document.getElementById('firstname').value,
                         "LastName": document.getElementById('lastname').value,
                         "Birthdate": "1963-07-01",
                         "PhoneNumber": document.getElementById('phone').value,
                         "EventTicketCost": numberCost,
                         "NumberOfTickets": "2"
                       }
                     ]
                   },
                   "CoverageAmount": numberCost,
                   "Price": insurancePrice,
                   "PremiumPrice": insurancePrice
                 }
               ]
             }
           }
         ]
       }
     }
   };
    var purchaseRequestEvent = new CustomEvent('azpPurchaseRequest', {
        detail: jsonPurchaseRequest
    });
    document.dispatchEvent(purchaseRequestEvent);
    console.log("Purchase Complete");
  }
}
```

## Try SmartCircuit

#### [Try SmartCircuit](https://sandbox.allianzpartnerservices.com/code-resources/smartcircuit-integrated-example)

Quote and buy through SmartCircuit in the sandbox (partner login required).

#### [Example source](https://sandbox.allianzpartnerservices.com/wp-content/plugins/azp-sandbox/js/sc_example.js)

The JavaScript behind the sandbox example.