jlorente/php-credit-cards
A PHP package for validating credit card numbers and detecting card brands using length checks, Luhn algorithm, and issuer patterns. Includes Laravel validation support, making it easy to reject invalid payment details and identify Visa, Mastercard, Amex, and more.
Consider it when:
Look elsewhere when:
To executives: This is a small, free, MIT-licensed library that handles the boring but error-prone part of payment forms — checking that a card number is well-formed and identifying the brand. It costs roughly a day of engineering to integrate and removes a class of self-inflicted checkout failures, which maps to conversion and support-ticket reduction. There is no vendor lock-in, no contract, and no per-transaction cost. The main caveat is that it is a small open-source project, so we would wrap it in our own thin interface: if it is ever abandoned, we swap it out without touching product code. It does not change our compliance obligations — card data still flows through our PSP's tokenization, and we would not store card numbers.
To engineering: Single-purpose, framework-agnostic Composer package. Use it strictly server-side and strictly before PSP tokenization, behind our own CardValidator interface so brand tables and validation rules can be replaced or extended. Do not log or persist the raw PAN — mask on the way in, and reuse its formatting only for display. Add contract tests around brand detection for the card types we actually accept, since the supported-brand list is finite and can drift. Keep an eye on release cadence; pin the version and review on upgrade. Roughly 1–2 days including tests, adapter, and a client/server parity check.
How can I help you explore Laravel packages today?