52

GitHub - chekalskiy/php-bank-db: PHP library for getting bank info (name, brand...

 5 years ago
source link: https://github.com/chekalskiy/php-bank-db
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

PHP Banks DB

Build Status codecov

It is a PHP port of ramoona's banks-db.

Returns bank's name and brand color by bank card number's first digits (BIN, Issuer Identification Numbers, IIN).

Installation

composer require chekalskiy/php-bank-db

Basic usage

$card_prefix = '5275 9400 0000 0000'; // we only need first 6 digits but it could be the whole card number

try {
    $bank_db = new BankDb();
    $bank_info = $bank_db->getBankInfo($card_prefix);

    $result = [
        'is_unknown' => $bank_info->isUnknown(), // is bank unknown
        'name' => $bank_info->getTitle(true),
        'color' => $bank_info->getColor(),
        'type' => $bank_info->getCardType(),
    ];

    return $result;
} catch (BankDbException $e) {
    // todo handle exception
}

About database

We use simple PHP-file with an array inside (it's regenerates every time ramoona's repository is updated). It's very fast and simple way to work with data because of opcache enabled by default in PHP 7. But you can extend BankDB class to make it work with redis or something, but for most cases compiled php-file is OK.

Contributions

Feel free to open an issue on every question you have.


It's a community driven database, so it can potentially contains mistakes.

For UI examples see the original library.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK