Payment Handler API will require CSP `connect-src`

Payment Handler API will require CSP `connect-src`

The Payment Handler API allows payment providers to make their custom payment experience available for merchants, along with the Payment Request API.

The information on this page only applies to websites that use both CSP (Content-Security-Policy) and the Payment Request API. If you use neither or only one of the two, then you can skip these instructions.

To check if your payment provider is using the Payment Handler API, contact them and follow their instructions.

If you are using the Payment Handler API and CSP (Content-Security-Policy) for better protection, you need to make sure the domains of HTTP requests sent from the browser are added to the connect-src directive of the CSP header.

For example, if your JavaScript code invokes new PaymentRequest(, details), then your CSP connect-src must include or

Content-Security-Policy: connect-src  

If is a cross-origin redirect, then the destination origin should be included in the CSP too. For example, if redirects to, then both origins must be included in the CSP:

Content-Security-Policy: connect-src

A URL payment method identifier is allowed up to 3 same-site redirects. If any redirects occur, then all of the URLs must be in the CSP.

Try it out locally

To enable the feature locally before it is shipped:

  1. Go to chrome://flags/#web-payment-api-cspon Chrome.
  2. Change “CSP policy for Web Payment API” from “Default” to “Enabled”.
  3. Restart Chrome.

Check the request URLs

To check the URLs of the requests sent from the Payment Handler API:

  1. Enable chrome://flags/#web-payment-api-csp.
  2. Go to your checkout page and open Chrome’s Developer Tools.
  3. Look for error messages like the following:
    RangeError: Failed to construct 'PaymentRequest': payment method identifier violates Content Security Policy.
  4. Add the specified method identifier to your CSP.

Photo by Eduardo Soares on Unsplash

This post is also available in: English