0.03
[Business-OnlinePayment-OpenECHO.git] / OpenECHO.pm
1 ##############################################################################\r
2 # Business::OnlinePayment::OpenECHO\r
3 #\r
4 # Credit card transactions via SSL to\r
5 # Electronic Clearing House (ECHO) Systems\r
6 #\r
7 # Refer to ECHO's documentation for more info\r
8 # http://www.openecho.com/echo_gateway_guide.html\r
9 #\r
10 # AUTHOR\r
11 # Michael Lehmkuhl <michael@electricpulp.com>\r
12 #\r
13 # SPECIAL THANKS\r
14 # Jim Darden <jdarden@echo-inc.com>\r
15 # Dan Browning <db@kavod.com>\r
16 #\r
17 # BUSINESS::ONLINEPAYMENT IMPLEMENTATION\r
18 # Ivan Kohler <ivan-openecho@420.am>\r
19 #\r
20 # VERSION HISTORY\r
21 # + v1.2        08/17/2002 Corrected problem with certain string comparisons.\r
22 # + v1.3        08/23/2002 Converted Interchange GlobalSub to Vend::Payment module.\r
23 # + v1.3.1      11/12/2002 Updated the OpenECHO_example.perl test script.\r
24 # + v1.4        11/18/2002 Corrected a problem with Submit method when using LWP.\r
25 # + v1.5        03/29/2003 Updated for additional status and avs_result codes.\r
26 # + v1.6        08/26/2003 Cleaned up code (salim qadeer sqadeer@echo-inc.com)\r
27 # + v1.6.2      09/23/2003 Added DH transaction type (salim qadeer sqadeer@echo-inc.com)\r
28 # --------\r
29 # + v0.1        08/26/2004 Business::OnlinePayment implementation\r
30 # + v0.2        09/13/2004\r
31 # + v0.3        unreleased\r
32 #\r
33 # Copyright (C) 2002 Electric Pulp. <info@electricpulp.com>\r
34 # Copyright (C) 2004 Ivan Kohler\r
35 #\r
36 # This program is free software; you can redistribute it and/or modify\r
37 # it under the terms of the GNU General Public License as published by\r
38 # the Free Software Foundation; either version 2 of the License, or\r
39 # (at your option) any later version.\r
40 #\r
41 # This program is distributed in the hope that it will be useful,\r
42 # but WITHOUT ANY WARRANTY; without even the implied warranty of\r
43 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
44 # GNU General Public License for more details.\r
45 #\r
46 # You should have received a copy of the GNU General Public\r
47 # License along with this program; if not, write to the Free\r
48 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,\r
49 # MA  02111-1307  USA.\r
50 #\r
51 ################################################################################\r
52 \r
53 package Business::OnlinePayment::OpenECHO;\r
54 \r
55 use strict;\r
56 use Carp;\r
57 use Business::OnlinePayment 3;\r
58 use Business::OnlinePayment::HTTPS;\r
59 use vars qw($VERSION @ISA);\r
60 \r
61 @ISA = qw(Business::OnlinePayment::HTTPS);\r
62 $VERSION = '0.03';\r
63 \r
64 sub set_defaults {\r
65         my $self = shift;\r
66 \r
67         $self->server('wwws.echo-inc.com');\r
68         $self->port('443');\r
69         $self->path('/scripts/INR200.EXE');\r
70 \r
71         $self->build_subs(qw(\r
72           order_number avs_code\r
73                          ));\r
74         # order_type\r
75         # md5 cvv2_response cavv_response\r
76 \r
77 }\r
78 \r
79 #map_fileds originally from AuthorizeNet.pm\r
80 \r
81 sub map_fields {\r
82     my($self) = @_;\r
83 \r
84     ##AD (Address Verification)  - 0.18 cents\r
85     #AS (Authorization) - 0.18 cents\r
86     #AV (Authorization with Address Verification) - 0.18 cents\r
87     #CR (Credit) - 0.18 cents + 0.12 cents (discount fee returned to merchant)\r
88     #DS (Deposit) - 0.18 cents + 0.12 cents\r
89     #ES (Authorization and Deposit) - 0.18 cents + 0.12 cents + an extra 0.17%\r
90     #EV (Authorization and Deposit with Address Verification) - 0.18 cents + 0.12 cents\r
91     ##CK (System check) - 0.18 cents\r
92     #DV (Electronic Check Verification) - check your contract\r
93     #DD (Electronic Check Debit with Verification) - check your contract\r
94     #DH (Electronic Check Debit ACH Only) - check your contract\r
95     #DC (Electronic Check Credit) - check your contract\r
96 \r
97     my %content = $self->content();\r
98 \r
99     my $avs = $self->require_avs;\r
100     $avs = 1 unless defined($avs) && length($avs); #default AVS on unless explicitly turned off\r
101 \r
102     my %map;\r
103     if (\r
104       $content{'type'} =~ /^(cc|visa|mastercard|american express|discover)$/i\r
105     ) {\r
106       if ( $avs ) {\r
107         %map = ( 'normal authorization' => 'EV',\r
108                  'authorization only'   => 'AV',\r
109                  'credit'               => 'CR',\r
110                  'post authorization'   => 'DS',\r
111                  #'void'                 => 'VOID',\r
112                );\r
113       } else {\r
114         %map = ( 'normal authorization' => 'ES',\r
115                  'authorization only'   => 'AS',\r
116                  'credit'               => 'CR',\r
117                  'post authorization'   => 'DS',\r
118                  #'void'                 => 'VOID',\r
119                );\r
120       }\r
121     } elsif ( $content{'type'} =~ /^check$/i ) {\r
122       %map = ( 'normal authorization' => 'DD',\r
123                'authorization only'   => 'DV',\r
124                'credit'               => 'DC',\r
125                'post authorization'   => 'DH',\r
126                #'void'                 => 'VOID',\r
127              );\r
128     } else {\r
129       croak 'Unknown type: '. $content{'type'};\r
130     }\r
131 \r
132     $content{'type'} = $map{lc($content{'action'})}\r
133       or croak 'Unknown action: '. $content{'action'};\r
134 \r
135     $self->transaction_type($content{'type'});\r
136 \r
137     # stuff it back into %content\r
138     $self->content(%content);\r
139 \r
140 }\r
141 \r
142 sub submit {\r
143     my($self) = @_;\r
144 \r
145     $self->map_fields();\r
146     $self->remap_fields(\r
147         #                => 'order_type',\r
148         type             => 'transaction_type',\r
149         #action          =>\r
150         login            => 'merchant_echo_id',\r
151         password         => 'merchant_pin',\r
152         #                => 'isp_echo_id',\r
153         #                => 'isp_pin',\r
154         #transaction_key =>\r
155         authorization    => 'authorization', # auth_code => 'authorization',\r
156         customer_ip      => 'billing_ip_address',\r
157         #                   'billing_prefix',\r
158         name             => 'billing_name',\r
159         first_name       => 'billing_first_name',\r
160         last_name        => 'billing_last_name',\r
161         company          => 'billing_company_name',\r
162         address          => 'billing_address_1',\r
163         #                => 'billing_address_2',\r
164         city             => 'billing_city',\r
165         state            => 'billing_state',\r
166         zip              => 'billing_zip',\r
167         country          => 'billing_country',\r
168         phone            => 'billing_phone',\r
169         fax              => 'billing_fax',\r
170         email            => 'billing_email',\r
171         card_number      => 'cc_number',\r
172         #                => 'ccexp_month',\r
173         #                => 'ccexp_year',\r
174         #                => 'counter',\r
175         #                => 'debug',\r
176 \r
177         #XXX#            => 'ec_*',\r
178 \r
179         'amount'         => 'grand_total',\r
180         #                => 'merchant_email',\r
181         #invoice_number  =>\r
182         customer_id      => 'merchant_trace_nbr',\r
183         #                => 'original_amount',\r
184         #                => 'original_trandate_mm',\r
185         #                => 'original_trandate_dd',\r
186         #                => 'original_trandate_yyyy',\r
187         #                => 'original_reference',\r
188         order_number     => 'order_number',\r
189         #                => 'shipping_flag',\r
190 \r
191         #description       =>\r
192         #currency          =>\r
193 \r
194         #ship_last_name    =>\r
195         #ship_first_name   =>\r
196         #ship_company      =>\r
197         #ship_address      =>\r
198         #ship_city         =>\r
199         #ship_state        =>\r
200         #ship_zip          =>\r
201         #ship_country      =>\r
202 \r
203         #expiration        =>\r
204         cvv2              => 'cnp_security',\r
205 \r
206         #check_type        =>\r
207         #account_name      => 'ec_last_name' & 'ec_first_name',\r
208         account_number    => 'ec_account',\r
209         #account_type      =>\r
210         bank_name         => 'ec_bank_name',\r
211         routing_code      => 'ec_rt',\r
212         #customer_org      =>\r
213         #customer_ssn      =>\r
214         license_num       => 'ec_id_number',\r
215         license_state     => 'ec_id_state',\r
216         #license_dob       =>\r
217 \r
218         #recurring_billing => 'cnp_recurring',\r
219     );\r
220 \r
221     #XXX hosted order_type?\r
222     $self->{_content}{order_type} = 'S';\r
223 \r
224     #XXX counter field shouldn't be just a random integer (but it does need a\r
225     #default this way i guess...\r
226     $self->{_content}{counter} = int(rand(2**31));\r
227 \r
228     #ccexp_month & ccexp_year\r
229     $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/\r
230       or croak "unparsable expiration ". $self->{_content}{expiration};\r
231     my( $month, $year ) = ( $1, $2 );\r
232     $month = '0'. $month if $month =~ /^\d$/;\r
233     $self->{_content}{ccexp_month} = $month;\r
234     $self->{_content}{ccexp_year} = $year;\r
235 \r
236     $self->{_content}{cnp_recurring} = 'Y'\r
237       if exists($self->{_content}{recurring_billing})\r
238       && $self->{_content}{recurring_billing} =~ /^y/i;\r
239 \r
240     #XXX echeck use customer_org and account_type to generate ec_account_type\r
241 \r
242     #XXX set required fields\r
243     # https://wwws.echo-inc.com/ISPGuide-Fields2.asp\r
244     $self->required_fields();\r
245 \r
246     my( $page, $response, %reply_headers) =\r
247       $self->https_get( $self->get_fields( $self->fields ) );\r
248 \r
249     #XXX check $response and die if not 200?\r
250 \r
251     my $echotype1 = $self->GetEchoReturn($page, 1);\r
252     my $echotype2 = $self->GetEchoReturn($page, 2);\r
253     my $echotype3 = $self->GetEchoReturn($page, 3);\r
254     my $openecho  = $self->GetEchoReturn($page, 'OPEN');\r
255 \r
256     #   server_response\r
257     #   avs_code\r
258     #   order_number\r
259     #   is_success\r
260     #   result_code\r
261     #   authorization\r
262     #md5 cvv2_response cavv_response ...?\r
263 \r
264     # Get all the metadata.\r
265     $self->server_response($page);\r
266     $self->authorization( $self->GetEchoProp($echotype3, 'auth_code') );\r
267     $self->order_number(  $self->GetEchoProp($echotype3, 'order_number') );\r
268 \r
269     #XXX ???\r
270     #$self->reference(     $this->GetEchoProp($echotype3, "echo_reference");\r
271 \r
272     $self->result_code(   $self->GetEchoProp($echotype3, 'status') );\r
273     $self->avs_code(      $self->GetEchoProp($echotype3, 'avs_result') );\r
274 \r
275     #XXX ???\r
276     #$self->security_result( $self->GetEchoProp($echotype3, 'security_result');\r
277     #$self->mac( $self->GetEchoProp($echotype3, 'mac') );\r
278     #$self->decline_code( $self->GetEchoProp($echotype3, 'decline_code') );\r
279 \r
280     if ($self->result_code =~ /^[GR]$/ ) { #success\r
281 \r
282       #XXX special case for AVS-only transactions we don't handle yet\r
283       #if ($self->transaction_type eq "AD") {\r
284       #  if ($self->avs_code =~ /^[XYDM]$/ ) {\r
285       #    $self->is_success(1);\r
286       #  } else {\r
287       #    $self->is_success(0);\r
288       #  }\r
289       #} else { \r
290         $self->is_success(1);\r
291       #}\r
292 \r
293     } else {\r
294       $self->is_success(0);\r
295 \r
296       my $decline_code = $self->GetEchoProp($echotype3, 'decline_code');\r
297       my $error_message = $self->error($decline_code);\r
298       if ( $decline_code =~ /^(00)?30$/ ) {\r
299         $echotype2 =~ s/<br>/\n/ig;\r
300         $echotype2 =~ s'</?(b|pre)>''ig;\r
301         $error_message .= ": $echotype2";\r
302       }\r
303       $self->error_message( $error_message );\r
304 \r
305     }\r
306 \r
307     $self->is_success(0) if $page eq '';\r
308 \r
309 }\r
310 \r
311 \r
312 sub fields {\r
313         my $self = shift;\r
314 \r
315         my @fields = qw(\r
316           order_type\r
317           transaction_type\r
318           merchant_echo_id\r
319           merchant_pin\r
320           isp_echo_id\r
321           isp_pin\r
322           authorization\r
323           billing_ip_address\r
324           billing_prefix\r
325           billing_name\r
326           billing_first_name\r
327           billing_last_name\r
328           billing_company_name\r
329           billing_address1\r
330           billing_address2\r
331           billing_city\r
332           billing_state\r
333           billing_zip\r
334           billing_country\r
335           billing_phone\r
336           billing_fax\r
337           billing_email\r
338           cc_number\r
339           ccexp_month\r
340           ccexp_year\r
341           counter\r
342           debug\r
343         );\r
344 \r
345         if ($self->transaction_type =~ /^D[DCVH]$/) {\r
346           push @fields, qw(\r
347             ec_account\r
348             ec_account_type\r
349             ec_payment_type\r
350             ec_address1\r
351             ec_address2\r
352             ec_bank_name\r
353             ec_business_acct\r
354             ec_city\r
355             ec_email\r
356             ec_first_name\r
357             ec_id_country\r
358             ec_id_exp_mm\r
359             ec_id_exp_dd\r
360             ec_id_exp_yy\r
361             ec_id_number\r
362             ec_id_state\r
363             ec_id_type\r
364             ec_last_name\r
365             ec_merchant_ref\r
366             ec_nbds_code\r
367             ec_other_name\r
368             ec_payee\r
369             ec_rt\r
370             ec_serial_number\r
371             ec_state\r
372             ec_transaction_dt\r
373             ec_zip\r
374           );\r
375         }\r
376 \r
377         push @fields, qw(\r
378           grand_total\r
379           merchant_email\r
380           merchant_trace_nbr\r
381           original_amount\r
382           original_trandate_mm\r
383           original_trandate_dd\r
384           original_trandate_yyyy\r
385           original_reference\r
386           order_number\r
387           shipping_flag\r
388           shipping_prefix\r
389           shipping_name\r
390           shipping_address1\r
391           shipping_address2\r
392           shipping_city\r
393           shipping_state\r
394           shipping_zip\r
395           shipping_comments\r
396           shipping_country\r
397           shipping_phone\r
398           shipping_fax\r
399           shipper\r
400           shipper_tracking_nbr\r
401           track1\r
402           track2\r
403           cnp_security\r
404           cnp_recurring\r
405         );\r
406 \r
407         return @fields;\r
408 }\r
409 \r
410 sub GetEchoProp {\r
411         my( $self, $raw, $prop ) = @_;\r
412         local $^W=0;\r
413 \r
414         my $data;\r
415         ($data) = $raw =~ m"<$prop>(.*?)</$prop>"gsi;\r
416         $data =~ s/<.*?>/ /gs;\r
417         chomp $data;\r
418         return $data;\r
419 }\r
420 \r
421 # Get's a given Echo return type and strips all HTML style tags from it.\r
422 # It also strips any new line characters from the returned string.\r
423 #\r
424 # This function based on Ben Reser's <breser@vecdev.com> Echo::Process\r
425 # module.\r
426 sub GetEchoReturn {\r
427         my( $self, $page, $type ) = @_;\r
428         local $^W=0;\r
429 \r
430         my $data;\r
431         if ($type eq 'OPEN') {\r
432                 ($data) = $page =~ m"<OPENECHO>(.*?)</OPENECHO>"gsi;\r
433         }\r
434         else {\r
435                 ($data) = $page =~ m"<ECHOTYPE$type>(.*?)</ECHOTYPE$type>"gsi;\r
436         }\r
437 #       $data =~ s"<.*?>" "g;\r
438 \r
439         #unless (length($data)) {\r
440         #  warn "$self $page $type";\r
441         #}\r
442 \r
443         chomp $data;\r
444         return $data;\r
445 }\r
446 \r
447 use vars qw(%error);\r
448 %error = (\r
449   "01" => [ "Refer to card issuer", "The merchant must call the issuer before the transaction can be approved." ],\r
450   "02" => [ "Refer to card issuer, special condition", "The merchant must call the issuer before the transaction can be approved." ],\r
451   "03" => [ "Invalid merchant number", "The merchant ID is not valid." ],\r
452   "04" => [ "Pick-up card. Capture for reward", "The card is listed on the Warning Bulletin.  Merchant may receive reward money by capturing the card." ],\r
453   "05" => [ "Do not honor. The transaction was declined by the issuer without definition or reason", "The transaction was declined without explanation by the card issuer." ],\r
454   "06" => [ "Error", "The card issuer returned an error without further explanation." ],\r
455   "07" => [ "Pick-up card, special condition", "The card is listed on the Warning Bulletin.  Merchant may receive reward money by capturing the card." ],\r
456   "08" => [ "Honor with identification", "Honor with identification." ],\r
457   "09" => [ "Request in progress", "Request in progress." ],\r
458   "10" => [ "Approved for partial amount", "Approved for partial amount." ],\r
459   "11" => [ "Approved, VIP", "Approved, VIP program." ],\r
460   "12" => [ "Invalid transaction", "The requested transaction is not supported or is not valid for the card number presented." ],\r
461   "13" => [ "Invalid amount", "The amount exceeds the limits established by the issuer for this type of transaction." ],\r
462   "14" => [ "Invalid card #", "The issuer indicates that this card is not valid." ],\r
463   "15" => [ "No such issuer", "The card issuer number is not valid." ],\r
464   "16" => [ "Approved, update track 3", "Approved, update track 3." ],\r
465   "17" => [ "Customer cancellation", "Customer cancellation." ],\r
466   "18" => [ "Customer dispute", "Customer dispute." ],\r
467   "19" => [ "Re enter transaction", "Customer should resubmit transaction." ],\r
468   "20" => [ "Invalid response", "Invalid response." ],\r
469   "21" => [ "No action taken", "No action taken. The issuer declined with no other explanation." ],\r
470   "22" => [ "Suspected malfunction", "Suspected malfunction." ],\r
471   "23" => [ "Unacceptable transaction fee", "Unacceptable transaction fee." ],\r
472   "24" => [ "File update not supported", "File update not supported." ],\r
473   "25" => [ "Unable to locate record", "Unable to locate record." ],\r
474   "26" => [ "Duplicate record", "Duplicate record." ],\r
475   "27" => [ "File update edit error", "File update edit error." ],\r
476   "28" => [ "File update file locked", "File update file locked." ],\r
477   "30" => [ "Format error, call ECHO", "The host reported that the transaction was not formatted properly." ],\r
478   "31" => [ "Bank not supported", "Bank not supported by switch." ],\r
479   "32" => [ "Completed partially", "Completed partially." ],\r
480   "33" => [ "Expired card, pick-up", "The card is expired.  Merchant may receive reward money by capturing the card." ],\r
481   "34" => [ "Issuer suspects fraud, pick-up card", "The card issuer suspects fraud.  Merchant may receive reward money by capturing the card." ],\r
482   "35" => [ "Contact acquirer, pick-up", "Contact card issuer.  Merchant may receive reward money by capturing the card." ],\r
483   "36" => [ "Restricted card, pick-up", "The card is restricted by the issuer.  Merchant may receive reward money by capturing the card." ],\r
484   "37" => [ "Call ECHO security, pick-up", "Contact ECHO security.  Merchant may receive reward money by capturing the card." ],\r
485   "38" => [ "PIN tries exceeded, pick-up", "PIN attempts exceed issuer limits.  Merchant may receive reward money by capturing the card." ],\r
486   "39" => [ "No credit account", "No credit account." ],\r
487   "40" => [ "Function not supported", "Requested function not supported." ],\r
488   "41" => [ "Lost Card, capture for reward", "The card has been reported lost." ],\r
489   "42" => [ "No universal account", "No universal account." ],\r
490   "43" => [ "Stolen Card, capture for reward", "The card has been reported stolen." ],\r
491   "44" => [ "No investment account", "No investment account." ],\r
492   "51" => [ "Not sufficient funds", "The credit limit for this account has been exceeded." ],\r
493   "54" => [ "Expired card", "The card is expired." ],\r
494   "55" => [ "Incorrect PIN", "The cardholder PIN is incorrect." ],\r
495   "56" => [ "No card record", "No card record." ],\r
496   "57" => [ "Transaction not permitted to cardholder", "The card is not allowed the type of transaction requested." ],\r
497   "58" => [ "Transaction not permitted on terminal", "The Merchant is not allowed this type of transaction." ],\r
498   "59" => [ "Suspected fraud", "Suspected fraud." ],\r
499   "60" => [ "Contact ECHO", "Contact ECHO." ],\r
500   "61" => [ "Exceeds withdrawal limit", "The amount exceeds the allowed daily maximum." ],\r
501   "62" => [ "Restricted card", "The card has been restricted." ],\r
502   "63" => [ "Security violation.", "The card has been restricted." ],\r
503   "64" => [ "Original amount incorrect", "Original amount incorrect." ],\r
504   "65" => [ "Exceeds withdrawal frequency", "The allowable number of daily transactions has been exceeded." ],\r
505   "66" => [ "Call acquirer security, call ECHO", "Call acquirer security, call ECHO." ],\r
506   "68" => [ "Response received too late", "Response received too late." ],\r
507   "75" => [ "PIN tries exceeded", "The allowed number of PIN retries has been exceeded." ],\r
508   "76" => [ "Invalid \"to\" account", "The debit account does not exist." ],\r
509   "77" => [ "Invalid \"from\" account", "The credit account does not exist." ],\r
510   "78" => [ "Invalid account specified (general)", "The associated card number account is invalid or does not exist." ],\r
511   "79" => [ "Already reversed", "Already reversed." ],\r
512   "84" => [ "Invalid authorization life cycle", "The authorization life cycle is invalid." ],\r
513   "86" => [ "Cannot verify PIN", "Cannot verify PIN." ],\r
514   "87" => [ "Network Unavailable", "Network Unavailable." ],\r
515   "89" => [ "Ineligible to receive financial position information", "Ineligible to receive financial position information." ],\r
516   "90" => [ "Cut-off in progress", "Cut-off in progress." ],\r
517   "91" => [ "Issuer or switch inoperative", "The bank is not available to authorize this transaction." ],\r
518   "92" => [ "Routing error", "The transaction cannot be routed to the authorizing agency." ],\r
519   "93" => [ "Violation of law", "Violation of law." ],\r
520   "94" => [ "Duplicate transaction", "Duplicate transaction." ],\r
521   "95" => [ "Reconcile error", "Reconcile error." ],\r
522   "96" => [ "System malfunction", "A system error has occurred." ],\r
523   "98" => [ "Exceeds cash limit", "Exceeds cash limit." ],\r
524   "1000" => [ "Unrecoverable error.", "An unrecoverable error has occurred in the ECHONLINE processing." ],\r
525   "1001" => [ "Account closed", "The merchant account has been closed." ],\r
526   "1002" => [ "System closed", "Services for this system are not available. (Not used by ECHONLINE)" ],\r
527   "1003" => [ "E-Mail Down", "The e-mail function is not available. (Not used by ECHONLINE)" ],\r
528   "1012" => [ "Invalid trans code", "The host computer received an invalid transaction code." ],\r
529   "1013" => [ "Invalid term id", "The ECHO-ID is invalid." ],\r
530   "1015" => [ "Invalid card number", "The credit card number that was sent to the host computer was invalid" ],\r
531   "1016" => [ "Invalid expiry date", "The card has expired or the expiration date was invalid." ],\r
532   "1017" => [ "Invalid amount", "The dollar amount was less than 1.00 or greater than the maximum allowed for this card." ],\r
533   "1019" => [ "Invalid state", "The state code was invalid. (Not used by ECHONLINE)" ],\r
534   "1021" => [ "Invalid service", "The merchant or card holder is not allowed to perform that kind of transaction" ],\r
535   "1024" => [ "Invalid auth code", "The authorization number presented with this transaction is incorrect. (deposit transactions only)" ],\r
536   "1025" => [ "Invalid reference number", "The reference number presented with this transaction is incorrect or is not numeric." ],\r
537   "1029" => [ "Invalid contract number", "The contract number presented with this transaction is incorrect or is not numeric. (Not used by ECHONLINE)" ],\r
538   "1030" => [ "Invalid inventory data", "The inventory data presented with this transaction is not ASCII \"printable\". (Not used by ECHONLINE)" ],\r
539   "1508" => [ " ", "Invalid or missing order_type." ],\r
540   "1509" => [ " ", "The merchant is not approved to submit this order_type." ],\r
541   "1510" => [ " ", "The merchant is not approved to submit this transaction_type." ],\r
542   #"1511" => [ " ", "Duplicate transaction attempt (see counterin Part I of this Specification</EM>)." ],\r
543   "1511" => [ " ", "Duplicate transaction attempt (set counter field?)." ],\r
544   "1599" => [ " ", "An system error occurred while validating the transaction input." ],\r
545   "1801" => [ "Return Code \"A\"", "Address matches; ZIP does not match." ],\r
546   "1802" => [ "Return Code \"W\"", "9-digit ZIP matches; Address does not match." ],\r
547   "1803" => [ "Return Code \"Z\"", "5-digit ZIP matches; Address does not match." ],\r
548   "1804" => [ "Return Codes \"U\"", "Issuer unavailable; cannot verify." ],\r
549   "1805" => [ "Return Code \"R\"", "Retry; system is currently unable to process." ],\r
550   "1806" => [ "Return Code \"S\" or \"G\"", "Issuer does not support AVS." ],\r
551   "1807" => [ "Return Code \"N\"", "Nothing matches." ],\r
552   "1808" => [ "Return Code \"E\"", "Invalid AVS only response." ],\r
553   "1809" => [ "Return Code \"B\"", "Street address match. Postal code not verified because of incompatible formats." ],\r
554   "1810" => [ "Return Code \"C\"", "Street address and Postal code not verified because of incompatible formats." ],\r
555   "1811" => [ "Return Code \"D\"", "Street address match and Postal code match." ],\r
556   "1812" => [ "Return Code \"I\"", "Address information not verified for international transaction." ],\r
557   "1813" => [ "Return Code \"M\"", "Street address match and Postal code match." ],\r
558   "1814" => [ "Return Code \"P\"", "Postal code match. Street address not verified because of incompatible formats." ],\r
559   "1897" => [ "invalid response", "The host returned an invalid response." ],\r
560   "1898" => [ "disconnect", "The host unexpectedly disconnected." ],\r
561   "1899" => [ "timeout", "Timeout waiting for host response." ],\r
562   "2071" => [ "Call VISA", "An authorization number from the VISA Voice Center is required to approve this transaction." ],\r
563   "2072" => [ "Call Master Card", "An authorization number from the Master Card Voice Center is required to approve this transaction." ],\r
564   "2073" => [ "Call Carte Blanche", "An authorization number from the Carte Blanche Voice Center is required to approve this transaction." ],\r
565   "2074" => [ "Call Diners Club", "An authorization number from the Diners' Club Voice Center is required to approve this transaction." ],\r
566   "2075" => [ "Call AMEX", "An authorization number from the American Express Voice Center is required to approve this transaction." ],\r
567   "2076" => [ "Call Discover", "An authorization number from the Discover Voice Center is required to approve this transaction." ],\r
568   "2078" => [ "Call ECHO", "The merchant must call ECHOCustomer Support for approval.or because there is a problem with the merchant's account." ],\r
569   "2079" => [ "Call XpresscheX", "The merchant must call ECHOCustomer Support for approval.or because there is a problem with the merchant's account." ],\r
570   "3001" => [ "No ACK on Resp", "The host did not receive an ACK from the terminal after sending the transaction response." ],\r
571   "3002" => [ "POS NAK'd 3 Times", "The host disconnected after the terminal replied 3 times to the host response with a NAK." ],\r
572   "3003" => [ "Drop on Wait", "The line dropped before the host could send a response to the terminal." ],\r
573   "3005" => [ "Drop on Resp", "The line dropped while the host was sending the response to the terminal." ],\r
574   "3007" => [ "Drop Before EOT", "The host received an ACK from the terminal but the line dropped before the host could send the EOT." ],\r
575   "3011" => [ "No Resp to ENQ", "The line was up and carrier detected, but the terminal did not respond to the ENQ." ],\r
576   "3012" => [ "Drop on Input", "The line disconnected while the host was receiving data from the terminal." ],\r
577   "3013" => [ "FEP NAK'd 3 Times", "The host disconnected after receiving 3 transmissions with incorrect LRC from the terminal." ],\r
578   "3014" => [ "No Resp to ENQ", "The line disconnected during input data wait in Multi-Trans Mode." ],\r
579   "3015" => [ "Drop on Input", "The host encountered a full queue and discarded the input data." ],\r
580 );\r
581 for ( 9000..9999 ) {\r
582   $error{$_} = [ "Host Error", "The host encountered an internal error and was not able to process the transaction." ]; \r
583 }\r
584 sub error {\r
585   my( $self, $num ) = @_;\r
586   $num =~ s/^00(\d\d)$/$1/;\r
587   return $num. ': '. $error{$num}[0]. ': '. $error{$num}[1];\r
588 }\r
589 \r
590 1;\r
591 \r
592 __END__\r
593 \r
594 =head1 NAME\r
595 \r
596 Business::OnlinePayment::OpenECHO - ECHO backend module for Business::OnlinePayment\r
597 \r
598 =head1 SYNOPSIS\r
599 \r
600   use Business::OnlinePayment;\r
601 \r
602   ####\r
603   # One step transaction, the simple case.\r
604   ####\r
605 \r
606   my $tx = new Business::OnlinePayment("OpenECHO");\r
607   $tx->content(\r
608       type           => 'VISA',\r
609       login          => '1234684752',\r
610       password       => '43400210',\r
611       action         => 'Normal Authorization',\r
612       description    => 'Business::OnlinePayment test',\r
613       amount         => '49.95',\r
614       invoice_number => '100100',\r
615       customer_id    => 'jsk',\r
616       first_name     => 'Tofu',\r
617       last_name      => 'Beast',\r
618       address        => '123 Anystreet',\r
619       city           => 'Anywhere',\r
620       state          => 'UT',\r
621       zip            => '84058',\r
622       card_number    => '4005550000000019',\r
623       expiration     => '08/06',\r
624       cvv2           => '1234', #optional\r
625       referer        => 'http://valid.referer.url/',\r
626   );\r
627   $tx->submit();\r
628 \r
629   if($tx->is_success()) {\r
630       print "Card processed successfully: ".$tx->authorization."\n";\r
631   } else {\r
632       print "Card was rejected: ".$tx->error_message."\n";\r
633   }\r
634 \r
635 =head1 SUPPORTED TRANSACTION TYPES\r
636 \r
637 =head2 CC, Visa, MasterCard, American Express, Discover\r
638 \r
639 Content required: type, login, password, action, amount, first_name, last_name, card_number, expiration.\r
640 \r
641 =head2 Check\r
642 \r
643 Not yet implemented...\r
644 #Content required: type, login, password, action, amount, first_name, last_name, account_number, routing_code, bank_name.\r
645 \r
646 =head1 PREREQUISITES\r
647 \r
648   URI::Escape\r
649   Tie::IxHash\r
650 \r
651   Net::SSLeay _or_ ( Crypt::SSLeay and LWP )\r
652 \r
653 =head1 DESCRIPTION\r
654 \r
655 For detailed information see L<Business::OnlinePayment>.\r
656 \r
657 =head1 AUTHOR\r
658 \r
659 Original Author\r
660 Michael Lehmkuhl <michael@electricpulp.com>\r
661 \r
662 Special Thanks\r
663 Jim Darden <jdarden@echo-inc.com>\r
664 Dan Browning <db@kavod.com>\r
665 \r
666 Business::OnlinePayment Implementation\r
667 Ivan Kohler <ivan-openecho@420.am>\r
668 \r
669 =head1 SEE ALSO\r
670 \r
671 perl(1). L<Business::OnlinePayment>.\r
672 \r
673 =cut\r
674 \r