we need B:OP v3, declare so in Makefile.PL
[Business-OnlinePayment-OpenECHO.git] / OpenECHO.pm
index a9eed3a..668bd8a 100644 (file)
 # --------\r
 # + v0.1        08/26/2004 Business::OnlinePayment implementation\r
 # + v0.2        09/13/2004\r
-# + v0.3        unreleased\r
+# + v0.3        03/25/2006\r
 #\r
 # Copyright (C) 2002 Electric Pulp. <info@electricpulp.com>\r
-# Copyright (C) 2004 Ivan Kohler\r
+# Copyright (C) 2004-2006 Ivan Kohler\r
 #\r
 # This program is free software; you can redistribute it and/or modify\r
 # it under the terms of the GNU General Public License as published by\r
@@ -59,7 +59,7 @@ use Business::OnlinePayment::HTTPS;
 use vars qw($VERSION @ISA $DEBUG);\r
 \r
 @ISA = qw(Business::OnlinePayment::HTTPS);\r
-$VERSION = '0.03';\r
+$VERSION = '0.04';\r
 $DEBUG = 0;\r
 \r
 sub set_defaults {\r
@@ -127,7 +127,7 @@ sub map_fields {
                  #'void'                 => 'VOID',\r
                );\r
       }\r
-    } elsif ( $content{'type'} =~ /^check$/i ) {\r
+    } elsif ( $content{'type'} =~ /^e?check$/i ) {\r
       %map = ( 'normal authorization' => 'DD',\r
                'authorization only'   => 'DV',\r
                'credit'               => 'DC',\r
@@ -223,7 +223,7 @@ sub submit {
         license_num       => 'ec_id_number',\r
         license_state     => 'ec_id_state',\r
         #license_dob       =>\r
-        payee             => 'ec_payee',\r
+        #get from new() args instead# payee             => 'ec_payee',\r
         check_number      => 'ec_serial_number',\r
 \r
         #recurring_billing => 'cnp_recurring',\r
@@ -235,7 +235,7 @@ 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
+\r
     if ( $self->transaction_type =~ /^[EA][VS]$/ ) {\r
       #ccexp_month & ccexp_year\r
       $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/\r
@@ -246,6 +246,19 @@ sub submit {
       $self->{_content}{ccexp_year} = $year;\r
     }\r
 \r
+    if ( $self->transaction_type =~ /^D[DVCH]$/ ) { #echeck\r
+\r
+      #check number kludge... "periodic bill payments" don't have check #s!\r
+      #$self->{_content}{ec_serial_number} = 'RECURRIN'\r
+      $self->{_content}{ec_serial_number} = '00000000'\r
+        if ! length($self->{_content}{ec_serial_number})\r
+        && $self->{_content}{ec_payment_type} =~ /^(PPD)?$/i;\r
+\r
+      ( $self->{_content}{ec_payee} = $self->payee )\r
+        or croak "'payee' option required when instantiating new ".\r
+                 "Business::OnlinePayment::OpenECHO object\n";\r
+    }\r
+\r
     $self->{_content}{cnp_recurring} = 'Y'\r
       if exists($self->{_content}{recurring_billing})\r
       && $self->{_content}{recurring_billing} =~ /^y/i;\r
@@ -655,8 +668,7 @@ Content required: type, login, password, action, amount, first_name, last_name,
 \r
 =head2 Check\r
 \r
-Not yet implemented...\r
-#Content required: type, login, password, action, amount, first_name, last_name, account_number, routing_code, bank_name.\r
+Content required: type, login, password, action, amount, first_name, last_name, account_number, routing_code, bank_name. (...more)\r
 \r
 =head1 PREREQUISITES\r
 \r