### Install bcbc Source: https://pkg.go.dev/github.com/hexindai/bcbc Install the tool using the Go command line interface. ```bash $ go install github.com/hexindai/bcbc@latest ``` -------------------------------- ### HTTP Server Usage Source: https://pkg.go.dev/github.com/hexindai/bcbc Start the HTTP server and query card information via curl. ```bash $ bcbc serve -p :3232 $ curl http://127.0.0.1:3232/cardInfo.json?cardNo=6222021234567890123 > {"bin":"622202","bank":"ICBC","name":"中国工商银行","type":"DC","length":19} ``` -------------------------------- ### Get Bank Card BIN Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Retrieves card bin information from the bank instance. ```go func (in Bank) Get(card string) (c *CardBIN, e error) ``` -------------------------------- ### Get Bank Name Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Returns the bank name associated with the CardBIN. ```go func (cb CardBIN) BankName() string ``` -------------------------------- ### Get Card BIN Information Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Retrieves Card BIN information using a provided card number. This function can be called directly or via a Bank instance. ```APIDOC ## GET /api/cardbin ### Description Retrieves Card BIN information for a given card number. ### Method GET ### Endpoint /api/cardbin ### Parameters #### Query Parameters - **card** (string) - Required - The card number to search for. ### Response #### Success Response (200) - **Bin** (string) - The Card BIN number. - **Bank** (string) - The name of the bank. - **Type** (string) - The type of card (e.g., Credit, Debit). - **Length** (int) - The length of the card number. #### Response Example ```json { "Bin": "622202", "Bank": "China Merchants Bank", "Type": "Credit Card", "Length": 19 } ``` ``` ```APIDOC ## func Get(card string) (*CardBIN, error) ### Description Fetches Card BIN details using a card number. ### Parameters #### Path Parameters - **card** (string) - Required - The card number to search. ### Response #### Success Response (200) - **CardBIN** (*CardBIN) - A pointer to the CardBIN struct containing BIN details. - **error** (error) - An error if the operation fails. #### Response Example ```json { "Bin": "6222021234567890123", "Bank": "Example Bank", "Type": "Debit Card", "Length": 16 } ``` ``` ```APIDOC ## func (Bank) Get(card string) (c *CardBIN, e error) ### Description Retrieves Card BIN information from a Bank instance using a card number. ### Parameters #### Path Parameters - **card** (string) - Required - The card number to search. ### Response #### Success Response (200) - **c** (*CardBIN) - A pointer to the CardBIN struct containing BIN details. - **e** (error) - An error if the operation fails. #### Response Example ```json { "Bin": "6222021234567890123", "Bank": "Example Bank", "Type": "Debit Card", "Length": 16 } ``` ``` -------------------------------- ### Display Help Source: https://pkg.go.dev/github.com/hexindai/bcbc Show the command-line help menu. ```bash $ bcbc -h ``` -------------------------------- ### Contribution Commands Source: https://pkg.go.dev/github.com/hexindai/bcbc Commands for adding new BIN data and building the project. ```bash make add len=16 bin=621245 make build ``` -------------------------------- ### CLI Search Source: https://pkg.go.dev/github.com/hexindai/bcbc Perform a bank card BIN lookup via the command line. ```bash $ bcbc search -c 6222021234567890123 -o json > {"bin":"622202","bank":"ICBC","name":"中国工商银行","type":"DC","length":19} ``` -------------------------------- ### New Bank Instance Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Creates and initializes a new Bank instance with a provided list of CardBINs. ```APIDOC ## func New(cb []*CardBIN) *Bank ### Description Creates a new Bank instance initialized with a slice of CardBINs. ### Parameters #### Request Body - **cb** ([]*CardBIN) - Required - A slice of CardBIN objects to initialize the bank with. - **Bin** (string) - The Card BIN number. - **Bank** (string) - The name of the bank. - **Type** (string) - The type of card. - **Length** (int) - The length of the card number. ### Request Example ```json [ { "Bin": "622204", "Bank": "Agricultural Bank of China", "Type": "Debit Card", "Length": 16 }, { "Bin": "622205", "Bank": "Bank of China", "Type": "Credit Card", "Length": 19 } ] ``` ``` -------------------------------- ### Execute command function Source: https://pkg.go.dev/github.com/hexindai/bcbc/cmd Entry point for executing the bcbc command. ```go func Execute() ``` -------------------------------- ### Insert Card BIN Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Adds a CardBIN to the bank instance. ```go func (in Bank) Insert(cb *CardBIN) ``` -------------------------------- ### Initialize New Bank Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Creates and returns a new Bank instance initialized with a slice of CardBIN pointers. ```go func New(cb []*CardBIN) *Bank ``` -------------------------------- ### New CardBinCheckResponse constructor Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Constructor function to create a new CardBinCheckResponse instance. ```go func New(card string) *CardBinCheckResponse ``` -------------------------------- ### Define BCBCVERSION constant Source: https://pkg.go.dev/github.com/hexindai/bcbc/cmd Defines the current version string for the bcbc package. ```go const BCBCVERSION = "0.0.16" ``` -------------------------------- ### New Function Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Constructor function to initialize a new CardBinCheckResponse. ```APIDOC ## func New ### Description Creates a new instance of CardBinCheckResponse based on the provided card string. ### Parameters - **card** (string) - The card number to check. ### Returns - ***CardBinCheckResponse** - A pointer to the initialized response object. ``` -------------------------------- ### Card BINs List Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank An array containing card bin data. ```go var CardBINs = [...]*CardBIN{}/* 1709 elements not displayed */ ``` -------------------------------- ### Fetch Card BIN Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Fetches card bin information for a specific card number. ```go func Get(card string) (*CardBIN, error) ``` -------------------------------- ### Insert Card BIN into Bank Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Inserts a new CardBIN into the Bank's internal storage. ```APIDOC ## func (Bank) Insert(cb *CardBIN) ### Description Inserts a CardBIN into the bank. ### Parameters #### Request Body - **cb** (*CardBIN) - Required - The CardBIN object to insert. - **Bin** (string) - The Card BIN number. - **Bank** (string) - The name of the bank. - **Type** (string) - The type of card. - **Length** (int) - The length of the card number. ### Request Example ```json { "Bin": "622203", "Bank": "Industrial and Commercial Bank of China", "Type": "Credit Card", "Length": 19 } ``` ``` -------------------------------- ### Search Card BIN Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Retrieves card bin information for a given card number string. ```go resp, err := bank.Get("6222021234567890123") ``` -------------------------------- ### CardBIN Type Methods Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Provides methods for interacting with CardBIN data. ```APIDOC ## type CardBIN ### Description Represents a China UnionPay Card BIN (Bank Identification Number). ### Fields - **Bin** (string) - The BIN number. - **Bank** (string) - The name of the bank. - **Type** (string) - The type of card (e.g., Credit, Debit). - **Length** (int) - The length of the card number. ``` ```APIDOC ## func (CardBIN) BankName() string ### Description Returns the bank name associated with the CardBIN. ### Response #### Success Response (200) - **string** - The bank name. ``` -------------------------------- ### Package Variables Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Defines error variables for parameter validation and card bin matching. ```go var ( // ErrParamIllegal PARAM_ILLEGAL ErrParamIllegal = errors.New("bank: PARAM_ILLEGAL") // ErrCardBINNotMatch CARD_BIN_NOT_MATCH ErrCardBINNotMatch = errors.New("bank: CARD_BIN_NOT_MATCH") ) ``` -------------------------------- ### BCBC Version Information Source: https://pkg.go.dev/github.com/hexindai/bcbc/cmd Provides information about the BCBC package version. ```APIDOC ## Constants ### BCBCVERSION `const BCBCVERSION = "0.0.16"` **Description:** bcbc version ``` -------------------------------- ### Define CardBinCheckResponse struct Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Defines the structure for a card bin check response, including card type, bank, key, messages, validation status, and card BIN. ```go type CardBinCheckResponse struct { CardType string `json:"cardType"` Bank string `json:"bank"` Key string `json:"key"` Messages []errorMessage `json:"messages"` Validated bool `json:"validated"` Stat string `json:"stat"` CardBIN string } ``` -------------------------------- ### Bank Name Map Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank A map storing bank abbreviations as keys and bank names as values. ```go var BankNameMap = map[string]string{}/* 275 elements not displayed */ ``` -------------------------------- ### WriteResponse method for CardBinCheckResponse Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Writes the CardBinCheckResponse to an io.Writer in a specified content type. ```go func (cbcr *CardBinCheckResponse) WriteResponse(w io.Writer, c ContentType) error ``` -------------------------------- ### ContentType constants Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Defines constants for JSON and Text content types for CardBinCheckResponse. ```go const ( // JSONContentType JSON content type JSONContentType ContentType = iota // TextContentType JSON content type TextContentType ) ``` -------------------------------- ### Bank Struct Definition Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Represents the bank structure. ```go type Bank struct { // contains filtered or unexported fields } ``` -------------------------------- ### Execute Function Source: https://pkg.go.dev/github.com/hexindai/bcbc/cmd Details the Execute function within the BCBC package. ```APIDOC ## Functions ### Execute `func Execute() ` **Description:** Execute bcbc command ``` -------------------------------- ### WriteResponse Method Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Method to serialize and write the response to an output stream. ```APIDOC ## func (*CardBinCheckResponse) WriteResponse ### Description Writes the CardBinCheckResponse to an io.Writer in the specified ContentType format. ### Parameters - **w** (io.Writer) - The destination writer. - **c** (ContentType) - The format type (JSONContentType or TextContentType). ``` -------------------------------- ### CardBIN Struct Definition Source: https://pkg.go.dev/github.com/hexindai/bcbc/bank Represents the structure of a bank card bin. ```go type CardBIN struct { Bin string Bank string Type string Length int } ``` -------------------------------- ### CardBinCheckResponse Structure Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Defines the data structure for bank card validation results. ```APIDOC ## type CardBinCheckResponse ### Description Represents the result of a bank card BIN check operation. ### Fields - **CardType** (string) - The type of the card. - **Bank** (string) - The issuing bank. - **Key** (string) - The associated key. - **Messages** ([]errorMessage) - A list of error messages if any. - **Validated** (bool) - Indicates if the card is validated. - **Stat** (string) - The status of the check. - **CardBIN** (string) - The card BIN number. ``` -------------------------------- ### Define ContentType type Source: https://pkg.go.dev/github.com/hexindai/bcbc/response Defines an integer type for representing content types of CardBinCheckResponse. ```go type ContentType int ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.