- Switch from GET to POST, as per old 1.5 prerelease from Michael
[Business-OnlinePayment-OpenECHO.git] / OpenECHO.pm
index fdf3a56..a9eed3a 100644 (file)
@@ -56,10 +56,11 @@ use strict;
 use Carp;\r
 use Business::OnlinePayment 3;\r
 use Business::OnlinePayment::HTTPS;\r
-use vars qw($VERSION @ISA);\r
+use vars qw($VERSION @ISA $DEBUG);\r
 \r
 @ISA = qw(Business::OnlinePayment::HTTPS);\r
 $VERSION = '0.03';\r
+$DEBUG = 0;\r
 \r
 sub set_defaults {\r
        my $self = shift;\r
@@ -96,6 +97,14 @@ sub map_fields {
 \r
     my %content = $self->content();\r
 \r
+    if ( lc($content{'action'}) eq 'void' ) {\r
+      $self->is_success(0);\r
+      $self->error_message( 'OpenECHO gateway does not support voids; '.\r
+                            'try action => "Credit" '\r
+                          );\r
+      return;\r
+    }\r
+\r
     my $avs = $self->require_avs;\r
     $avs = 1 unless defined($avs) && length($avs); #default AVS on unless explicitly turned off\r
 \r
@@ -214,6 +223,8 @@ sub submit {
         license_num       => 'ec_id_number',\r
         license_state     => 'ec_id_state',\r
         #license_dob       =>\r
+        payee             => 'ec_payee',\r
+        check_number      => 'ec_serial_number',\r
 \r
         #recurring_billing => 'cnp_recurring',\r
     );\r
@@ -224,14 +235,16 @@ sub submit {
     #XXX counter field shouldn't be just a random integer (but it does need a\r
     #default this way i guess...\r
     $self->{_content}{counter} = int(rand(2**31));\r
-\r
-    #ccexp_month & ccexp_year\r
-    $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/\r
-      or croak "unparsable expiration ". $self->{_content}{expiration};\r
-    my( $month, $year ) = ( $1, $2 );\r
-    $month = '0'. $month if $month =~ /^\d$/;\r
-    $self->{_content}{ccexp_month} = $month;\r
-    $self->{_content}{ccexp_year} = $year;\r
+    \r
+    if ( $self->transaction_type =~ /^[EA][VS]$/ ) {\r
+      #ccexp_month & ccexp_year\r
+      $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/\r
+        or croak "unparsable expiration ". $self->{_content}{expiration};\r
+      my( $month, $year ) = ( $1, $2 );\r
+      $month = '0'. $month if $month =~ /^\d$/;\r
+      $self->{_content}{ccexp_month} = $month;\r
+      $self->{_content}{ccexp_year} = $year;\r
+    }\r
 \r
     $self->{_content}{cnp_recurring} = 'Y'\r
       if exists($self->{_content}{recurring_billing})\r
@@ -244,7 +257,9 @@ sub submit {
     $self->required_fields();\r
 \r
     my( $page, $response, %reply_headers) =\r
-      $self->https_get( $self->get_fields( $self->fields ) );\r
+      $self->https_post( $self->get_fields( $self->fields ) );\r
+\r
+    warn "raw echo response: $page" if $DEBUG;\r
 \r
     #XXX check $response and die if not 200?\r
 \r