WebService::MinFraud::Example - MaxMind minFraud client example
Here is an example using the client to submit a request of transaction data to the minFraud service. You can provide any subset of the $request so long as you provide a $request->{device}{ip_address}. Typically, the more information that you provide, the more confident you can be in the risk score.
$request
$request->{device}{ip_address}
use 5.010; use Data::Dumper; use WebService::MinFraud::Client; my $client = WebService::MinFraud::Client->new( account_id => 42, license_key => 'abcdef123456', ); my $request = { account => { user_id => '3132', username_md5 => '570a90bfbf8c7eab5dc5d4e26832d5b1' }, billing => { address_2 => 'Unit 5', region => 'CT', company => 'Company', phone_country_code => '1', phone_number => '323-123-4321', address => '101 Address Rd.', last_name => 'Last', country => 'US', city => 'City of Thorns', postal => '06510', first_name => 'First' }, credit_card => { bank_phone_country_code => '1', avs_result => 'Y', bank_phone_number => '800-342-1232', last_4_digits => '7643', cvv_result => 'N', bank_name => 'Bank of No Hope', issuer_id_number => '323132' }, custom_inputs => { section => 'news', number_of_previous_purchases => 19, discount => 3.2, previous_user => JSON->true, }, device => { accept_language => 'en-US,en;q=0.8', ip_address => '81.2.69.160', user_agent => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36', }, email => { address => '977577b140bfb7c516e4746204fbdb01', domain => 'maxmind.com' }, event => { shop_id => 's2123', type => 'purchase', transaction_id => 'txn3134133', time => '2014-04-12T23:20:50.052+00:00' }, order => { affiliate_id => 'af12', referrer_uri => 'http://www.amazon.com/', subaffiliate_id => 'saf42', discount_code => 'FIRST', currency => 'USD', amount => 323.21 is_gift => 1, has_gift_message => 0, }, payment => { decline_code => 'invalid number', was_authorized => 0, processor => 'stripe' }, shipping => { city => 'Nowhere', postal => '73003', last_name => 'ShipLast', country => 'US', phone_number => '403-321-2323', delivery_speed => 'same_day', address_2 => 'St. 43', phone_country_code => '1', company => 'ShipCo', address => '322 Ship Addr. Ln.', region => 'OK', first_name => 'ShipFirst' }, shopping_cart => [ { category => 'pets', quantity => 2, price => 20.43, item_id => 'ad23232' }, { category => 'beauty', quantity => 1, price => 100.0, item_id => 'bst112' } ], }; my $score_response = $client->score($request); # say Dumper $score_response; say "Transaction risk score: ", $score_response->risk_score; say "Request id: ",$score_response->id; say "Queries Remaining: ",$score_response->queries_remaining; # output: # Transaction risk score: 5.84 # Request id: 96A5C322-1B86-11E5-A3D3-72F613C364DD # Queries Remaining: 299923 my $insights_response = $client->insights($request); # say Dumper $insights_response; say "Transaction risk score: ", $insights_response->risk_score; say "IP Address risk score: ", $insights_response->ip_address->risk; # output: # Transaction risk score: 5.84 # IP Address risk score: 0.01
To install WebService::MinFraud, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::MinFraud
CPAN shell
perl -MCPAN -e shell install WebService::MinFraud
For more information on module installation, please visit the detailed CPAN module installation guide.