maxmind

package
v0.0.0-...-d355ef6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// URL of maxMind service, overwritten via ENV variable.
	URL = ""
)

Functions

func RiskCheck

func RiskCheck(firstSixDigits, lastFourDigits string, IPAddress IP, emailAddress Email) (score float64, err error)

RiskCheck queries the minFraud service from MaxMind for Credit Card fraud patterns matching.

Returns just the riskScore value, you could extrad more information by parsing the Response object.

Types

type Email

type Email string

Email is an ISO email address.

type IP

type IP string

IP is an IPv4 address.

type Response

type Response struct {
	IPAddress struct {
		Risk    float64 `json:"risk"`
		Country struct {
			IsHighRisk bool   `json:"is_high_risk"`
			Confidence int    `json:"confidence"`
			IsoCode    string `json:"iso_code"`
			GeonameID  int    `json:"geoname_id"`
			Names      struct {
			} `json:"names,omitempty"`
		} `json:"country"`
		Location struct {
			LocalTime      time.Time `json:"local_time"`
			AccuracyRadius int       `json:"accuracy_radius"`
			Latitude       float64   `json:"latitude"`
			Longitude      float64   `json:"longitude"`
			TimeZone       string    `json:"time_zone"`
		} `json:"location"`
		City struct {
			Confidence int `json:"confidence"`
			GeonameID  int `json:"geoname_id"`
		} `json:"city"`
		Continent struct {
			Code      string `json:"code"`
			GeonameID int    `json:"geoname_id"`
		} `json:"continent"`
		Postal struct {
			Confidence int    `json:"confidence"`
			Code       string `json:"code"`
		} `json:"postal"`
		RegisteredCountry struct {
			IsoCode   string `json:"iso_code"`
			GeonameID int    `json:"geoname_id"`
		} `json:"registered_country"`
		Subdivisions []struct {
			Confidence int    `json:"confidence"`
			IsoCode    string `json:"iso_code"`
			GeonameID  int    `json:"geoname_id"`
		} `json:"subdivisions"`
		Traits struct {
			UserType                     string `json:"user_type"`
			AutonomousSystemNumber       int    `json:"autonomous_system_number"`
			AutonomousSystemOrganization string `json:"autonomous_system_organization"`
			Isp                          string `json:"isp"`
			Organization                 string `json:"organization"`
			IPAddress                    string `json:"ip_address"`
		} `json:"traits"`
	} `json:"ip_address"`
	CreditCard struct {
		Issuer struct {
			Name        string `json:"name"`
			PhoneNumber string `json:"phone_number"`
		} `json:"issuer"`
		Brand     string `json:"brand"`
		Country   string `json:"country"`
		IsPrepaid bool   `json:"is_prepaid"`
		IsVirtual bool   `json:"is_virtual"`
		Type      string `json:"type"`
	} `json:"credit_card"`
	ID               string  `json:"id"`
	RiskScore        float64 `json:"risk_score"`
	FundsRemaining   float64 `json:"funds_remaining"`
	QueriesRemaining int     `json:"queries_remaining"`
}

Response stores the data returned from MaxMind's API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL