Quickstart
Adding script to your site
Make sure that you added our script to your site. You can exclusively add to your checkout (or wherever you want to show the available insurances), but we highly recommend to add it to all your pages:
<script src="https://sdk.vernsurance.com/loader.js"></script>
<script>
var vern = Vern.configure('<replace with your public key>');
</script>
Add cart items
Once the cart on your website got updated make sure to update
vern.cart([{
id: '<event id>',
amount: '<price of this cart item as integer>',
currency: '<currency code>',
type: 'concert',
start: '<start date>',
end: '<end date>'
}]);
Where:
id: this should be a unique identifier of the event/product. Using this ID you can identify the given eventamount: price of the ticketstart: start date of the event as UTC ISO8601 string (eg:2019-04-11T13:03:54.002Z)end: end date of the event as UTC ISO8601 string (eg:2019-04-11T15:03:54.002Z)currency: currency code (eg: HUF, EUR, GBP, USD),type: type of the event, we currently support the following ones:concert.
Show available insurance
vern.on('insurance:available', function(insurance) {
});
Gets triggered when there's an available insurance for the current cart. In the callback you'll receive an object with the following structure:
{
"amount": 1340, // price of the insurance
"currency": "HUF" // currency of the insurance
}
Once you receive an available insurance you can either automatically choose it or let the user decide whether they want activate it.
vern.on('insurance:available', function(insurance) {
vern.open();
});
or
var checkbox = document.getElementById('insurance-checkbox');
vern.on('insurance:available', function(insurance) {
checkbox.style.display = 'block';
});
checkbox.addEventListener('click', function() {
vern.open();
}, false);
Store the quote
Once the user fills all the required fields for their chosen insurance you'll get notified.
vern.on('insurance:valid', function(quote) {
});
The quote is an identifier of a filled quote which you should store on your backend and let us know once the order on your side has been fulfilled.
Finalize the insurance once the order has been fulfilled
Once the order has been paid or fulfilled (it's up to your business process), you can activate the insurance by notifying us:
curl https://api.vern.com/v1/purchase \
-u <YOUR SECRET KEY>: \
-d quote=<QUOTE>
-d tickets=<ticketId1>,<ticketId2>
-d zip=<zip code>
-d city=<city>
-d address=<address line>
-d country=<country>
-d email=<email address>
-d firstName=<first name>
-d lastName=<last name>
-d vat=<vat id if any>
