Embedded Widget
Enable customers to complete the TaxWisp tax exemption form directly inside your ecommerce application using the TaxWisp Embedded Widget.
Overview
The TaxWisp Embedded Widget opens a modal inside your storefront or customer account page, allowing customers to submit their tax exemption request without leaving your application.
Integration Flow
- Customer clicks Request Tax Exemption.
- Your backend creates a TaxWisp customer session.
- TaxWisp returns both a token and redirectUrl.
- Your frontend calls
window.showTaxExemptionForm(). - The TaxWisp modal opens inside your application.
- Customer completes and submits the tax exemption request.
Important: The Customer Session API must be called from your backend because it requires your TaxWisp API key (
X-TaxWisp-Api-Key). Never expose your client secret in frontend code.
Step 1: Add the TaxWisp CDN Assets
Include the TaxWisp stylesheet and JavaScript bundle in your application.
Stylesheet
Add the stylesheet inside the <head> section of your application.
<link
rel="stylesheet"
href="https://cdn.taxwisp.ai/content/widget/prod/tax-exemption-manual-form.min.css"
/>
JavaScript
Load the widget JavaScript before the closing </body> tag or after your application finishes loading.
<script src="https://cdn.taxwisp.ai/content/widget/prod/tax-exemption-manual-form.min.js"></script>
Once loaded, the CDN exposes the following global function:
window.showTaxExemptionForm(...);
Step 2: Create a Customer Session
Your backend creates a TaxWisp customer session.
Endpoint
POST https://taxwisp.ai/api/v1/external/customer-sessions
Authentication
Pass your TaxWisp Client Secret in the request header.
| Header | Value |
|---|---|
Content-Type | application/json |
X-TaxWisp-Api-Key | YOUR_CLIENT_SECRET |
Request Body
{
"customerId": "customer-12345",
"customerEmail": "customer@example.com"
}
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
customerId | String | Yes | Your unique customer identifier. |
customerEmail | String | Yes | Customer's email address. |
Step 3: Handle the API Response
Your backend receives the customer session details from TaxWisp.
Success Response
{
"redirectUrl": "https://customer.taxwisp.ai/session/abc123...",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Response Fields
| Field | Description |
|---|---|
redirectUrl | URL that opens the TaxWisp Customer Portal if needed. |
token | Authentication token required to open the embedded widget. |
Important: Unlike the Customer Portal integration, both
tokenandredirectUrlare required for the Embedded Widget integration.
Step 4: Open the Embedded Widget
After your backend returns the response, call the TaxWisp widget.
Frontend Example
window.showTaxExemptionForm({
authToken: token,
redirectUrl: redirectUrl
});
Widget Configuration
| Property | Required | Description |
|---|---|---|
authToken | Yes | Token returned by the Customer Session API. |
redirectUrl | Yes | Portal URL used if the customer chooses to continue in the TaxWisp Customer Portal. |
The widget opens as an embedded modal inside your application.
Complete Frontend Example
async function requestTaxExemption(customerId, customerEmail) {
const response = await fetch("/api/request-tax-exemption", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
customerId,
customerEmail
})
});
const { token, redirectUrl } = await response.json();
window.showTaxExemptionForm({
authToken: token,
redirectUrl: redirectUrl
});
}
Complete Backend Example (Node.js / Express)
app.post("/api/request-tax-exemption", async (req, res) => {
const response = await fetch(
"https://taxwisp.ai/api/v1/external/customer-sessions",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-TaxWisp-Api-Key": process.env.TAXWISP_CLIENT_SECRET
},
body: JSON.stringify({
customerId: req.body.customerId,
customerEmail: req.body.customerEmail
})
}
);
const data = await response.json();
res.json({
token: data.token,
redirectUrl: data.redirectUrl
});
});
Customer Experience
The customer completes the tax exemption request without leaving your application.
| Step | Customer Action |
|---|---|
| 1 | Clicks Request Tax Exemption. |
| 2 | Your backend securely requests a customer session from TaxWisp. |
| 3 | Your frontend calls window.showTaxExemptionForm(). |
| 4 | The TaxWisp modal opens inside your application. |
| 5 | Customer selects the exemption jurisdiction. |
| 6 | Customer uploads exemption certificates and supporting documents. |
| 7 | Customer reviews and submits the exemption request from the modal. |
Continue in TaxWisp Customer Portal
The embedded widget includes a Continue in TaxWisp Portal option.
If the customer chooses this option:
- The widget automatically uses the provided
redirectUrl. - The customer is redirected to the TaxWisp Customer Portal.
- The customer can continue the exemption process outside your storefront without restarting the session.
No additional integration work is required for this fallback experience.
Security Best Practices
- Always call the Customer Session API from your backend.
- Never expose your
X-TaxWisp-Api-Keyor client secret in frontend or client-side JavaScript. - Pass only the returned
tokenandredirectUrlfrom your backend to the frontend widget. - Use HTTPS for all communication between your application and TaxWisp.
API Summary
| Method | Endpoint | Purpose |
|---|---|---|
POST | /api/v1/external/customer-sessions | Create a customer session and receive the token and redirectUrl required for the embedded widget. |
CDN Assets Summary
| Asset | URL |
|---|---|
| Stylesheet | https://cdn.taxwisp.ai/content/widget/prod/tax-exemption-manual-form.min.css |
| JavaScript | https://cdn.taxwisp.ai/content/widget/prod/tax-exemption-manual-form.min.js |