Developer Docs
Search…
⌃K

JavaScript SDK

Seel JavaScript SDK provides a way to integrate Seel Return Assurance(RA) into your web app.

Overview

Integrating RA into a web client includes adding the RA widget to the checkout page, setting up RA event listeners, and creating a policy after shopper has purchased the RA.

Set up Seel SDK

Installation

npm install seel-sdk --save

Importing

import SeelSDK from 'seel-sdk';
If you prefer to use seel-sdk globally via window.seelSDK, we provides single-file distribution as follows.
<!-- Seel SDK -->
<script src="https://cdn.seel.com/scripts/ra/marketplace-embedded.min.js"></script>
<!-- End Seel SDK –->

Add RA widget

Paste this code snippet to the checkout page
<!-- Seel RA widget -->
<div id="seel-ra-widget-root"></div>
<!-- End RA widget –->

Create quote

Seel SDK sends all items in the shopping cart to Seel backend to create a quote when shopper lands on the checkout page. There is no dev work needed in this step.

Set up RA event listeners

onRAChecked

Add a listener function to update the order total when shopper opts in RA.
import SeelSDK, { Events } from 'seel-sdk';
const checkedHandler = (raProductData) => {
// Implemenation required: update order info
const { price, quoteId, ...rest } = raProductData;
};
SeelPixel.setupListener(Events.checked, checkedHandler);

onRAUnchecked

Add a listener function to update the order total when shopper opts out RA
import SeelSDK, { Events } from 'seel-sdk';
const uncheckedHandler = (raProductData) => {
// Implemenation required: update order info
csont { price, quoteId, ...rest } = raProductData;
};
SeelPixel.setupListener(Events.unchecked, uncheckedHandler);

Create policy

createPolicy() is triggered when shopper successfully places an order with Return Assurance opted in, and is used to inform Seel of the policy creation.
import { createPolicy } from 'seel-pixel'
// construct polict data
policy_data = {
"quote_id": "quote_123", // from onRAChecked event
"order_id": "order_1234",
"customer_email": "[email protected]"
}
// call createPolicy()
createPolicy(policy_data)
Last modified 3mo ago