Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 1.87 KB

README.md

File metadata and controls

57 lines (43 loc) · 1.87 KB

Banks DB

Build Status Go Reference Go Report Card Release codecov

Community driven database to get bank info (name, brand, color, etc.) by bankcard prefix (BIN)

This is golang port of ramoona's banks-db.

Install

go get -u github.com/khasanovbi/banksdb

Usage

Below is an example which shows some common use cases for banksdb:

package main

import (
	"fmt"

	"github.com/khasanovbi/banksdb/v2"
	"github.com/khasanovbi/banksdb/v2/paymentsystem"
)

func main() {
	for _, creditCard := range []string{"5275940000000000", "4111111111111111"} {
		bank := banksdb.FindBank(creditCard)
		paymentSystem := paymentsystem.FindPaymentSystem(creditCard)
		fmt.Printf("CreditCard: %s\n", creditCard)
		fmt.Printf("Bank info: %#v\n", bank)
		if paymentSystem != nil {
			fmt.Printf("Payment system: %s\n", *paymentSystem)
		}
		fmt.Println()
	}
}

Output:

CreditCard: 5275940000000000
Bank info: &banksdb.Bank{Name:"citibank", Country:"ru", LocalTitle:"Ситибанк", EngTitle:"Citibank", URL:"https://www.citibank.ru/", Color:"#0088cf", Prefixes:[]int{419349, 427760, 427761, 520306, 527594}}
Payment system: MasterCard

CreditCard: 4111111111111111
Bank info: (*banksdb.Bank)(nil)
Payment system: Visa