minfraud

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	BaseResponse
	IPAddress       IPAddress       `json:"ip_address"`
	BillingAddress  BillingAddress  `json:"billing_address"`
	CreditCard      CreditCard      `json:"credit_card"`
	Device          Device          `json:"device"`
	Email           Email           `json:"email"`
	ShippingAddress ShippingAddress `json:"shipping_address"`
	Subscores       Subscores       `json:"subscores"`
}

APIResponse is used to align the type from API request.

type AccountData

type AccountData struct {
	UserID      string `json:"user_id,omitempty"`
	UserNameMD5 string `json:"username_md5,omitempty"`
}

type BaseRequest

type BaseRequest struct {
	Account      *AccountData       `json:"account,omitempty"`
	Billing      *BillingData       `json:"billing,omitempty"`
	CreditCard   *CreditCardData    `json:"credit_card,omitempty"`
	Device       *DeviceData        `json:"device,omitempty"`
	Email        *EmailData         `json:"email,omitempty"`
	Event        *EventData         `json:"event,omitempty"`
	Order        *OrderData         `json:"order,omitempty"`
	Payment      *PaymentData       `json:"payment,omitempty"`
	Shipping     *ShippingData      `json:"shipping,omitempty"`
	ShoppingCart []ShoppingCartData `json:"shopping_cart,omitempty"`

	// ref: https://support.maxmind.com/custom-inputs-guide/
	CustomInputs interface{} `json:"custom_inputs,omitempty"`
}

BaseRequest is common request of minFraud API. ref: https://dev.maxmind.com/minfraud/api-documentation/requests

type BaseResponse

type BaseResponse struct {
	ErrData
	Disposition      Disposition `json:"disposition"`
	FundsRemaining   float64     `json:"funds_remaining"`
	ID               string      `json:"id"`
	QueriesRemaining int64       `json:"queries_remaining"`
	RiskScore        float64     `json:"risk_score"` // from 0.01 to 99
	Warnings         []Warning   `json:"warnings"`
}

BaseResponse is common response of minFraud API. ref: https://dev.maxmind.com/minfraud/api-documentation/responses

func (BaseResponse) HasError

func (r BaseResponse) HasError() bool

type BillingAddress

type BillingAddress struct {
	DistanceToIPLocation int64   `json:"distance_to_ip_location"`
	IsInIPCountry        bool    `json:"is_in_ip_country"`
	IsPostalInCity       bool    `json:"is_postal_in_city"`
	Latitude             float64 `json:"latitude"`
	Longitude            float64 `json:"longitude"`
}

type BillingData

type BillingData struct {
	Address          string `json:"address,omitempty"`
	Address2         string `json:"address_2,omitempty"`
	City             string `json:"city,omitempty"`
	Company          string `json:"company,omitempty"`
	Country          string `json:"country,omitempty"`
	FirstName        string `json:"first_name,omitempty"`
	LastName         string `json:"last_name,omitempty"`
	PhoneCountryCode string `json:"phone_country_code,omitempty"`
	PhoneNumber      string `json:"phone_number,omitempty"`
	Postal           string `json:"postal,omitempty"`
	Region           string `json:"region,omitempty"`
}

type City

type City struct {
	Confidence Confidence `json:"confidence"`
	GeoNameID  GeoNameID  `json:"geoname_id"`
	Names      Names      `json:"names"`
}

type Confidence

type Confidence int64

from 0 to 100

type Continent

type Continent struct {
	Code      string    `json:"code"` // [AF, AN, AS, EU, NA, OC, SA]
	GeoNameID GeoNameID `json:"geoname_id"`
	Names     Names     `json:"names"`
}

type Country

type Country struct {
	Confidence Confidence `json:"confidence"`
	CountryData
}

type CountryData

type CountryData struct {
	GeoNameID         GeoNameID `json:"geoname_id"`
	IsInEuropeanUnion bool      `json:"is_in_european_union"`
	ISOCode           string    `json:"iso_code"` // ISO 3166-1 alpha-2
	Names             Names     `json:"names"`
}

common data for country type object.

type CreditCard

type CreditCard struct {
	Brand                           string `json:"brand"`
	Country                         string `json:"country"`
	IsBusiness                      bool   `json:"is_business"`
	IsIssuedInBillingAddressCountry bool   `json:"is_issued_in_billing_address_country"`
	IsPrepaid                       bool   `json:"is_prepaid"`
	IsVirtual                       bool   `json:"is_virtual"`
	Issuer                          Issuer `json:"issuer"`
	Type                            string `json:"type"`
}

type CreditCardData

type CreditCardData struct {
	AVSResult             string `json:"avs_result,omitempty"`
	BankName              string `json:"bank_name,omitempty"`
	BankPhoneCountryCode  string `json:"bank_phone_country_code,omitempty"`
	BankPhoneNumber       string `json:"bank_phone_number,omitempty"`
	CVVResult             string `json:"cvv_result,omitempty"`
	IssuerIDNumber        string `json:"issuer_id_number,omitempty"`
	Last4Digits           string `json:"last_4_digits,omitempty"`
	Token                 string `json:"token,omitempty"`
	Was3DSecureSuccessful *bool  `json:"was_3d_secure_successful,omitempty"`
}

type Device

type Device struct {
	Confidence Confidence `json:"confidence"`
	ID         string     `json:"id"`
	LastSeen   string     `json:"last_seen"`
	LocalTime  string     `json:"local_time"`
}

type DeviceData

type DeviceData struct {
	AcceptLanguage string  `json:"accept_language,omitempty"`
	IPAddress      string  `json:"ip_address,omitempty"`
	SessionAge     float64 `json:"session_age,omitempty"`
	SessionID      string  `json:"session_id,omitempty"`
	UserAgent      string  `json:"user_agent,omitempty"`
}

type Disposition

type Disposition struct {
	Action    string `json:"action"`
	Reason    string `json:"reason"`
	RuleLabel string `json:"rule_label"`
}

type Domain

type Domain struct {
	FirstSeen string `json:"first_seen"`
}

type Email

type Email struct {
	Domain       Domain `json:"domain"`
	FirstSeen    string `json:"first_seen"`
	IsDisposable bool   `json:"is_disposable"`
	IsFree       bool   `json:"is_free"`
	IsHighRisk   bool   `json:"is_high_risk"`
}

type EmailData

type EmailData struct {
	Address string `json:"address,omitempty"` // plain text or MD5 hased email address
	Domain  string `json:"domain,omitempty"`
}

type ErrData

type ErrData struct {
	Code  string `json:"code"`
	Error string `json:"error"`
}

type EventData

type EventData struct {
	ShopID        string `json:"shop_id,omitempty"`
	Time          string `json:"time,omitempty"`
	TransactionID string `json:"transaction_id,omitempty"`
	Type          string `json:"type,omitempty"`
}

type FactorsResponse

type FactorsResponse struct {
	BaseResponse
	IPAddress       IPAddress       `json:"ip_address"`
	BillingAddress  BillingAddress  `json:"billing_address"`
	CreditCard      CreditCard      `json:"credit_card"`
	Device          Device          `json:"device"`
	Email           Email           `json:"email"`
	ShippingAddress ShippingAddress `json:"shipping_address"`
	Subscores       Subscores       `json:"subscores"`
}

FactorsResponse has response from Factors API.

func (FactorsResponse) APIResponse

func (r FactorsResponse) APIResponse() APIResponse

type GeoNameID

type GeoNameID int64

ref: https://www.geonames.org/

type IPAddress

type IPAddress struct {
	Risk               float64            `json:"risk"` // from 0.01 to 99
	City               City               `json:"city"`
	Continent          Continent          `json:"continent"`
	Country            Country            `json:"country"`
	Location           Location           `json:"location"`
	Postal             Postal             `json:"postal"`
	RegisteredCountry  RegisteredCountry  `json:"registered_country"`
	RepresentedCountry RepresentedCountry `json:"represented_country"`
	RiskReasons        []RiskReason       `json:"risk_reasons"`
	Subdivisions       []Subdivision      `json:"subdivisions"`
	Traits             Traits             `json:"traits"`
}

type InsightsResponse

type InsightsResponse struct {
	BaseResponse
	IPAddress       IPAddress       `json:"ip_address"`
	BillingAddress  BillingAddress  `json:"billing_address"`
	CreditCard      CreditCard      `json:"credit_card"`
	Device          Device          `json:"device"`
	Email           Email           `json:"email"`
	ShippingAddress ShippingAddress `json:"shipping_address"`
}

InsightsResponse has response from Insights API.

func (InsightsResponse) APIResponse

func (r InsightsResponse) APIResponse() APIResponse

type Issuer

type Issuer struct {
	MatchesProvidedName        bool   `json:"matches_provided_name"`
	MatchesProvidedPhoneNumber bool   `json:"matches_provided_phone_number"`
	Name                       string `json:"name"`
	PhoneNumber                string `json:"phone_number"`
}

type Location

type Location struct {
	AccuracyRadius    int64   `json:"accuracy_radius"` // in Killometers
	AverageIncome     float64 `json:"average_income"`  // in USD
	Latitude          float64 `json:"latitude"`
	LocalTime         string  `json:"local_time"`
	Longitude         float64 `json:"longitude"`
	MetroCode         int64   `json:"metro_code"`
	PopulationDensity int64   `json:"population_density"` // only for US
	TimeZone          string  `json:"time_zone"`
}

type MinFraud

type MinFraud struct {
	// contains filtered or unexported fields
}

MinFraud is service struct for MinFraud API.

func New

func New(conf config.Config) (*MinFraud, error)

New creates MinFraud from Config data.

func (*MinFraud) Factors

func (s *MinFraud) Factors(req BaseRequest) (*FactorsResponse, error)

Factors executes Factors API.

func (*MinFraud) Insights

func (s *MinFraud) Insights(req BaseRequest) (*InsightsResponse, error)

Insights executes Insights API.

func (*MinFraud) InsightsByIP

func (s *MinFraud) InsightsByIP(ipaddr string) (*InsightsResponse, error)

InsightsByIP executes Insights API with only ip address parameter.

func (*MinFraud) Score

func (s *MinFraud) Score(req BaseRequest) (*ScoreResponse, error)

Score executes Score API.

func (*MinFraud) ScoreByIP

func (s *MinFraud) ScoreByIP(ipaddr string) (*ScoreResponse, error)

ScoreByIP executes Score API with only ip address parameter.

func (*MinFraud) SetLogger

func (s *MinFraud) SetLogger(logger log.Logger)

SetLogger sets internal API logger.

type Names

type Names struct {
	DE   string `json:"de"`
	EN   string `json:"en"`
	ES   string `json:"es"`
	FR   string `json:"fr"`
	JA   string `json:"ja"`
	PtBR string `json:"pt-BR"`
	RU   string `json:"ru"`
	ZhCN string `json:"zh-CN"`
}

type OrderData

type OrderData struct {
	AffiliateID    string   `json:"affiliateID,omitempty"`
	Amount         *float64 `json:"amount,omitempty"`
	Currency       string   `json:"currency,omitempty"`
	DiscountCode   string   `json:"discount_code,omitempty"`
	HasGiftMessage *bool    `json:"has_gift_message,omitempty"`
	IsGift         *bool    `json:"is_gift,omitempty"`
	ReferrerURI    string   `json:"referrer_uri,omitempty"`
	SubaffiliateID string   `json:"subaffiliate_id,omitempty"`
}

type PaymentData

type PaymentData struct {
	DeclineCode   string `json:"decline_code,omitempty"`
	Processor     string `json:"processor,omitempty"`
	WasAuthorized *bool  `json:"was_authorized,omitempty"`
}

type Postal

type Postal struct {
	Code       string     `json:"code"`
	Confidence Confidence `json:"confidence"`
}

type RegisteredCountry

type RegisteredCountry struct {
	CountryData
}

type RepresentedCountry

type RepresentedCountry struct {
	CountryData
	Type string `json:"type"`
}

type RiskReason

type RiskReason struct {
	Code   string `json:"code"`
	Reason string `json:"reason"`
}

type ScoreResponse

type ScoreResponse struct {
	BaseResponse
	IPAddress IPAddress `json:"ip_address"`
}

ScoreResponse has response from Score API.

func (ScoreResponse) APIResponse

func (r ScoreResponse) APIResponse() APIResponse

type ShippingAddress

type ShippingAddress struct {
	DistanceToBillingAddress int64   `json:"distance_to_billing_address"`
	DistanceToIPLocation     int64   `json:"distance_to_ip_location"`
	IsHighRisk               bool    `json:"is_high_risk"`
	IsInIPCountry            bool    `json:"is_in_ip_country"`
	IsPostalInCity           bool    `json:"is_postal_in_city"`
	Latitude                 float64 `json:"latitude"`
	Longitude                float64 `json:"longitude"`
}

type ShippingData

type ShippingData struct {
	Address          string `json:"address,omitempty"`
	Address2         string `json:"address_2,omitempty"`
	City             string `json:"city,omitempty"`
	Company          string `json:"company,omitempty"`
	Country          string `json:"country,omitempty"`
	DeliverySpeed    string `json:"delivery_speed,omitempty"`
	FirstName        string `json:"first_name,omitempty"`
	LastName         string `json:"last_name,omitempty"`
	PhoneCountryCode string `json:"phone_country_code,omitempty"`
	PhoneNumber      string `json:"phone_number,omitempty"`
	Postal           string `json:"postal,omitempty"`
	Region           string `json:"region,omitempty"`
}

type ShoppingCartData

type ShoppingCartData struct {
	Category string   `json:"category,omitempty"`
	ItemID   string   `json:"item_id,omitempty"`
	Price    *float64 `json:"price,omitempty"`
	Quantity *int64   `json:"quantity,omitempty"`
}

type Subdivision

type Subdivision struct {
	GeoNameID  GeoNameID  `json:"geoname_id"`
	ISOCode    string     `json:"iso_code"` // ISO 3166-1 alpha-2
	Names      Names      `json:"names"`
	Confidence Confidence `json:"confidence"`
}

type Subscores

type Subscores struct {
	AVSResult                           float64 `json:"avs_result"`
	BillingAddress                      float64 `json:"billing_address"`
	BillingAddressDistanceToIPLocation  float64 `json:"billing_address_distance_to_ip_location"`
	Browser                             float64 `json:"browser"`
	Chargeback                          float64 `json:"chargeback"`
	Country                             float64 `json:"country"`
	CountryMismatch                     float64 `json:"country_mismatch"`
	CVVResult                           float64 `json:"cvv_result"`
	Device                              float64 `json:"device"`
	EmailAddress                        float64 `json:"email_address"`
	EmailDomain                         float64 `json:"email_domain"`
	EmailLocalPart                      float64 `json:"email_local_part"`
	IssuerIDNumber                      float64 `json:"issuer_id_number"`
	OrderAmount                         float64 `json:"order_amount"`
	PhoneNumber                         float64 `json:"phone_number"`
	ShippingAddress                     float64 `json:"shipping_address"`
	ShippingAddressDistanceToIPLocation float64 `json:"shipping_address_distance_to_ip_location"`
	TimeOfDay                           float64 `json:"time_of_day"`
}

type Traits

type Traits struct {
	AutonomousSystemNumber       int64   `json:"autonomous_system_number"`
	AutonomousSystemOrganization string  `json:"autonomous_system_organization"`
	Domain                       string  `json:"domain"`
	IPAddress                    string  `json:"ip_address"`
	IsAnonymous                  bool    `json:"is_anonymous"`
	IsAnonymousVPN               bool    `json:"is_anonymous_vpn"`
	IsHostingProvider            bool    `json:"is_hosting_provider"`
	IsPublicProxy                bool    `json:"is_public_proxy"`
	IsResidentialProxy           bool    `json:"is_residential_proxy"`
	IsTorExitNode                bool    `json:"is_tor_exit_node"`
	ISP                          string  `json:"isp"`
	Network                      string  `json:"network"`
	Organization                 string  `json:"organization"`
	StaticIPScore                float64 `json:"static_ip_score"` // 0 ~ 99.99
	UserCount                    int64   `json:"user_count"`
	UserType                     string  `json:"user_type"`
}

type Warning

type Warning struct {
	Code         string `json:"code"`
	InputPointer string `json:"input_pointer"`
	Warning      string `json:"warning"`
}

Jump to

Keyboard shortcuts

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