Download the PHP package jlorente/php-credit-cards without Composer

On this page you can find all versions of the php package jlorente/php-credit-cards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-credit-cards

PHP Credit Cards

A PHP package to perform operations on debit and credit cards like format, validate brand, number and Luhn algorithm. It validates popular brands like Visa, Mastercard, American Express, etc.

This package is based on the braintree/credit-card-type javascript package. All the card types configuration have been extracted from it.

Current Cart Type Validators

Installation

The preferred way to install this extension is through composer.

With Composer installed, you can then install the extension using the following commands:

or add

to the section of your composer.json file.

Usage

You can create an instance of the validator either by using the common constructor or the static make method.

or

By default, the validator will load the configuration of all the card types that come along with the package, but you can limit the allowed types by providing an array with the card type codes.

or

Validating a credit card number without knowing the type

Validating a credit card number knowing the type

or

Get the type configuration of a card number

With the type configuration you can know metadata info, perform some validation or format the card number using the class methods.

CreditCardTypeConfig

Method Description Return example
getType(): string Get the type of the card type configuration "visa", "mastercard"
getNiceType(): string Get the nice type of the card type configuration "Visa", "Mastercard"
getPatterns(): array Get the patterns that the card type configuration uses to validate a card number [50, [55, 59]]
getGaps(): array Get the index of the position in card number string where to put blank spaces on card formatting [4, 8, 12]
getLengths(): array Get the allowed lengths that the card type configuration uses to validate the card numbers [16, 19]
getCode(): string Get the security code configuration of the card type ["name" => "CVC", "size" => 4]
getLuhnCheck(): bool Get the luhn check value of the configuration true
setLuhnCheck(bool $value): $this Set the luhn check value. If true, the validator will validate the card number with the Luhn's algorithm
matches(string $cardNumber): bool Check if the given card number matches the card type configuration false
matchesPatterns(string $cardNumber): bool Check if the card number matches one of the patterns array configuration true
matchesLengths(string $cardNumber): bool Check if the card number matches one of the lengths array configuration true
satisfiesLuhn(string $cardNumber): bool Check if the card number satisfies the luhn's algorithm true
matchesSecurityCode(string $cardNumber): bool Check if the card number satisfies the luhn's algorithm false
format(string $cardNumber): string Format the card number according to the gap configuration "4242 4242 4242 4242"

Contribute

Feel free to add new credit card configurations or fix the current ones and create a pull request to keep the package up to date.

A credit type configuration has the following structure:

License

Copyright © 2020 José Lorente Martín [email protected].

Licensed under the MIT License. See LICENSE.txt for details.


All versions of php-credit-cards with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jlorente/php-credit-cards contains the following files

Loading the files please wait ....