Skip to content
Security & Data Validation

PAN validator

The card validation API checks a number with Luhn and masks all but the last four digits. It stores nothing and keeps the number out of your logs.

GET https://api2.globus.studio/v2/pan

Reference

Parameters

Name Type Required Description
card_number string yes Card number, spaces and punctuation are stripped.
number string alias Alias for card_number.
format string no plain, json, jsonp. Default: plain.
callback string no JSONP callback name. Default: callback.
curl -s "https://api2.globus.studio/v2/pan?card_number=4111111111111111&format=json"
Open documentation

PAN validator

The PAN validator checks a card number with the Luhn algorithm. The number is not stored and is not sent to a payment provider. The response masks all but the last four digits, so a log or a browser history entry does not contain the full value.

What the PAN validator returns

The JSON body has a masked card_number and a validity field with valid or invalid. The raw number is not returned by default. The old contract returned the full value, which is a leak; keep the default unless a legacy client cannot work without it.

What Luhn checks

The algorithm doubles every second digit from the right, subtracts nine from results above nine and sums the digits. A valid number produces a total divisible by ten. It catches single-digit errors and most adjacent transpositions. It cannot catch a valid number that was never issued.

Example request

curl "https://api2.globus.studio/v2/pan?card_number=4111111111111111&format=json"

Use the test numbers published by a payment provider sandbox. They pass the PAN validator and behave in predictable ways. Do not use a real card for testing, even your own.

Where to run the check

Run it in the payment form before you create a token with the provider. If the number fails, show a field error and let the customer fix it. Run the same check on the server when the form posts. A client-side pass is a convenience; the server decides what enters the system. Return one message and never echo the number or point at the failed digit.

What the PAN validator does not do

It does not detect the card brand, the issuing bank or the expiry date. It does not perform an authorization. It is one field validation, and it should stay that way. A Luhn-valid number with the wrong length for the brand is still invalid, so check the length and the prefix in the form and let the provider confirm the brand.

Storage and PCI scope

If the card number reaches your server, the server is in scope for PCI DSS. If the provider form collects the number and returns a token, the number never touches your code. The second design is simpler to audit. Store the token, the last four digits, the brand and the expiry, and keep the full number out of logs and error messages.

Test numbers and brand rules

Payment providers publish test numbers for each brand. Use them in the sandbox and keep one per brand in the test fixture. A number that passes the PAN validator can still belong to a brand with a different length, so check the length and the prefix in the form before the provider call. Do not hard-code a list of brands in the validator; the provider knows the current rules.

A card number is not a secret you can rotate like a password. If it appears in a log, treat the log as sensitive and remove the entry. The masked value is enough for support: the last four digits identify the card without exposing the rest.

Limits

The endpoint is fast and rate limited like the other cheap calls. A slow payment form loses orders, so keep the call short and show the result while the customer waits. The PAN validator does not know the card brand or the issuer, and it cannot replace address verification, 3-D Secure or the provider fraud checks. Read the card validation guide for the payment flow around the check.

At signup, pair the PAN validator with the email validator. For an admin account, use the strong password generator.

Further reading: PCI Security Standards Council.

Custom work

Need an API that does not exist yet?

Describe the task and the response format. We will estimate the endpoint, the integration and the maintenance.

Start a conversation