- Switch from GET to POST, as per old 1.5 prerelease from Michael
authorivan <ivan>
Mon, 7 Nov 2005 11:10:08 +0000 (11:10 +0000)
committerivan <ivan>
Mon, 7 Nov 2005 11:10:08 +0000 (11:10 +0000)
  Lehmkuhl <michael@electricpulp.com>
- Don't check expiration for ECHECK and refunds
- For the unsupported "void" action, return is_success 0 and error
  msg suggesting "credit" action, instead of croaking.  This way the
  "try void first, if it fails, try credit" idiom will work.
- tests: enable check.t and add crypt_check.t and {crypt_}bad_check.t
- update with new test account

Changes
OpenECHO.pm
t/bad_card.t
t/bad_check.t [new file with mode: 0644]
t/check.t
t/credit_card.t
t/crypt_bad_card.t
t/crypt_bad_check.t [new file with mode: 0644]
t/crypt_check.t [new file with mode: 0644]
t/crypt_credit_card.t

diff --git a/Changes b/Changes
index 314e208..25e8f10 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,14 @@
 0.03  unreleased
-       - include final 0.02 changelog
-       - actually bump the version number this time
+       - Include final 0.02 changelog
+       - Actually bump the version number this time
+       - Switch from GET to POST, as per old 1.5 prerelease from Michael
+         Lehmkuhl <michael@electricpulp.com> 
+       - Don't check expiration for ECHECK and refunds
+       - For the unsupported "void" action, return is_success 0 and error
+         msg suggesting "credit" action, instead of croaking.  This way the
+         "try void first, if it fails, try credit" idiom will work.
+       - tests: enable check.t and add crypt_check.t and {crypt_}bad_check.t
+       - update with new test account
 
 0.02  Mon Sep 13 17:14:29 2004
        - update test account with new PIN
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
index 3d0913c..760242b 100644 (file)
@@ -10,9 +10,8 @@ use Business::OnlinePayment;
 my $tx = new Business::OnlinePayment("OpenECHO");
 $tx->content(
     type           => 'VISA',
-    #login          => '123>4684752',
-    login          => '1234684752',
-    password       => '54321420',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
     action         => 'Normal Authorization',
     description    => 'Business::OnlinePayment visa test',
     amount         => '49.95',
diff --git a/t/bad_check.t b/t/bad_check.t
new file mode 100644 (file)
index 0000000..6b44591
--- /dev/null
@@ -0,0 +1,39 @@
+BEGIN { $| = 1; print "1..1\n"; }
+
+eval "use Net::SSLeay;";
+if ( $@ ) {
+  print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
+}
+
+use Business::OnlinePayment;
+
+# checks are broken it seems
+my $ctx = new Business::OnlinePayment("OpenECHO");
+$ctx->content(
+    type           => 'CHECK',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
+    action         => 'Normal Authorization',
+    amount         => '49.95',
+    invoice_number => '100100',
+    customer_id    => 'jsk',
+    first_name     => 'Tofu',
+    last_name      => 'Beast',
+    account_number => '12345',
+    routing_code   => '026009593',
+    bank_name      => 'First National Test Bank',
+    phone          => '420-420-5454',
+    payee          => 'Tofu Heavy Enterprises, GmbH',
+    check_number   => '420',
+);
+$ctx->test_transaction(1); # test, dont really charge
+$ctx->submit();
+
+print $ctx->is_success()."\n";
+
+if($ctx->is_success()) {
+    #warn $ctx->error_message();
+    print "not ok 1 (".$ctx->error_message().")\n";
+} else {
+    print "ok 1\n";
+}
index d64d49c..c68c442 100644 (file)
--- a/t/check.t
+++ b/t/check.t
@@ -1,6 +1,9 @@
 BEGIN { $| = 1; print "1..1\n"; }
 
-print "ok 1 # Skipped: no ACH test yet\n"; exit;
+eval "use Net::SSLeay;";
+if ( $@ ) {
+  print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
+}
 
 use Business::OnlinePayment;
 
@@ -8,8 +11,8 @@ use Business::OnlinePayment;
 my $ctx = new Business::OnlinePayment("OpenECHO");
 $ctx->content(
     type           => 'CHECK',
-    login          => 'testing',
-    password       => 'testing',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
     action         => 'Normal Authorization',
     amount         => '49.95',
     invoice_number => '100100',
@@ -17,8 +20,11 @@ $ctx->content(
     first_name     => 'Tofu',
     last_name      => 'Beast',
     account_number => '12345',
-    routing_code   => '123456789',
+    routing_code   => '026009593',
     bank_name      => 'First National Test Bank',
+    phone          => '420-420-5454',
+    payee          => 'Tofu Heavy Enterprises, GmbH',
+    check_number   => '420',
 );
 $ctx->test_transaction(1); # test, dont really charge
 $ctx->submit();
@@ -28,5 +34,6 @@ print $ctx->is_success()."\n";
 if($ctx->is_success()) {
     print "ok 1\n";
 } else {
+    warn $ctx->error_message();
     print "not ok 1 (".$ctx->error_message().")\n";
 }
index 3878374..62b6c8d 100644 (file)
@@ -10,9 +10,8 @@ use Business::OnlinePayment;
 my $tx = new Business::OnlinePayment("OpenECHO");
 $tx->content(
     type           => 'VISA',
-    #login          => '123>4684752',
-    login          => '1234684752',
-    password       => '54321420',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
     action         => 'Normal Authorization',
     description    => 'Business::OnlinePayment visa test',
     amount         => '49.95',
index 9e10fc2..572b187 100644 (file)
@@ -14,9 +14,8 @@ use Business::OnlinePayment;
 my $tx = new Business::OnlinePayment("OpenECHO");
 $tx->content(
     type           => 'VISA',
-    #login          => '123>4684752',
-    login          => '1234684752',
-    password       => '54321420',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
     action         => 'Normal Authorization',
     description    => 'Business::OnlinePayment visa test',
     amount         => '49.95',
diff --git a/t/crypt_bad_check.t b/t/crypt_bad_check.t
new file mode 100644 (file)
index 0000000..4903b48
--- /dev/null
@@ -0,0 +1,43 @@
+BEGIN {
+  $| = 1; print "1..1\n";
+  $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
+  $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
+}
+
+eval "use Crypt::SSLeay;";
+if ( $@ ) {
+  print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit;
+}
+
+use Business::OnlinePayment;
+
+# checks are broken it seems
+my $ctx = new Business::OnlinePayment("OpenECHO");
+$ctx->content(
+    type           => 'CHECK',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
+    action         => 'Normal Authorization',
+    amount         => '49.95',
+    invoice_number => '100100',
+    customer_id    => 'jsk',
+    first_name     => 'Tofu',
+    last_name      => 'Beast',
+    account_number => '12345',
+    routing_code   => '026009593',
+    bank_name      => 'First National Test Bank',
+    phone          => '420-420-5454',
+    payee          => 'Tofu Heavy Enterprises, GmbH',
+    check_number   => '420',
+);
+$ctx->test_transaction(1); # test, dont really charge
+$ctx->submit();
+
+print $ctx->is_success()."\n";
+
+if($ctx->is_success()) {
+    #warn $ctx->error_message();
+    print "not ok 1 (".$ctx->error_message().")\n";
+} else {
+    print "ok 1\n";
+}
diff --git a/t/crypt_check.t b/t/crypt_check.t
new file mode 100644 (file)
index 0000000..7d01a85
--- /dev/null
@@ -0,0 +1,43 @@
+BEGIN {
+  $| = 1; print "1..1\n";
+  $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
+  $Business::OnlinePayment::HTTPS::skip_NetSSLeay=1;
+}
+
+eval "use Crypt::SSLeay;";
+if ( $@ ) {
+  print "ok 1 # Skipped: Crypt::SSLeay is not installed\n"; exit;
+}
+
+use Business::OnlinePayment;
+
+# checks are broken it seems
+my $ctx = new Business::OnlinePayment("OpenECHO");
+$ctx->content(
+    type           => 'CHECK',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
+    action         => 'Normal Authorization',
+    amount         => '49.95',
+    invoice_number => '100100',
+    customer_id    => 'jsk',
+    first_name     => 'Tofu',
+    last_name      => 'Beast',
+    account_number => '12345',
+    routing_code   => '026009593',
+    bank_name      => 'First National Test Bank',
+    phone          => '420-420-5454',
+    payee          => 'Tofu Heavy Enterprises, GmbH',
+    check_number   => '420',
+);
+$ctx->test_transaction(1); # test, dont really charge
+$ctx->submit();
+
+print $ctx->is_success()."\n";
+
+if($ctx->is_success()) {
+    print "ok 1\n";
+} else {
+    warn $ctx->error_message();
+    print "not ok 1 (".$ctx->error_message().")\n";
+}
index 8f5c252..6b7c01a 100644 (file)
@@ -14,9 +14,8 @@ use Business::OnlinePayment;
 my $tx = new Business::OnlinePayment("OpenECHO");
 $tx->content(
     type           => 'VISA',
-    #login          => '123>4684752',
-    login          => '1234684752',
-    password       => '54321420',
+    'login'        => '123>4685706',
+    'password'     => '09437869',
     action         => 'Normal Authorization',
     description    => 'Business::OnlinePayment visa test',
     amount         => '49.95',