Skip to main content

Capabilities

The payment card SDK uses secure iframes to display the following information on a merchant page:
  • Primary account number (PAN)
  • Expiration date (EXP)
  • CVV
  • Card information copy buttons
Plaintext card data never enters the merchant page’s DOM or JavaScript. The merchant page only provides a one-time Client Access Token, configures display styles, and receives loading and copy callbacks. Demo URL: https://paysdk.keysecure.io/Sbox/demo.sandbox.html

SDK URLs

Select the SDK URL that matches your environment.
Use the sandbox SDK during development and integration testing. Replace it with the production SDK before going live.

Get the integrity Hash

Retrieve the sandbox SDK integrity hash from the following URL: https://paysdk.keysecure.io/Sbox/0.0.1/integrity.json Retrieve the production SDK integrity hash from the following URL: https://paysdk.keysecure.io/SDK/prod/0.0.1/integrity.json Example response:
Copy the complete value of files["index.min.js"] into the integrity attribute of the <script> tag.
The integrity hash changes whenever the SDK file is updated. Retrieve integrity.json again before every SDK update or application release. Do not rely on the fixed hash shown in this example; always use the latest value returned by the URL above.

Load the SDK

Add the following <script> tag to your HTML page to load the sandbox SDK:

Prerequisites

Register Page Origins

Register the origin of every page that embeds the SDK in the merchant portal, for example:
  • HTTPS is required.
  • Register the exact origin. Wildcards such as *.merchant.com are not supported.
  • Contact KeySecure technical support if the origin registration option is not available in the merchant portal.
  • Content Security Policy (CSP) may block the SDK on unregistered pages.

Obtain a Client Access Token on the Backend

The Client Access Token must be obtained by the merchant backend. Never expose Api-Key, Access-Token, or other server-side credentials in the browser.
Example response:
The backend only needs to pass data.client_access_token to the frontend. See Issue PCI Client Access Token for complete parameter details.
A Client Access Token is a short-lived, one-time credential. Use it before it expires, and never store it in a database or cookie or write it to logs. Request a new token after a page refresh or before reinitializing the SDK.

Frontend Integration

Prepare the Containers

Initialize the SDK

Destroy and Resize

When bootstrap is called repeatedly with the same token, the SDK destroys the associated components before rebuilding them. Because the token is a one-time credential, the application should still avoid duplicate initialization and request a new token before reloading the components.

API Configuration Reference

Error Handling

Initialization Errors

Read error.code in callbackEvents.onFailure(error):

Copy Errors

Read error.code in onCopyFailure(error):

Style Customization

For security, styles only supports the following CSS properties. Unsupported properties are ignored:

Integration Checklist

  • The page origin is registered and exactly matches the actual HTTPS page.
  • The SDK URL matches the current environment.
  • integrity contains the latest SRI hash for the selected SDK file.
  • The backend obtains the Client Access Token, and the frontend never receives server credentials.
  • The token is not logged, persisted, or reused.
  • Copy button containers have position: relative and explicit dimensions.
  • Sensitive page responses include Cache-Control: no-store, no-cache.
  • widget.destroy() is called when leaving or unmounting a sensitive view.
  • Initialization and copy failure callbacks are handled.

Security Requirements

  1. Do not attempt to extract plaintext card data from the DOM, network requests, or internal SDK messages.
  2. Do not write the Client Access Token to databases, cookies, logs, or analytics events.
  3. Avoid placing the card information page inside nested iframes, which may break parent origin validation.
  4. Do not run screen recording, session replay, or unnecessary third-party analytics scripts on sensitive pages.
  5. Do not listen to, construct, or reuse internal SDK communication channels.

Browser Compatibility

Troubleshooting

The page reports a frame-ancestors CSP violation Confirm that the current page origin is registered. Request a new Client Access Token after registration, then initialize the SDK again. The SDK repeatedly returns TOKEN_INVALID The token is a one-time credential. Check whether React Strict Mode, SPA route transitions, or repeated rendering triggers initialization twice, and call widget.destroy() when unmounting the component. Nothing happens when a copy button is clicked Confirm that the copy container uses position: relative and has non-zero dimensions. The Clipboard API requires a user gesture; do not simulate the click with a timer. The iframe is blank Inspect the browser Network and Console panels. Confirm that requests do not return 403, the container is visible, and CSP or Permissions Policy is not blocking the iframe. If the issue persists, provide the browser, SDK URL, error code, and reproduction steps to KeySecure technical support. Never include a Client Access Token, full card number, or CVV in a support ticket or chat.