1 package Business::OnlinePayment::Network1Financial;
5 use Business::OnlinePayment;
6 #use Business::CreditCard;
7 use Net::SSLeay qw( make_form post_https make_headers );
9 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
13 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
21 # 000000 => 'INTERNAL SERVER ERROR',
22 # 000001 => 'INTERNAL SERVER ERROR',
23 # 000002 => 'INTERNAL SERVER ERROR',
24 # 900000 => 'INVALID T_ORDERNUM',
25 # 900001 => 'INVALID C_NAME',
26 # 900002 => 'INVALID C_ADDRESS',
27 # 900003 => 'INVALID C_CITY',
28 # 900004 => 'INVALID C_STATE',
29 # 900005 => 'INVALID C_ZIP',
30 # 900006 => 'INVALID C_COUNTRY',
31 # 900007 => 'INVALID C_TELEPHONE',
32 # 900008 => 'INVALID C_FAX',
33 # 900009 => 'INVALID C_EMAIL',
34 # 900010 => 'INVALID C_SHIP_NAME',
35 # 900011 => 'INVALID C_SHIP_ADDRESS',
36 # 900012 => 'INVALID C_SHIP_CITY',
37 # 900013 => 'INVALID C_SHIP_STATE',
38 # 900014 => 'INVALID C_SHIP_ZIP',
39 # 900015 => 'INVALID C_SHIP_COUNTRY',
40 # 900016 => 'INVALID C_CARDNUMBER',
41 # 900017 => 'INVALID C_EXP',
42 # 900018 => 'INVALID C_CVV',
43 # 900019 => 'INVALID T_AMT',
44 # 900020 => 'INVALID T_CODE',
45 # 900021 => 'INVALID T_AUTH',
46 # 900022 => 'INVALID T_REFERENCE',
47 # 900023 => 'INVALID T_TRACKDATA',
48 # 900024 => 'INVALID T_TRACKING_NUMBER',
49 # 900025 => 'INVALID T_CUSTOMER_NUMBER',
50 # 910000 => 'SERVICE NOT ALLOWED',
51 # 910001 => 'VISA NOT ALLOWED',
52 # 910002 => 'MASTERCARD NOT ALLOWED',
53 # 910003 => 'AMEX NOT ALLOWED',
54 # 910004 => 'DISCOVER NOT ALLOWED',
55 # 910005 => 'CARD TYPE NOT ALLOWED',
56 # 911911 => 'SECURITY VIOLATION',
57 # 920000 => 'ITEM NOT FOUND',
58 # 920001 => 'CREDIT VOL EXCEEDED',
59 # 920002 => 'AVS FAILURE',
60 # 999999 => 'INTERNAL SERVER ERROR',
65 $self->server('va.eftsecure.net');
67 #$self->path('/cgi-bin/eftBankcard.dll?transaction');
68 #$self->build_subs(qw( product_id merchant_id ));
73 my %content = $self->content();
76 my %actions = ( 'normal authorization' => '01',
77 'authorization only' => '02',
79 'post authorization' => '03',
81 $content{'action'} = $actions{lc($content{'action'})} || $content{'action'};
84 my %types = ('visa' => 'BankCard',
85 'mastercard' => 'BankCard',
86 'american express' => 'BankCard',
87 'discover' => 'BankCard',
89 'check' => 'VirtualCheck',
91 $content{'type'} = $types{lc($content{'type'})} || $content{'type'};
92 $self->transaction_type($content{'type'});
94 # stuff it back into %content
95 $self->content(%content);
100 my %content = $self->content();
102 $content{$_} = ref($map{$_})
104 : $content{$map{$_}};
106 $self->content(%content);
112 my %content = $self->content();
114 my $action = lc($content{'action'});
115 if ( $action eq '01' ) {
117 croak "$action not (yet) supported";
120 my $type = $content{'type'};
121 if ( $type eq 'BankCard' ) {
123 croak "$type not (yet) supported";
126 ( my $exp = $content{'expiration'} ) =~ s/\///;
128 $self->revmap_fields(
130 'M_key' => 'password',
132 'C_address' => 'address',
134 'C_state' => 'state',
136 'C_country' => 'country',
137 'C_email' => 'email',
138 'C_cardnumber' => 'card_number',
141 'T_code' => 'action',
142 #'T_ordernum' => 'invoice_number', #probably not unique...
146 'T_customer_number' => 'customer_id',
155 'C_telephone' => 'phone',
159 my %post_data = $self->get_fields(qw(
160 M_id M_key C_name C_address C_city C_state C_zip C_country C_email
161 C_cardnumber C_exp T_amt T_code
162 C_cvv T_customer_number
165 #T_ordernum T_auth T_trackdata
166 #T_tax T_shipping C_ship_name C_ship_address C_ship_city C_ship_state
167 #C_ship_zip C_ship_country
170 my $pd = make_form(%post_data);
171 my $s = $self->server();
172 my $p = $self->port();
173 my $t = "/cgi-bin/eft$type.dll?transaction";
174 my($page,$server_response,%headers) = post_https($s,$p,$t,'',$pd);
176 my $approved = substr($page,1, 1); #A is approved E is declined/error.
177 my $result_code = substr($page, 2, 6);
178 my $error_message = substr($page, 8, 32);
179 #print "Front-End Indicator: " . substr($page, 40, 2);
180 #print "CVV Indicator: " . substr($page, 42, 1);
181 #print "AVS Indicator: " . substr($page, 43, 1);
182 #print "Risk Indicator: " . substr($page, 44, 2);
183 my $reference = substr($page, 46, 10);
184 #print "Order Number: " . substr($page, index($page, chr(28)) + 1,
185 # rindex($page, chr(28)) - index($page, chr(28)) - 1);
187 if ( $approved eq 'A' ) {
188 $self->is_success(1);
189 $self->result_code($result_code);
190 $self->error_message($error_message);
191 $self->authorization($reference);
193 $self->is_success(0);
194 $self->result_code($result_code);
195 $self->error_message($error_message);
205 Business::OnlinePayment::Network1Financial - Network1 Financial backend for Business::OnlinePayment
209 use Business::OnlinePayment;
211 my $tx = new Business::OnlinePayment("Network1Financial");
214 login => 'test', #12 Digit ID Number
215 password => 'test', #12 Digit Security Key
216 action => 'Normal Authorization',
217 description => 'Business::OnlinePayment test',
219 invoice_number => '100100',
220 name => 'Tofu Beast',
221 card_number => '4007000000027',
222 expiration => '09/02',
226 if($tx->is_success()) {
227 print "Card processed successfully: ".$tx->authorization."\n";
229 print "Card was rejected: ".$tx->error_message."\n";
234 For detailed information see L<Business::OnlinePayment>.
238 This module only implements credit card trasactions at this time. Electronic
239 check (ACH) transactions are not (yet) supported.
243 This module implements the interface documented at
244 https://va.eftsecure.net/VirtualTerminal/Documentation/
248 Ivan Kohler <ivan-network1financial@420.am>
252 perl(1). L<Business::OnlinePayment>