simplecms / bank
Laravel 银行组件 / 银行大全
1.0.2
2024-07-13 01:34 UTC
Requires
- php: >=8.0
- laravel/framework: >=9.0
Requires (Dev)
- phpunit/phpunit: ^9.5.8
This package is auto-updated.
Last update: 2024-09-13 02:09:07 UTC
README
📦 包含了银联发布的260家银行的全面信息集合。
英语 | 简体中文
要求
- PHP >= 8.0
- Laravel/Framework >= 9.0
安装
composer require simplecms/bank
用法
包含验证规则和safe_bank_number方法。
获取银行列表
use SimpleCMS\Bank\Facades\Bank; Bank::getBankList(); //Returns the complete list Bank::getOptions(); // Returns as Collection<value:string, name:string> Bank::getOptions('DC'); // Returns a list of debit card banks. Supports all, DC, CC, SCC, PC
查询和检查
use SimpleCMS\Bank\Facades\Bank; Bank::getBankByCode($code); // Retrieve bank information by code Bank::getBankByName($name); // Retrieve bank information by name Bank::getBankByBin($bin); // Retrieve bank information by BIN Bank::getBankByCardNumber($card_number); // Retrieve bank information by card number Bank::checkBin($bin); // Check the validity of BIN Bank::checkCardNumber($card_number); // Check the validity of card number
助手
$card_number = '62270000000006666'; //Bank card masking safe_bank_number((string) $card_number, (string) $maskChar = '*', (int) $start = 6, (int) $length = 4); // 622700********6666
验证
$rules = [ 'bank' => 'bank', //Bank name 'bank_bin' => 'bank_bin', //Bank BIN 'bank_card' => 'bank_card', //Bank card number 'bank_code' => 'bank_code' //Bank code ]; $messages = [ 'bank.bank' => 'The name of bank is incorrect.', 'bank_bin.bank_bin' => 'The bin code is incorrect.', 'bank_card.bank_card' => 'The card number is incorrect.', 'bank_code.bank_code' => 'The code of bank is incorrect.', ]; $data = $request->validate($rules,$messages);
自定义银行数据
您可以通过.env
文件自定义自己的数据。
修改配置文件路径
将以下代码添加到您的.env
文件中
BANK_PATH='Your bank JSON file address' #Absolute location
JSON数据格式
数据结构遵循以下格式
{ "name": "Bank Name", "code": "Bank code identifier", "bins": { "DC": { # DC Debit Card "19": ["123456", "23456"] # 19 is the card number length, numeric content is the BIN code }, "CC": { # CC Credit Card "18": ["32131", "13123"] }, "SCC": { # Semi-Credit Card "16": ["1233", "2345"], "17": ["3213", "3322"] }, "PC": { # Prepaid Card "15": ["1234"] } } }
许可证
MIT