When developers integrate a payment gateway for the first time, one of the earliest and most consequential decisions they face is how card data gets from the customer's browser to the payment processor. The wrong answer to that question puts raw card numbers through your server, expands your PCI compliance scope to its most demanding level, and creates liability exposure that's disproportionate to any technical benefit.

Collect.js is CyoGate's hosted tokenization library. It handles that card data collection decision correctly by design: card numbers, expiry dates, and CVV codes are captured directly in iFrames hosted on CyoGate's PCI-compliant infrastructure, and your server receives a one-time token in place of the actual card data. Your server never sees, transmits, or stores a raw PAN. This post explains how Collect.js works, why that architecture matters for PCI compliance, and how it fits alongside the other components of a complete CyoGate integration.

The Problem Collect.js Solves

The naive approach to payment form integration looks straightforward: create an HTML form with fields for card number, expiry, and CVV, submit it to your server, and then your server calls the payment gateway API with those values. It works technically. The problem is what it does to your PCI compliance posture.

Any server that receives, processes, or transmits cardholder data is in scope for PCI DSS compliance at the SAQ D level — the most demanding self-assessment questionnaire, covering your entire server environment including network segmentation, access controls, logging, vulnerability management, and penetration testing. For most developers and merchants, maintaining SAQ D compliance is a significant ongoing cost that is completely unnecessary if card data never touches your server in the first place.

Hosted tokenization libraries like Collect.js exist specifically to keep raw card data out of your environment. The card number the customer types never reaches your application server. It goes directly from the customer's browser to CyoGate's infrastructure, which returns a token. Your server handles the token, not the card data. Your PCI scope drops to SAQ A, with the PCI DSS 4.0 script management requirements that now apply to any checkout page hosting payment fields being the primary compliance consideration.

How Collect.js Works: The Technical Flow

The Collect.js integration flow works as follows:

Your checkout page loads Collect.js from CyoGate's CDN. The library renders iFrame elements for the card number, expiry, and CVV fields within your checkout form. The customer sees fields that appear to be part of your page, but those fields are actually rendered inside CyoGate-hosted iFrames. The card data the customer types goes into those iFrames and is processed by CyoGate's infrastructure directly.

When the customer submits the payment form, Collect.js intercepts the submit event, sends the card data from the iFrames to CyoGate's tokenization endpoint over an encrypted connection, and returns a one-time-use payment token to your JavaScript callback. Your form submission then sends that token to your server. Your server uses the token to complete the transaction through the CyoGate API — charging the card, storing it in the customer vault for future use, or performing any other transaction operation you need.

The token is tied to the specific card data captured in that session and is single-use for a transaction initiation, after which the customer vault token (if storage was requested) becomes the durable reference for future charges. Raw card data exists only in CyoGate's PCI Level 1 certified environment at every point in this flow.

Collect.js vs. Hosted Payment Page Redirect

Collect.js is one of two hosted approaches to removing card data from your server environment. The alternative is a hosted payment page redirect, where the customer leaves your site entirely to enter card data on a page hosted by CyoGate, then returns to your site after the transaction.

Both approaches keep raw card data off your server and both qualify for SAQ A compliance. The tradeoff is checkout experience control vs. integration simplicity.

With Collect.js, the customer never leaves your page. The card fields look and feel like part of your checkout — you control the surrounding design, layout, and flow. The iFrame boundaries are invisible to the customer. This produces a seamless checkout experience that typically converts better than redirect flows, particularly on mobile where page transitions during checkout increase abandonment.

With a hosted payment page redirect, integration is simpler (you redirect, receive a callback, handle the result) but you lose control of the checkout design and introduce a navigation step that can increase cart abandonment. Redirect flows are appropriate for merchants who want the fastest possible integration path and aren't concerned about checkout UX customization.

For merchants building custom checkout flows, subscriptions, or applications where checkout experience matters, Collect.js is the right choice. The developer portal has full Collect.js documentation including the JavaScript library reference, iFrame styling options, and example implementations.

PCI DSS 4.0 Script Requirements and Collect.js

PCI DSS 4.0 introduced new requirements for ecommerce checkout pages that became mandatory in March 2025. Requirement 6.4.3 specifically addresses script management: every script loaded on a payment page must be authorized by the merchant, and an integrity mechanism (Subresource Integrity or equivalent) must be in place to detect unauthorized script modification.

This requirement exists because of Magecart and similar attacks where malicious scripts injected into checkout pages silently exfiltrate card data as customers type it. Even with hosted tokenization, a compromised checkout page that injects a keylogger before Collect.js runs can capture card data before it reaches the iFrame.

For Collect.js integrations, this means your checkout page needs to implement Subresource Integrity (SRI) for the Collect.js script tag itself, maintain an authorized script inventory for all other scripts on the payment page, and have a mechanism to detect unauthorized script additions. Our post on PCI DSS 4.0 checkout page requirements covers the specific implementation requirements in detail.

Collect.js and the Customer Vault

One of the most valuable Collect.js use cases is storing cards for future use. When a customer completes a transaction through Collect.js, you can request that the card be stored in CyoGate's Customer Vault by including the appropriate parameters in your API call. The vault stores a tokenized reference to the card and returns a vault token that you store in your database.

For subsequent transactions — subscription renewals, one-click repeat purchases, installment payments — your server uses the vault token to initiate the charge without any new card data collection. The customer doesn't re-enter their card for repeat purchases. The raw card data remains in CyoGate's vault and never appears in your application at any point.

This pattern is the foundation for recurring billing implementations that comply with card network credential-on-file requirements. The vault token is the stored credential; the initial Collect.js transaction where the customer entered their card is the cardholder-initiated transaction that established the credential-on-file relationship. Subsequent vault charges are merchant-initiated transactions that must be flagged accordingly in the API call.

Tokenization vs. Encryption: Clarifying the Difference

Collect.js implements tokenization, not encryption. Our post on tokenization vs. encryption covers the distinction in detail, but the short version for Collect.js specifically: encryption transforms card data into ciphertext that can be decrypted back to the original value. Tokenization replaces card data with a token that has no mathematical relationship to the original PAN — the mapping between token and card data exists only in the secure vault. A compromised token reveals nothing about the underlying card number. This is why tokenization is superior to encryption for PCI scope reduction.

Getting Started with Collect.js

Collect.js integration requires an active CyoGate merchant account and gateway credentials. The integration path:

Start in the sandbox environment using the test credentials available through the developer portal. Load Collect.js from the CyoGate CDN, configure your iFrame fields, implement the token callback, and connect your server-side API call that uses the token to complete the transaction. Test the full flow including successful authorizations, declines, CVV failures, and AVS responses. Then implement SRI for the Collect.js script tag to satisfy PCI DSS 4.0 Requirement 6.4.3 before going live.

If you're evaluating CyoGate's gateway for a new integration or migrating from another processor, the Collect.js approach compares favorably to Stripe.js, Braintree's hosted fields, and similar implementations from other gateways. The key differentiator for high-risk merchants is that CyoGate's gateway supports Collect.js tokenization across a broad range of processor connections, including many processors that support 3D Secure authentication end-to-end through the gateway.

Questions about Collect.js integration or ready to get started? Visit the CyoGate developer portal for documentation, or apply for a merchant account if you need the processing relationship alongside the gateway.