New in Chargebee: Explore Reveal and understand your payment performance end-to-end.Try Now
Docschargebee docs
HomeBillingCPQPaymentsRevRecGrowthReveal
Support

Product Updates


  • Release Notes

Getting Started


  • Overview
  • Chargebee Billing Data Centers
  • Object Relationship Model
  • Understanding Sites
  • Chargebee Tech Glossary
  • Articles and FAQ

Implementing Chargebee


  • Implementation Guide
  • Go-live Checklist
  • Articles and FAQ

Agentic AI


  • Chargebee Copilot
  • Catalog Setup Assistant
  • MCP Servers

Developer Resources


  • Developer Resources Overview
  • API Explorer
  • Articles and FAQ

Chargebee Apps


  • Chargebee Apps CLI Developer Guide

Product Catalog


  • Product Catalog Overview
  • Coupons
  • Articles and FAQ

Subscriptions


  • Working with Subscriptions
  • Billing
  • Orders
  • Articles and FAQ

Customers


  • Managing Customers
  • Account Hierarchy
  • Email Notifications
  • Branding
  • Configure Multiple Languages
  • Articles and FAQ

Entitlements


  • Entitlements Overview
  • Features Overview
  • Feature Management
  • Managing Product Entitlements
  • Subscription Entitlements
  • Customer Entitlements
  • Grandfathering Entitlements
  • Articles and FAQ

Usage Based Billing


  • Understanding Usages
  • Setting up Usage Based Billing
  • Usage Alerts
  • Prepaid credits

Invoices and Credit Notes


  • Invoices
  • Credit Notes
  • Quotes [Legacy]
  • Transactions
  • Articles and FAQ

Taxes


  • Overview
  • Configuring Taxes
  • Country-specific Taxes
  • Articles and FAQ

Hosted Capabilities


  • Overview
  • Hosted Checkout
  • Hosted Self-Serve Portal
  • Hosted Pages Features
    • Custom Domain
    • Quantity Restrictions
    • Analytics
    • CSP Configuration
  • Additional Hosted Pages
  • Payment Components
  • Pricing Table
  • Mobile SDKs and Wrappers
  • Articles and FAQ

Site Configuration


  • Users & Roles
  • Custom Fields & Metadata
  • Approvals
  • Mandatory Fields
  • File Attachments & Comments
  • Advanced Filter Options
  • Multicurrency Pricing
  • Multi-decimal Support
  • Configuring Reason Codes
  • Events and Webhooks
  • API Keys
  • Time Zone
  • Time Machine
  • Transfer Configurations
  • Articles and FAQ

Multi Business Entity


  • Multi Business Entity Overview
  • Customer Transfer Overview
  • Articles and FAQ

Mobile Subscriptions


  • Overview
  • Omnichannel Subscriptions
  • Omnichannel Subscriptions (Legacy)

Reports and Analytics


  • RevenueStory
  • Home Dashboard
  • Frequently Asked Questions
  • FAQs for Classic Reports Sunset
  • Articles and FAQ

Integrations


  • Sales
  • Customer Support and Success
  • Finance
  • Tax
  • eInvoicing
  • Marketing
  • Stitch
  • Collaboration
  • Contract Management
  • Ecommerce Management
  • Articles and FAQ

Data Privacy & Security


  • Two Factor Authentication
  • SAML Single Sign-On
  • System for Cross-Domain Identity Management (SCIM)
  • EU-GDPR
  • Consent Management
  • Personal Data Management
  • Compliance Certificates
  • HIPAA Guidelines
  • PCI Recommendations and Integration Types
  • Articles and FAQ

Data Operations


  • Bulk Operations
  • Migration
  • Articles and FAQ
  1. Billing
  2. Hosted Capabilities
  3. Hosted Pages Features
  4. CSP Configuration
  1. Billing
  2. Hosted Capabilities
  3. Hosted Pages Features
  4. CSP Configuration

CSP configuration for hosted pages

Overview

To protect your customers and to comply with PCI DSS v4.0.1, Chargebee enforces a strict allowlist Content Security Policy (CSP) on Checkout, Portal, additional payment pages, and all components loaded by Chargebee.js, such as Payment Components and Card Components.

If you use the Google Tag Manager (GTM) integration to deploy scripts or other assets on these pages, you must explicitly allowlist them by uploading a JSON configuration in Chargebee Billing. Otherwise, the assets are blocked.

Configure CSP for hosted pages

Follow these steps to allowlist scripts and other assets on Chargebee hosted pages.

  1. Create a configuration JSON using the examples and JSON schema on this page.
  2. Upload the configuration JSON in Chargebee Billing.

Note

The CSP changes take effect immediately for Checkout, Portal, and other payment pages. However, it can take up to 7 days to apply to the other components loaded by Chargebee.js, such as Payment Components and Card Components.

Warning

The minified version of the configuration JSON must not exceed 5000 characters.

Examples of configuration JSON

Add analytics

CSP header
Content-Security-Policy:
    script-src 'self' https://stats.example.com;
    connect-src 'self' https://api.stats.example.com;
    img-src 'self' https://tracker.stats.example.com;
JSON configuration
{
  "policies": [
    {
      "name": "Basic Analytics",
      "type": "analytics",
      "script-src": {
        "hosts": [
          { "host": "https://stats.example.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      },
      "connect-src": {
        "hosts": [
          { "host": "https://api.stats.example.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      },
      "img-src": {
        "hosts": [
          { "host": "https://tracker.stats.example.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      }
    }
  ]
}

Add analytics and your own JavaScript with hashes

CSP header
Content-Security-Policy:
    script-src 'self' 
               'sha256-k9v+1rD48p+PyMPVGFijWfgSnkelbj/APH3uJacPuoB0=' 
               'sha256-0QF6XTN2zxURUBa+L8+AMfQzCALzVVwaW9xEOsMf/X0=' 
               https://analytics.example.com;
    connect-src 'self' https://api.example.com;
    img-src 'self' data: https://tracker.example.com;
JSON configuration
{
  "policies": [
    {
      "name": "Analytics + Trackers + JavaScript with Hash Validation",
      "type": "custom",
      "script-src": {
        "hosts": [
          { "host": "https://analytics.example.com" }
        ],
        "hashes": [
          "k9v+1rD48p+PyMPVGFijWfgSnkelbj/APH3uJacPuoB0=",
          "0QF6XTN2zxURUBa+L8+AMfQzCALzVVwaW9xEOsMf/X0="
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      },
      "connect-src": {
        "hosts": [
          { "host": "https://api.example.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      },
      "img-src": {
        "hosts": [
          { "host": "https://tracker.example.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" },
          { "type": "SCHEME", "value": "DATA" }
        ]
      }
    }
  ]
}

Use wildcards

CSP header
Content-Security-Policy:
    script-src 'self' https://*.tracking-example.com;
    img-src 'self' data: https://cdn.image-host.com;
    connect-src 'self' https://*.api-service.com;
JSON configuration
{
  "policies": [
    {
      "name": "Tracking and Services",
      "type": "tracking",
      "script-src": {
        "hosts": [
          { "scheme": "https", "host": "*.tracking-example.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      },
      "img-src": {
        "hosts": [
          { "host": "https://cdn.image-host.com" }
        ],
        "expressions": [
          { "type": "SCHEME", "value": "DATA" },
          { "type": "KEYWORD", "value": "SELF" }
        ]
      },
      "connect-src": {
        "hosts": [
          { "scheme": "https", "host": "*.api-service.com" }
        ],
        "expressions": [
          { "type": "KEYWORD", "value": "SELF" }
        ]
      }
    }
  ]
}

JSON schema for CSP configuration

JSON schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "CSP Configuration Schema for Chargebee Hosted Capabilities",
  "description": "This schema defines the structure of configuration files that let merchants add Content Security Policy (CSP) directives to Chargebee-hosted capabilities.",
  "type": "object",
  "properties": {
    "policies": {
      "type": "array",
      "description": "An array of CSP configurations. Each configuration specifies a set of CSP directives.",
      "minItems": 1,
      "items": { "$ref": "#/$defs/policy" }
    }
  },
  "required": ["policies"],
  "$defs": {
    "policy": {
      "type": "object",
      "description": "Specifies a set of CSP directives. Chargebee adds a single CSP header to hosted pages. If the same directive appears in multiple policies, Chargebee combines their values.",
      "properties": {
        "name": {
          "type": "string",
          "description": "A unique name of the policy. Use this field to describe the policy's purpose or related service."
        },
        "type": {
          "type": "string",
          "description": "The category of the policy. Use this field to group policies into categories."
        },
        "script-src": { "$ref": "#/$defs/directive" },
        "connect-src": { "$ref": "#/$defs/directive" },
        "frame-src": { "$ref": "#/$defs/directive" },
        "style-src": { "$ref": "#/$defs/directive" },
        "font-src": { "$ref": "#/$defs/directive" },
        "img-src": { "$ref": "#/$defs/directive" },
        "worker-src": { "$ref": "#/$defs/directive" },
        "child-src": { "$ref": "#/$defs/directive" },
        "script-src-elem": { "$ref": "#/$defs/directive" },
        "script-src-attr": { "$ref": "#/$defs/directive" },
        "style-src-elem": { "$ref": "#/$defs/directive" },
        "style-src-attr": { "$ref": "#/$defs/directive" },
        "media-src": { "$ref": "#/$defs/directive" }
      }
    },
    "directive": {
      "type": "object",
      "description": "The value of the CSP directive, specifying the allowed hosts, expressions, and hashes.",
      "properties": {
        "hosts": {
          "type": "array",
          "description": "A list of allowed host sources.",
          "items": { "$ref": "#/$defs/host" }
        },
        "expressions": {
          "type": "array",
          "description": "Additional source expressions that define directive behaviors.",
          "items": { "$ref": "#/$defs/expression" }
        },
        "hashes": {
          "type": "array",
          "description": "A list of Base64-encoded SHA-256 hashes used to allow specific scripts or assets. Chargebee automatically prefixes the hash with 'sha256-' when adding it to the directive.",
          "items": { "$ref": "#/$defs/hash" }
        }
      }
    },
    "host": {
      "type": "object",
      "description": "Defines a host source that the directive allows.",
      "properties": {
        "host": {
          "type": "string",
          "description": "A valid host source for the directive."
        },
        "scheme": {
          "type": "string",
          "description": "The protocol scheme for the 'host' (e.g., 'https', 'http', 'wss')."
        }
      },
      "required": ["host"]
    },
    "expression": {
      "type": "object",
      "description": "Defines a source expression for the directive.",
      "properties": {
        "type": {
          "type": "string",
          "enum": ["SCHEME", "KEYWORD"],
          "description": "The type of source expression.\n- Use 'SCHEME' to indicate a scheme source.\n- Use 'KEYWORD' to indicate forms of source expressions that are not schemes or host sources."
        },
        "value": {
          "type": "string",
          "description": "The value of the source expression. Allowed values depend on the 'type':\n- If 'type' is 'SCHEME', valid values: 'HTTP', 'HTTPS', 'WS', 'WSS', 'DATA', 'BLOB'.\n- If 'type' is 'KEYWORD', valid values: 'SELF', 'UNSAFE_INLINE', 'UNSAFE_EVAL', 'STRICT_DYNAMIC'."
        }
      },
      "required": ["type", "value"]
    },
    "hash": {
      "type": "string",
      "description": "A Base64-encoded SHA-256 hash for an allowed script or other asset. Chargebee automatically prefixes the hash with 'sha256-' when adding it to the directive."
    }
  }
}

Schema description

This section describes each property in the JSON schema.

Root level

NameTypeDescription
policiesArray of objects, requiredAn array of CSP configurations. Each configuration specifies a set of supported CSP fetch directives.

$defs/policy

Type: Object

Specifies a set of supported CSP fetch directives. Chargebee adds a single CSP header to hosted pages. If the same directive appears in multiple policies, Chargebee combines their values.

Properties
NameTypeDescription
nameStringA unique name of the policy. Use this field to describe the policy's purpose or related service.
typeStringThe category of the policy. Use this field to group policies into categories.
connect-srcObjectThe value of the connect-src CSP directive.
script-srcObjectThe value of the script-src CSP directive.
script-src-elemObjectThe value of the script-src-elem CSP directive.
script-src-attrObjectThe value of the script-src-attr CSP directive.
child-srcObjectThe value of the child-src CSP directive.
frame-srcObjectThe value of the frame-src CSP directive.
style-srcObjectThe value of the style-src CSP directive.
style-src-elemObjectThe value of the style-src-elem CSP directive.
style-src-attrObjectThe value of the style-src-attr CSP directive.
font-srcObjectThe value of the font-src CSP directive.
img-srcObjectThe value of the img-src CSP directive.
worker-srcObjectThe value of the worker-src CSP directive.
media-srcObjectThe value of the media-src CSP directive.

$defs/directive

Type: Object

The value of the CSP directive, specifying the allowed hosts, expressions, and hashes.

NameTypeDescription
hostsArray of objectsA list of allowed host sources.
expressionsArray of objectsAdditional source expressions that define directive behaviors.
hashesArray of stringsA list of Base64-encoded SHA-256 hashes used to allow specific scripts or assets. Chargebee automatically prefixes the hash with sha256- when adding it to the directive.

$defs/host

Type: Object

Defines a host source that the directive allows.

NameTypeDescription
hostString, requiredA valid host source for the directive.
schemeStringThe protocol scheme for the host, for example https, http, or wss.

$defs/expression

Type: Object

Defines a source expression for the directive.

NameTypeDescription
typeString, requiredThe type of source expression. Use SCHEME to indicate a scheme source. Use KEYWORD to indicate forms of source expressions that are not scheme sources or host sources.
valueString, requiredThe value of the source expression. When type is SCHEME, the valid values are HTTP, HTTPS, WS, WSS, DATA, and BLOB. When type is KEYWORD, the valid values are SELF, UNSAFE_INLINE, UNSAFE_EVAL, and STRICT_DYNAMIC.

$defs/hash

Type: String

A Base64-encoded SHA-256 hash for an allowed script or other asset. Chargebee automatically prefixes the hash with sha256- when adding it to the directive.

See also

Configure full-page checkout and portal

Google Tag Manager for full-page checkout

Articles & FAQs

Content Security Policy for loading the Checkout page
Content security policy for the Checkout page

Was this article helpful?