0.9.0 • Published 12 months ago

@mycoverai/mca-javascript-sdk v0.9.0

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 pid 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 = {
  pid: ["a72c4e3c-e868-4782-bb35-df6e3344ae6c"], //optional
  pk: "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": "lagos",
   "first_name": "micheal",
   "last_name": "okafor",
   "bvn": "22226850607",
   "address": "Plot 8, Providence Street, Lekki Phase 1, Lagos, Nigeria",
   "email": "mikeokafor@mailinator.com",
   "date_of_birth": "2015-05-19",
   "phone_number": "08011111111",
  }
   Where the property names do not match the ones we have provided above, such fields will be discarded and ignored.
 ***/,
  payment_option: "gateway", //set to 'wallet' or 'gateway' to define default payment option
  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: "purchase",
};

//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 = {
    pid: ["a72c4e3c-e868-4782-bb35-df6e3344ae6c"], //optional
    pk: "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.
     ***/,
    payment_option: "gateway", //set to 'wallet' or 'gateway' to define default payment option
    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: "purchase",
  };

  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.7

1 year ago

0.8.6

1 year ago

0.9.0

12 months ago

0.8.5

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.4

2 years ago

0.5.5

2 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago