1 package Business::FraudDetect::preCharge;
5 use vars qw($VERSION @ISA);
6 use Business::OnlinePayment::HTTPS;
8 @ISA = qw( Business::OnlinePayment::HTTPS );
12 sub _glean_parameters_from_parent {
13 my ($self, $parent) = @_;
14 foreach my $method (qw / precharge_id precharge_security1 precharge_security2 /) {
15 $self->$method($parent->$method);
21 $self->server('api.precharge.net');
23 $self->path('/charge');
24 $self->build_subs(qw /currency fraud_score error_code
25 precharge_id precharge_security1 precharge_security2 force_success fraud_transaction_id / );
26 $self->currency('USD');
32 if ($self->force_success()) {
34 $self->result_code('1');
35 $self->error_message('No Error. Force success path');
38 my %content = $self->content();
39 Carp::croak("Action: $content{action} not supported.") unless
40 lc($content{action}) eq 'fraud detect';
42 $self->required_fields(qw(
43 amount card_number expiration
44 first_name last_name state zip country phone email
48 $self->remap_fields( qw/
49 ip_address ecom_billto_online_ip
50 zip ecom_billto_postal_postalcode
51 phone ecom_billto_telecom_phone_number
52 first_name ecom_billto_postal_name_first
53 last_name ecom_billto_postal_name_last
54 email ecom_billto_online_email
55 country ecom_billto_postal_countrycode
56 card_number ecom_payment_card_number
57 amount ecom_transaction_amount
62 my %post_data = $self->get_fields(qw(
63 ecom_billto_online_ip ecom_billto_postal_postalcode
64 ecom_billto_telecom_phone_number ecom_billto_online_email
65 ecom_transaction_amount currency
66 ecom_billto_postal_name_first ecom_billto_postal_name_last
67 ecom_billto_postal_countrycode
68 ecom_payment_card_number
71 # set up some reasonable defaults
74 # split out MM/YY from exp date
77 @post_data{ qw/ ecom_payment_card_expdate_month
78 ecom_payment_card_expdate_year
80 } = split(/\//,$content{expiration});
82 @post_data{qw/merchant_id security_1 security_2/} = (
84 $self->precharge_security1,
85 $self->precharge_security2
88 if ($self->test_transaction()) {
91 my ($page, $response, %headers) = $self->https_post(\%post_data);
93 $self->server_response($page);
95 my @details = split ',',$page;
97 my %error_map = ( 101 => 'Invalid Request Method',
98 102 => 'Invalid Request URL',
99 103 => 'Invalid Security Code(s)',
100 104 => 'Merchant Status not Verified',
101 105 => 'Merchant Feed is Disabled',
102 106 => 'Invalid Request Type',
103 107 => 'Missing IP Address',
104 108 => 'Invalid IP Address Syntax',
105 109 => 'Missing First Name',
106 110 => 'Invalid First Name',
107 111 => 'Missing Last Name',
108 112 => 'Invalid Last Name',
109 113 => 'Invalid Address 1',
110 114 => 'Invalid Address 2',
111 115 => 'Invalid City',
112 116 => 'Invalid State',
113 117 => 'Invalid Country',
114 118 => 'Missing Postal Code',
115 119 => 'Invalid Postal Code',
116 120 => 'Missing Phone Number',
117 121 => 'Invalid Phone Number',
118 122 => 'Missing Expiration Month',
119 123 => 'Invalid Expiration Month',
120 124 => 'Missing Expiration Year',
121 125 => 'Invalid Expiration Year',
122 126 => 'Expired Credit Card',
123 127 => 'Missing Credit Card Number',
124 128 => 'Invalid Credit Card Number',
125 129 => 'Missing Email Address',
126 130 => 'Invlaid Email Syntax',
127 131 => 'Duplicate Transaction',
128 132 => 'Invlaid Transaction Amount',
129 133 => 'Invalid Currency',
130 998 => 'Unknown Error',
131 999 => 'Service Unavailable',
132 1001 => 'No detail returned',
136 my %output = ( error => 1001 );
138 foreach my $detail (@details) {
139 my ($k, $v) = split('=', $detail);
143 if ($output{response} == 1 ) {
144 $self->is_success(1);
145 $self->fraud_score($output{score});
146 $self->result_code($output{response});
147 $self->fraud_transaction_id($output{transaction});
148 $self->error_message('No Error. Risk assesment transaction successful');
150 $self->is_success(0);
151 $self->fraud_score($output{score});
152 $self->result_code($output{error});
153 $self->error_message( exists( $error_map{$output{error}} )
154 ? $error_map{$output{error}}
155 : "preCharge error $output{error} occurred."
168 Business::FraudDetect::preCharge - backend for Business::FraudDetect (part of Business::OnlinePayment)
172 use Business::OnlinePayment
173 my $tx = new Business::OnlinePayment ( 'someGateway',
174 fraud_detect => 'preCharge',
175 maximum_fraud_score => 500,
176 preCharge_id => '1000000000000001',
177 preCharge_security1 => 'abcdef0123',
178 preCharge_security2 => '3210fedcba',
181 first_name => 'Larry Walton',
182 last_name => 'Sanders',
183 login => 'testdrive',
185 action => 'Normal Authorization',
190 phone => '617 555 8900',
191 email => 'lws@sanders.com',
192 ip_address => '18.62.0.6',
193 card_number => '4111111111111111',
194 expiration => '0307',
198 if ($tx->is_success()) {
200 my $score = $tx->fraud_score;
201 my $id = $tx->fraud_transaction_id;
202 #returns the preCharge transaction id
205 my $score = $tx->fraud_score;
210 This module provides a driver for the preCharge Risk Management Solutions API Verison 1.7 (16 Jan 2006).
212 See L<Business::OnlinePayment> and L<Business::FraudDetect> for more information.
217 Whe constructing the Business::OnlinePayment object, three risk management parameters must be included for the preCharge object to be properly constructed.
223 This field is called "merchant_id" in the preCharge API manual
226 =item * precharge_security1
228 This field is called "security_1" in the preCharge API manual
230 =item * precharge_secuirty2
232 This field is called "security_2" in the preCharge API manual
239 This module provides no public methods.
243 Lawrence Statton <lawrence@cluon.com>
245 Jason Hall <jayce@lug-nut.com>
249 THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
253 http://420.am/business-onlinepayment