It validates credit card details, display credit card types and reduces human error using the Luhn algorithm with REST APIs.
Basic credit card validation using the Luhn algorithm
Currently identifies the following credit card companies:
- American Express
- MasterCard
- Visa
- Visa Electron
$ git clone git@github.com:bitcyber/golang-credit-card.git
OR
$ go get github.com/bitcyber/golang-credit-card
Download all go-gettable dependencies for your project.
$ go get -d ./...
Run this command on Terminal after installation
$ go run main.go
Once the application is running, navigate to http://localhost:3000 in your browser. If all went well, you should see level 1 header text Welcome to the Credit Card Validation displayed.
Returns json data about a single credit card.
-
URL
http://localhost:3000/card-scheme/verify/:cardNumber
-
Method:
GET
-
URL Params
Required:
cardNumber=[integer]
-
Data Params
None
-
Success Response:
-
Code: 200
Content:{ "success" : "true", "valid": "true", "scheme": "AMEX/VISA/MASTERCARD" }
OR
-
Code: 200
Content:{ "INVALID CARD NUMBER" }
-
-
Error Response:
- Code: 404 NOT FOUND
Content:{ 404 page not found }
- Code: 404 NOT FOUND
-
Sample Request:
http://localhost:3000/card-scheme/verify/373473833566829
-
Sample Response:
{ "success": "true", "valid": "true", "scheme": "AMEX" }
Any help and suggestions are very welcome and appreciated.