0.8.5 • Published 12 months ago

@mycoverai/mca-javascript-sdk v0.8.5

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

MyCover.ai Javascript SDK

Official MyCover.ai SDK. Supercharge your product with MyCover AI Insurance offerings. Create embedded insurance offerings or full white label insurance applications that excite your customers.

Installation

With NPM

npm install @mycoverai/mca-javascript-sdk@latest

From CDN

<script src="https://unpkg.com/@mycoverai/mca-javascript-sdk/dist/index.js"></script>

Usage

With NPM

//import package
import mycoverai from "@mycoverai/mca-javascript-sdk"

//setup your business configuration by supplying your public key. If productId is not provided or is an empty array, the SDK will display a list of insurance products for the customer to choose from. You can supply an array of strings, where each string represents an insurance product id, for the user to select from.
const config = {
  productId: ['a72c4e3c-e868-4782-bb35-df6e3344ae6c'], //optional
  publicKey: 'MCAPUBK_TEST|d24a7f02-99c8-497f-b1cc-d6d14d7963d5',
  form: {}, /*** Provide form data that your user has already given to ease form filling. The form object and all it's properties are optional, you only need to provide this when they are available. However, the property names must match the following format
   form: {
   "state": "Nasarawa",
   "first_name": "Lucian",
   "last_name": "Bryant",
   "bvn": "22226850607",
   "address": "Rem quae molestias h",
   "email": "dyzivoga@mailinator.com",
   "date_of_birth": "2015-05-19",
   "phone_number": "+2348011111111",
  }
   Where the property names do not match the ones we have provided above, such fields will be discarded and ignored.
 ***/
  paymentOption: 'wallet', //set to 'wallet' or 'gateway' to define default payment option
  willInspect: true, // ignore or set to false if you do not need inspection enabled. Set to true to enable inspection
  callback: Function, //A function you want us to call after the user has completed 
  onClose: Function, //A function you want us to call after the user closes without completing a purchase, activation or inspection
  reference: '',//optional. supply reference when you want the user to continue to the insurance activation step. This only applies to users who have previously bought insurance using this SDK,
  action: 'claim',  //optional, supply this field when your customer requires inspection to make a claim
}


//create a function that starts up the SDK
function buyInsurance() {
  mycoverai(config)
}

With CDN

<button onclick="buyInsurance">Buy Insurance</button>

<script src="https://unpkg.com/@mycoverai/mca-javascript-sdk/dist/index.js"></script>
<script>
  const config = {
    productId: ['a72c4e3c-e868-4782-bb35-df6e3344ae6c'], //optional
    publicKey: 'MCAPUBK_TEST|d24a7f02-99c8-497f-b1cc-d6d14d7963d5',
    form: {}, /*** Provide form date that your user has already given to ease form filling. The form object and all it's properties are optional, you only need to provide this when they are available. However, the property names must match the following format
     form: {
   "state": "Nasarawa",
   "first_name": "Lucian",
   "last_name": "Bryant",
   "bvn": "22226850607",
   "address": "Rem quae molestias h",
   "email": "dyzivoga@mailinator.com",
   "date_of_birth": "2015-05-19",
   "phone_number": "+2348011111111",
  }
     Where the property names do not match the ones we have provided above, such fields will be discarded and ignored.
     ***/
    paymentOption: 'wallet', //set to 'wallet' or 'gateway' to define default payment option
    willInspect: true, // ignore or set to false if you do not need inspection enabled. Set to true to enable inspection
    callback: Function, //A function you want us to call after the user has completed 
    onClose: Function, //A function you want us to call after the user closes without completing a purchase, activation or inspection
    reference: '',//optional. supply reference when you want the user to continue to the insurance activation step. This only applies to users who have previously bought insurance using this SDK,
    action: 'claim',  //optional, supply this field when your customer requires inspection to make a claim
  }

  function buyInsurance() {
    mycoverai(config)
  }
</script>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

0.8.5

12 months ago

0.8.0

12 months ago

0.7.0

12 months ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.4

1 year ago

0.5.5

1 year ago

0.5.3

1 year ago

0.5.2

1 year ago

0.5.1

2 years ago

0.5.0

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago