2 package Business::FraudDetect::preCharge;
6 use vars qw($VERSION @ISA);
9 use Business::OnlinePayment::HTTPS;
10 @ISA = qw / Business::OnlinePayment::HTTPS /;
14 sub _glean_parameters_from_parent {
15 my ($self, $parent) = @_;
16 foreach my $method (qw / precharge_id precharge_security1 precharge_security2 /) {
17 $self->$method($parent->$method);
23 $self->server('api.precharge.net');
25 $self->path('/charge');
26 $self->build_subs(qw /currency fraud_score error_code
27 precharge_id precharge_security1 precharge_security2 force_success / );
28 $self->currency('USD');
34 if ($self->force_success()) {
36 $self->result_code('1');
37 $self->error_message('No Error. Force success path');
40 my %content = $self->content();
41 Carp::croak("Action: $content{action} not supported.") unless
42 lc($content{action}) eq 'fraud detect';
44 $self->required_fields(qw(
45 amount card_number expiration
46 first_name last_name state zip country phone email
50 $self->remap_fields( qw /
51 ip_address ecom_billto_online_ip
52 zip ecom_billto_postal_code
53 phone ecom_billto_telecom_phone_number
54 first_name ecom_billto_postal_name_first
55 last_name ecom_billto_postal_name_last
56 email ecom_billto_online_email
57 amount ecom_transaction_amount /
61 my %post_data = $self->get_fields(qw ( ecom_billto_online_ip ecom_billto_postal_code
62 ecom_billto_telecom_phone_number ecom_billto_online_email
63 ecom_transaction_amount currency
66 # set up some reasonable defaults
69 # split out MM/YY from exp date
72 @post_data{qw/ecom_payment_card_expdate_month ecom_payment_card_expdate_year/} = $content{expiration} =~ m/(\d{1,2})(\d{2})/;
73 @post_data{qw/merchant_id security_1 security_2/} = ($self->precharge_id,
74 $self->precharge_security1,
75 $self->precharge_security2);
77 if ($self->test_transaction()) {
81 # warn Dumper \%post_data;
82 my ($page, $response, %headers) = $self->https_post(\%post_data);
84 $self->server_response($page);
86 my @details = split ',',$page;
88 my %error_map = ( 101 => 'Invalid Request Method',
89 102 => 'Invalid Request URL',
90 103 => 'Invalid Security Code(s)',
91 104 => 'Merchant Status not Verified',
92 105 => 'Merchant Feed is Disabled',
93 106 => 'Invalid Request Type',
94 107 => 'Missing IP Address',
95 108 => 'Invalid IP Address Syntax',
96 109 => 'Missing First Name',
97 110 => 'Invalid First Name',
98 111 => 'Missing Last Name',
99 112 => 'Invalid Last Name',
100 113 => 'Invalid Address 1',
101 114 => 'Invalid Address 2',
102 115 => 'Invalid City',
103 116 => 'Invalid State',
104 117 => 'Invalid Country',
105 118 => 'Missing Postal Code',
106 119 => 'Invalid Postal Code',
107 120 => 'Missing Phone Number',
108 121 => 'Invalid Phone Number',
109 122 => 'Missing Expiration Month',
110 123 => 'Invalid Expiration Month',
111 124 => 'Missing Expiration Year',
112 125 => 'Invalid Expiration Year',
113 126 => 'Expired Credit Card',
114 127 => 'Missing Credit Card Number',
115 128 => 'Invalid Credit Card Number',
116 129 => 'Missing Email Address',
117 130 => 'Invlaid Email Syntax',
118 131 => 'Duplicate Transaction',
119 132 => 'Invlaid Transaction Amount',
120 133 => 'Invalid Currency',
121 998 => 'Unknown Error',
122 999 => 'Service Unavailable',
123 1001 => 'No detail returned',
127 my %output = ( error => 1001 );
129 foreach my $detail (@details) {
130 my ($k, $v) = split('=', $detail);
134 if ($output{response} == 1 ) {
135 $self->is_success(1);
136 $self->fraud_score($output{score});
137 $self->result_code($output{response});
138 $self->error_message('No Error. Risk assesment transaction successful');
140 $self->is_success(0);
141 $self->result_code($output{error});
142 $self->error_message(exists $error_map{$output{error}} ? $error_map{$output{error}} : "preCharge error $output{error} occurred.");
157 Business::FraudDetect::preCharge - backend for Business::FraudDetect (part of Business::OnlinePayment)
161 use Business::OnlinePayment
162 my $tx = new Business::OnlinePayment ( 'someGateway',
163 fruad_detection => 'preCharge',
164 maximum_fraud_score => 500,
165 preCharge_id => '1000000000000001',
166 preCharge_security1 => 'abcdef0123',
167 preCharge_security2 => '3210fedcba',
170 first_name => 'Larry Walton',
171 last_name => 'Sanders',
172 login => 'testdrive',
174 action => 'Normal Authorization',
179 phone => '617 555 8900',
180 email => 'lws@sanders.com',
181 ip_address => '18.62.0.6',
182 card_number => '4111111111111111',
183 expiration => '0307',
187 if ($tx->is_success()) {
195 This module provides a driver for the preCharge Risk Management Solutions API Verison 1.7 (16 Jan 2006).
197 See L<Business::OnlinePayment> and L<Business::FraudDetect> for more information.
202 Whe constructing the Business::OnlinePayment object, three risk management parameters must be included for the preCharge object to be properly constructed.
208 This field is called "merchant_id" in the preCharge API manual
211 =item * precharge_security1
213 This field is called "security_1" in the preCharge API manual
215 =item * precharge_secuirty2
217 This field is called "security_2" in the preCharge API manual
224 This module provides no public methods.
228 Lawrence Statton <lawrence@cluon.com>
232 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.
236 http://420.am/business-onlinepayment