All Projects → maxmind → minfraud-api-java

maxmind / minfraud-api-java

Licence: Apache-2.0 license
Java API for minFraud Score, Insights, and Factors

Programming Languages

java
68154 projects - #9 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to minfraud-api-java

minfraud-api-ruby
Ruby API for minFraud Score, Insights, and Factors
Stars: ✭ 14 (+0%)
Mutual labels:  maxmind, minfraud
minfraud-api-php
PHP API for minFraud Score, Insights, and Factors
Stars: ✭ 41 (+192.86%)
Mutual labels:  maxmind, minfraud
minfraud-api-python
Python API for minFraud Score, Insights, and Factors
Stars: ✭ 22 (+57.14%)
Mutual labels:  maxmind, minfraud
nodejs-geoip2ws
Maxmind GeoIP2 Web Services for Node.js
Stars: ✭ 47 (+235.71%)
Mutual labels:  maxmind
sawmill
Sawmill is a JSON transformation Java library
Stars: ✭ 92 (+557.14%)
Mutual labels:  maxmind
geoip2
GeoIP2 Reader for Go
Stars: ✭ 54 (+285.71%)
Mutual labels:  maxmind
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (+392.86%)
Mutual labels:  maxmind
MaxMind-DB-Reader-java
Java reader for the MaxMind DB format
Stars: ✭ 88 (+528.57%)
Mutual labels:  maxmind
GeoIP2-ruby
Ruby API for GeoIP2 webservice client and database reader
Stars: ✭ 41 (+192.86%)
Mutual labels:  maxmind
WordPress-IP-Geo-Block
A WordPress plugin that will blocks any comment, pingback and trackback spams posted from outside your nation. And it will also protect against malicious access to the login form, admin area and XML-RPC from undesired countries.
Stars: ✭ 26 (+85.71%)
Mutual labels:  maxmind
geoip2-rs
Fast GeoIP2 Reader for Rust
Stars: ✭ 25 (+78.57%)
Mutual labels:  maxmind
lua-resty-maxminddb
A Lua library for reading MaxMind's Geolocation database
Stars: ✭ 72 (+414.29%)
Mutual labels:  maxmind
geoip-country
Less memory usage version of geoip-lite by supporting only country lookup.
Stars: ✭ 50 (+257.14%)
Mutual labels:  maxmind
GeoLite2-City
GeoLite2-City.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 170 (+1114.29%)
Mutual labels:  maxmind
MaxMind-DB-Writer-perl
Create MaxMind DB database files
Stars: ✭ 63 (+350%)
Mutual labels:  maxmind
GeoIP2-perl
Perl API for MaxMind's GeoIP2 web services and databases
Stars: ✭ 18 (+28.57%)
Mutual labels:  maxmind
mmdbwriter
Go library for writing MaxMind DB (mmdb) files
Stars: ✭ 44 (+214.29%)
Mutual labels:  maxmind
Geoip2 Php
PHP API for GeoIP2 webservice client and database reader
Stars: ✭ 1,956 (+13871.43%)
Mutual labels:  maxmind
MaxMind-DB-Reader-ruby
Ruby reader for the MaxMind DB Database Format
Stars: ✭ 35 (+150%)
Mutual labels:  maxmind
ansible
Ansible playbook automation for pfelk
Stars: ✭ 23 (+64.29%)
Mutual labels:  maxmind

MaxMind minFraud Score, Insights, and Factors Java API

Description

This package provides an API for the MaxMind minFraud Score, Insights, Factors and Report Transaction web services.

Installation

Maven

We recommend installing this package with Maven. To do this, add the dependency to your pom.xml:

    <dependency>
        <groupId>com.maxmind.minfraud</groupId>
        <artifactId>minfraud</artifactId>
        <version>2.1.0</version>
    </dependency>

Gradle

Add the following to your build.gradle file:

repositories {
    mavenCentral()
}
dependencies {
    compile 'com.maxmind.minfraud:minfraud:2.1.0'
}

API Documentation

API documentation is viewable on our GitHub Page under the API tab.

Usage

To use this API, first create a new WebServiceClient object. The constructor takes your MaxMind account ID, license key, and an optional options array as arguments. For example:

WebServiceClient client = new WebServiceClient.Builder(6, "ABCD567890").build();

Then create a new Transaction object. This represents the transaction that you are sending to minFraud. The class is instantiated using an inner builder class, Transaction.Builder. Each builder method takes a corresponding request model object. Each of these objects is similarly built up with corresponding builder classes. For example:

Transaction transaction = new Transaction.Builder(
        new Device.Builder(InetAddress.getByName("1.1.1.1")).build()
    ).email(
        new Email.Builder()
            .address("[email protected]")
            .build()
    ).build();

After creating the transaction object, send a Score request by calling the score method:

ScoreResponse score = client.score(transaction);

an Insights request by calling insights method:

InsightsResponse insights = client.insights(transaction);

a Factors request by calling factors method:

FactorsResponse factors = client.factors(transaction);

If the request succeeds, a model object will be returned for the endpoint. If the request fails, an exception will be thrown.

To report a transaction:

TransactionReport transaction = new TransactionReport.Builder(
         InetAddress.getByName("1.1.1.1"), Tag.NOT_FRAUD
     ).build();
client.reportTransaction(transaction);

reportTransaction() has a void return type. If the request fails, an exception will be thrown.

See the API documentation for more details.

Exceptions

Runtime exceptions:

  • IllegalArgumentException - This will be thrown when an illegal argument is passed to a builder method. For instance, a country code that is not two capital letters.

Checked exceptions:

  • AuthenticationException - This will be thrown when the server is unable to authenticate the request, e.g., if the license key or account ID is invalid.
  • InsufficientFundsException - This will be thrown when your account is out of funds.
  • InvalidRequestException - This will be thrown when the server rejects the request for another reason such as invalid JSON in the POST.
  • PermissionRequiredException - This will be thrown when permission is required to use the service.
  • MinFraudException - This will be thrown when the server returns an unexpected response. This also serves as the base class for the above checked exceptions.
  • HttpException -This will be thrown when an unexpected HTTP error occurs such as an internal server error or other unexpected status code.

Examples

Insights

Transaction request = new Transaction.Builder(
        new Device.Builder(InetAddress.getByName("1.1.1.1"))
            .acceptLanguage("en-US")
            .sessionAge(3600.6)
            .sessionId("foobar")
            .userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36")
            .build()
    ).account(
        new Account.Builder()
            .userId("usr-123")
            .username("fraudster9")
            .build()
    ).billing(
        new Billing.Builder()
            .address("11 Wall St.")
            .address2("Apt 1")
            .city("New Haven")
            .company("Company, Inc")
            .firstName("Mike")
            .lastName("Smith")
            .phoneCountryCode("1")
            .phoneNumber("321-321-3211")
            .postal("06510")
            .region("CT")
            .build()
    ).creditCard(
        new CreditCard.Builder()
            .avsResult('N')
            .bankName("BanK of New Haven")
            .bankPhoneCountryCode("1")
            .bankPhoneNumber("313-231-3213")
            .cvvResult('Y')
            .issuerIdNumber("213312")
            .lastDigits("3211")
            .was3dSecureSuccessful(true)
            .build()
    ).email(
        new Email.Builder()
            .address("[email protected]")
            .domain("ster.com")
            .build()
    ).event(
        new Event.Builder()
            .shopId("2432")
            .time(new Date())
            .transactionId("tr1242")
            .type(Event.Type.ACCOUNT_CREATION)
            .build()
    ).order(
        new Order.Builder()
            .affiliateId("af5")
            .amount(new BigDecimal(Double.toString(1.1)))
            .currency("USD")
            .discountCode("10OFF")
            .referrerUri(new URI("https://www.google.com/"))
            .subaffiliateId("saf9")
            .build()
    ).payment(
        new Payment.Builder()
            .declineCode("invalid")
            .processor(Payment.Processor.ADYEN)
            .wasAuthorized(false)
            .build()
    ).shipping(
        new Shipping.Builder()
            .region("MN")
            .postal("55455")
            .phoneNumber("313-545-3113")
            .phoneCountryCode("1")
            .deliverySpeed(Shipping.DeliverySpeed.EXPEDITED)
            .address("32 Washington Ave.")
            .address2("18")
            .city("Minneapolis")
            .company("MinnCo")
            .firstName("John")
            .lastName("Doe")
            .build()
    ).addShoppingCartItem(
        new ShoppingCartItem.Builder()
            .category("TOYS")
            .itemId("t-132")
            .price(1.1)
            .quantity(100)
            .build()
    ).addShoppingCartItem(
        new ShoppingCartItem.Builder()
            .category("COSMETICS")
            .itemId("c-12312")
            .price(3.)
            .quantity(1)
            .build()
    ).customInputs(
        new CustomInputs.Builder()
            .put("float_input", 12.1)
            .put("integer_input", 3123)
            .put("string_input", "This is a string input.")
            .put("boolean_input", true)
            .build()
    ).build();

WebServiceClient client = new WebServiceClient.Builder(6, "ABCD567890").build();

System.out.println(client.insights(request));

Report Transactions API

MaxMind encourages the use of this API, as data received through this channel is continually used to improve the accuracy of our fraud detection algorithms.

To use the Report Transactions API, create a new TransactionReport object. An IP address and a valid tag are required arguments. Additional params may also be set, as documented below.

If the report is successful, nothing is returned. If the report fails, an exception with be thrown.

See the API documentation for more details.

TransactionReport transaction = new TransactionReport.Builder(InetAddress.getByName("1.1.1.1"), Tag.NOT_FRAUD)
    .chargebackCode("mycode")
    .maxmindId("12345678")
    .minfraudId(UUID.fromString("58fa38d8-4b87-458b-a22b-f00eda1aa20d"))
    .notes("notes go here")
    .transactionId("foo")
    .build();

WebServiceClient client = new WebServiceClient.Builder(6, "ABCD567890").build();

client.reportTransaction(transaction);

Support

Please report all issues with this code using the GitHub issue tracker.

If you are having an issue with the minFraud service that is not specific to the client API, please see our support page.

Requirements

This code requires Java 11+.

Contributing

Patches and pull requests are encouraged. Please include unit tests whenever possible.

Versioning

This API uses Semantic Versioning.

Copyright and License

This software is Copyright (c) 2015-2022 by MaxMind, Inc.

This is free software, licensed under the Apache License, Version 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].