Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ingresse/card-bin-ex
:credit_card: Elixir module to get the CreditCard brand based in the first digits
https://github.com/ingresse/card-bin-ex
backend cardbin credit-card elixir
Last synced: 3 days ago
JSON representation
:credit_card: Elixir module to get the CreditCard brand based in the first digits
- Host: GitHub
- URL: https://github.com/ingresse/card-bin-ex
- Owner: ingresse
- License: mit
- Archived: true
- Created: 2019-05-16T19:33:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-20T21:43:54.000Z (over 4 years ago)
- Last Synced: 2024-12-29T12:23:14.498Z (27 days ago)
- Topics: backend, cardbin, credit-card, elixir
- Language: Elixir
- Homepage: https://ingresse.github.io/card-bin-ex/
- Size: 123 KB
- Stars: 3
- Watchers: 23
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# :credit_card: CardBinEX
[Elixir](https://elixir-lang.org/) module to discover the CreditCard brand based in the first digits.
## Valid CreditCard brands
| brand | alias |
|------------------|-------------|
| Visa | `visa` |
| Elo | `elo` |
| JCB | `jcb` |
| Diners | `diners` |
| Discover | `discover` |
| MasterCard | `master` |
| Hipercard | `hipercard` |
| American Express | `amex` |## Install
```elixir
def deps do
[
{:card_bin_ex, "~> 1.0"}
]
end
```## Usage
Get the creditcard brand base in the first digits.
```elixir
iex> CardBinEx.brand_from_number("4716892")
{:ok, "visa"}iex> CardBinEx.brand_from_number("9716892")
{:error, :card_brand, "9716892"}
```Get the creditcard brand base in the first digits and return only the brand.
It will raise `CardBinEx.Error` if is an invalid bin.
```elixir
iex> CardBinEx.brand_from_number!("4716892")
"visa"iex> try do
...> CardBinEx.brand_from_number!("9716892")
...> rescue
...> e in CardBinEx.Error -> IO.puts(e.message)
..> end
```