initial import BEGIN BUSINESS_ONLINEPAYMENT_PAYCONNECT_0_01
authorivan <ivan>
Mon, 18 Nov 2002 14:42:13 +0000 (14:42 +0000)
committerivan <ivan>
Mon, 18 Nov 2002 14:42:13 +0000 (14:42 +0000)
Changes [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Makefile.PL [new file with mode: 0644]
PayConnect.pm [new file with mode: 0644]
README [new file with mode: 0644]
t/bad_lec.t [new file with mode: 0644]
t/bop.t [new file with mode: 0644]
t/lec.t [new file with mode: 0644]
t/load.t [new file with mode: 0644]

diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..2b6d101
--- /dev/null
+++ b/Changes
@@ -0,0 +1,5 @@
+Revision history for Perl extension Business::OnlinePayment::PayConnect.
+
+0.01  Sat Nov 17 21:59:37 PST 2002
+       -original version; created by ivan 1.0
+
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..3a82b83
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,9 @@
+PayConnect.pm
+Changes
+MANIFEST
+Makefile.PL
+README
+t/load.t
+t/bop.t
+t/lec.t
+t/bad_lec.t
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..3882606
--- /dev/null
@@ -0,0 +1,15 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    'NAME'         => 'Business::OnlinePayment::PayConnect',
+    'VERSION_FROM' => 'PayConnect.pm', # finds $VERSION
+    'AUTHOR'       => 'Ivan Kohler <ivan-payconnect@420.am>',
+    #'NORECURS'     => 1, # dont descend into subdirectories
+    'PREREQ_PM'    => { 'Net::SSLeay' => '0',
+                        #'Text::CSV_XS' => 0,
+                        'Business::OnlinePayment' => '0',
+                        #'Business::CreditCard' => 0.27,
+                      },
+);
+
diff --git a/PayConnect.pm b/PayConnect.pm
new file mode 100644 (file)
index 0000000..10597b5
--- /dev/null
@@ -0,0 +1,179 @@
+package Business::OnlinePayment::PayConnect;
+
+use strict;
+use Carp;
+use Business::OnlinePayment;
+#use Business::CreditCard;
+use Net::SSLeay qw( make_form post_https get_https make_headers );
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
+
+require Exporter;
+
+@ISA = qw(Exporter AutoLoader Business::OnlinePayment);
+@EXPORT = qw();
+@EXPORT_OK = qw();
+$VERSION = '0.01';
+
+$DEBUG = 0;
+
+sub set_defaults {
+    my $self = shift;
+
+    #test
+    $self->server('zavijah.e-ebi.net');
+    $self->port('443');
+    $self->path('/rtv/servlet/aio');
+
+    $self->build_subs(qw( partner ));
+}
+
+sub revmap_fields {
+    my($self, %map) = @_;
+    my %content = $self->content();
+    foreach(keys %map) {
+        $content{$_} = ref($map{$_})
+                         ? ${ $map{$_} }
+                         : $content{$map{$_}};
+    }
+    $self->content(%content);
+}
+
+sub submit {
+    my $self = shift;
+    my %content = $self->content();
+
+    my $action = lc($content{'action'});
+    if ( $action eq 'authorization only' ) {
+    } else {
+      croak "$action not (yet) supported";
+    }
+    
+    my $type = lc($content{'type'});
+    if ( $type eq 'lec' ) {
+    } else {
+      croak "$type not (yet) supported";
+    }
+
+    $content{'zip'} =~ s/\D//g;
+    $content{'zip'} =~ /^(\d{5})(\d*)$/;
+    my($zip, $zip4) = ($1, $2);
+
+    my $phone = $content{'phone'};
+    $phone =~ s/\D//g;
+
+    $self->revmap_fields(
+      ebiinfo   => \'AIO-1.0',
+      clientid  => 'login',
+      password  => 'password',
+      partner   => \($self->partner()),
+      #sysid
+      transtype => \'A', #action
+      paytype   => \'lec', #type
+      trackid   => 'invoice_number',
+      acctid    => 'customer_id',
+      billname  => 'name',
+      billaddr1 => 'address',
+      #billaddr2 =>
+      billcity  => 'city',
+      billstate => 'state',
+      billzip   => \$zip,
+      billzip4  => \$zip4,
+      amt       => 'amount',
+
+      #LEC
+      #ani
+      btn       => \$phone,
+      #dni
+      #traffic
+      #planid
+      #pincode
+    );
+
+    my %post_data = $self->get_fields(qw(
+        ebiinfo clientid password partner transtype paytype trackid acctid
+        billname billaddr1 billcity billstate billzip billzip4 amt btn
+    ));
+
+    my $s = $self->server();
+    my $p = $self->port();
+    my $t = $self->path();
+
+    my $pd = make_form(%post_data);
+    my($page,$server_response,%headers) = post_https($s,$p,$t,'',$pd);
+
+    #warn join('-',%headers);
+    #warn $page;
+    my %response = map { split('=',$_,2) } split(/\|/,$page);
+    #warn "$_: $response{$_}\n" foreach keys %response;
+
+    if ( $response{'response'} eq '0000' ) {
+      $self->is_success(1);
+      $self->result_code('0000');
+      $self->authorization($response{'trackid'});
+    } else {
+      $self->is_success(0);
+      $self->result_code($response{'response'});
+      $self->error_message($response{'respmsg'});
+    }
+
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Business::OnlinePayment::PayConnect - PaymentOne (formerly eBillit) PayConnect  backend for Business::OnlinePayment
+
+=head1 SYNOPSIS
+
+  use Business::OnlinePayment;
+
+  my $tx = new Business::OnlinePayment("PayConnect",
+    'partner' => '',
+  );
+  $tx->content(
+      type           => 'LEC',
+      login          => 'test', #ClientID
+      password       => 'test',
+      action         => 'Authorization Only',
+      description    => 'Business::OnlinePayment test',
+      amount         => '49.95',
+      invoice_number => '100100',
+      name           => 'Tofu Beast',
+      phone          => '4155554321',
+  );
+  $tx->submit();
+
+  if($tx->is_success()) {
+      print "LEC billing authorized successfully: ".$tx->authorization."\n";
+  } else {
+      print "LEC billing was rejected: ".$tx->error_message."\n";
+  }
+
+=head1 DESCRIPTION
+
+For detailed information see L<Business::OnlinePayment>.
+
+=head1 NOTE
+
+This module only implements 'LEC' (phone bill billing) functionality at this
+time.  Credit card and ACH transactions are not (yet) supported.
+
+=head1 COMPATIBILITY
+
+This module implements an interface the "HTTPS AIO Validation Protocol
+version 3.0" of PaymentOne (formerly eBillit) PayConnect
+<http://www.paymentone.com/products/paycon.asp>.  Unfortunately, no
+documentation is publicly available.
+
+=head1 AUTHOR
+
+Ivan Kohler <ivan-jettis@420.am>
+
+=head1 SEE ALSO
+
+perl(1). L<Business::OnlinePayment>
+
+=cut
+
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..f5ad54a
--- /dev/null
+++ b/README
@@ -0,0 +1,20 @@
+Copyright (c) 2002 Ivan Kohler
+
+All rights reserved. This program is free software; you can redistribute it
+and/or modify it under the same terms as Perl itself.
+
+This is Business::OnlinePayment::PayConnect, an Business::OnlinePayment backend
+module for the PaymentOne (formerly eBillit) PayConnect.  It is only
+useful if you have a merchant account with PaymentOne (formerly eBillit):
+http://www.paymentone.com/products/paycon.asp
+
+Currently, only 'LEC' billing is supported.  Eventually credit card and ACH
+will be supported as well.
+
+Ivan Kohler <ivan-payconnect@420.am>
+
+Business::OnlinePayment is a generic interface for processing payments through
+online credit card processors, online check acceptance houses, etc.  (If you
+like buzzwords, call it an "multiplatform ecommerce-enabling middleware
+solution").
+
diff --git a/t/bad_lec.t b/t/bad_lec.t
new file mode 100644 (file)
index 0000000..ec7b7f6
--- /dev/null
@@ -0,0 +1,47 @@
+#BEGIN { $| = 1; print "1..4\n"; }
+BEGIN { $| = 1; print "1..3\n"; }
+
+use Business::OnlinePayment;
+
+my %phone2error = (
+  '2033500000' => '0130',
+  '2012179746' => '0150',
+  '4083624100' => '0160',
+  #got 0416 (expected 0141)?? #'9044270189' => '0141',
+);
+
+foreach my $phone (keys %phone2error) {
+
+  my $tx = new Business::OnlinePayment("PayConnect",
+    partner => 's9Te1',
+  );
+  $tx->content(
+      type           => 'LEC',
+      login          => '7001',
+      password       => '9PIci',
+      action         => 'Authorization Only',
+      description    => 'Business::OnlinePayment LEC test',
+      amount         => '1.01',
+      invoice_number => '100100',
+      customer_id    => 'jsk',
+      first_name     => 'Tofu',
+      last_name      => 'Beast',
+      address        => '123 Anystreet',
+      city           => 'Anywhere',
+      state          => 'UT',
+      zip            => '84058',
+      phone          => $phone,
+  );
+  $tx->test_transaction(1); # test, dont really charge (NOP for this gateway)
+  $tx->submit();
+  
+  $num++;
+  if($tx->is_success() || $tx->result_code ne $phone2error{$phone} ) {
+      warn "**** got ". $tx->result_code. " (expected $phone2error{$phone}): ".
+           $tx->error_message. " ****\n";
+      print "not ok $num\n";
+  } else {
+      print "ok $num\n";
+  }
+
+}
diff --git a/t/bop.t b/t/bop.t
new file mode 100644 (file)
index 0000000..64332c5
--- /dev/null
+++ b/t/bop.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Business::OnlinePayment;
+$loaded = 1;
+print "ok 1\n";
diff --git a/t/lec.t b/t/lec.t
new file mode 100644 (file)
index 0000000..438afeb
--- /dev/null
+++ b/t/lec.t
@@ -0,0 +1,39 @@
+BEGIN { $| = 1; print "1..2\n"; }
+
+use Business::OnlinePayment;
+
+foreach my $phone (qw( 4082435901 8107926049 )) {
+
+  my $tx = new Business::OnlinePayment("PayConnect",
+    partner => 's9Te1',
+  );
+  $tx->content(
+      type           => 'LEC',
+      login          => '7001',
+      password       => '9PIci',
+      action         => 'Authorization Only',
+      description    => 'Business::OnlinePayment LEC test',
+      amount         => '1.00',
+      invoice_number => '100100',
+      customer_id    => 'jsk',
+      name           => 'Tofu Beast',
+      first_name     => 'Tofu',
+      last_name      => 'Beast',
+      address        => '123 Anystreet',
+      city           => 'Anywhere',
+      state          => 'UT',
+      zip            => '84058',
+      phone          => $phone,
+  );
+  $tx->test_transaction(1); # test, dont really charge (NOP for this gateway)
+  $tx->submit();
+
+  $num++;
+  if($tx->is_success()) {
+      print "ok $num\n";
+  } else {
+      warn "*******". $tx->error_message. "*******";
+      print "not ok $num\n";
+  }
+
+}
diff --git a/t/load.t b/t/load.t
new file mode 100644 (file)
index 0000000..8b4190c
--- /dev/null
+++ b/t/load.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Business::OnlinePayment::PayConnect;
+$loaded = 1;
+print "ok 1\n";