initial import BEGIN BUSINESS_ONLINEPAYMENT_OCV_0_01
authorivan <ivan>
Sat, 16 Nov 2002 01:40:49 +0000 (01:40 +0000)
committerivan <ivan>
Sat, 16 Nov 2002 01:40:49 +0000 (01:40 +0000)
Changes [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Makefile.PL [new file with mode: 0644]
OCV.pm [new file with mode: 0644]
README [new file with mode: 0644]
t/bop.t [new file with mode: 0644]
t/load.t [new file with mode: 0644]
t2/bad_auth.t [new file with mode: 0644]
t2/credit_card.t [new file with mode: 0644]

diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..a32885b
--- /dev/null
+++ b/Changes
@@ -0,0 +1,5 @@
+Revision history for Perl extension Business::OnlinePayment::OCV.
+
+0.01  Sat Nov  9 13:39:46 PST 2002
+       -original version; created by ivan 1.0
+       -based on Business::OCV by Benjamin Low <b.d.low@unsw.edu.au>
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..5a47938
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,9 @@
+OCV.pm
+Changes
+MANIFEST
+Makefile.PL
+README
+t/load.t
+t/bop.t
+t2/credit_card.t
+t2/bad_auth.t
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..27e1d6b
--- /dev/null
@@ -0,0 +1,16 @@
+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::OCV',
+    'VERSION_FROM' => 'OCV.pm', # finds $VERSION
+    'AUTHOR'       => 'Ivan Kohler <ivan-ocv@420.am>',
+    #'NORECURS'     => 1, # dont descend into subdirectories
+    'PREREQ_PM'    => { 'Net::SSLeay' => 0,
+                        #'Text::CSV_XS' => 0,
+                        'Business::OnlinePayment' => 0,
+                        #'Business::CreditCard' => 0.27,
+                        'Business::OCV' => 0,
+                      },
+);
+
diff --git a/OCV.pm b/OCV.pm
new file mode 100644 (file)
index 0000000..e1793d4
--- /dev/null
+++ b/OCV.pm
@@ -0,0 +1,129 @@
+package Business::OnlinePayment::OCV;
+
+use strict;
+use Carp;
+use Business::OnlinePayment;
+#use Business::CreditCard;
+#use Net::SSLeay qw( make_form post_https );
+use Business::OCV; #qw( :transaction );
+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';
+
+#Business::OCV exporting is broken
+use subs qw(TRANS_APPROVED);
+sub TRANS_APPROVED   (){ '0' }  # transaction status result - approved
+
+$DEBUG = 0;
+
+
+sub set_defaults {
+    my $self = shift;
+#    $self->server('sec.aba.net.au');
+#    $self->port('443');
+#    $self->path('/cgi-bin/service/authint');
+    $self->build_subs(qw( account ));
+}
+
+sub submit {
+    my $self = shift;
+    my %content = $self->content;
+
+    my $action = lc($content{'action'});
+    if ( $action eq 'normal authorization' ) {
+    } else {
+      croak "$action not (yet) supported";
+    }
+
+    $content{'expiration'} =~ /^(\d+)\D+\d{0,2}(\d{2})$/
+      or croak "unparsable expiration $content{expiration}";
+    my ($month, $year) = ( $1, $2 );
+    $month += 0;
+    $month = "0$month" if $month < 10;
+    my $exp = "$month$year";
+
+    my $ocv = new OCV (
+        Server      => $self->server. ':'. $self->port,
+        ClientID    => $content{login},
+        AccountNum  => $self->account,
+    ) or die "can't create Business::OCV object: $@!";
+
+    my $m = $ocv->purchase(
+      'CardData'   => $content{card_number},
+      'CardExpiry' => $exp,
+      'Amount'     => $content{'amount'} * 100,
+    );
+    croak $@ unless $m;
+
+    warn "Result: ". $m->Result, "\n";
+
+    if ( $m->Result == TRANS_APPROVED ) {
+      $self->is_success(1);
+      $self->result_code($m->Result);
+      $self->authorization($m->PreAuth); #?
+    } else {
+      $self->is_success(0);
+      $self->result_code($m->Result);
+      $self->error_message($m->ResponseText);
+    }
+
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Business::OnlinePayment::OCV - OCV backend for Business::OnlinePayment
+
+=head1 SYNOPSIS
+
+  use Business::OnlinePayment;
+
+  my $tx = new Business::OnlinePayment("OCV");
+  $tx->content(
+      type           => 'CC',
+      login          => 'test', #ClientID
+      action         => 'Authorization Only',
+      description    => 'Business::OnlinePayment test',
+      amount         => '49.95',
+      invoice_number => '100100',
+      name           => 'Tofu Beast',
+      card_number    => '4007000000027',
+      expiration     => '09/02',
+  );
+  $tx->submit();
+
+  if($tx->is_success()) {
+      print "Card processed successfully: ".$tx->authorization."\n";
+  } else {
+      print "Card was rejected: ".$tx->error_message."\n";
+  }
+
+=head1 DESCRIPTION
+
+For detailed information see L<Business::OnlinePayment>.
+
+=head1 NOTE
+
+=head1 COMPATIBILITY
+
+This module is a wrapper around Business::OCV written by Benjamin
+Low <b.d.low@unsw.edu.au>.  Eventually it will be self-contained.
+See <INSERTURLHERE> for details.
+
+=head1 AUTHOR
+
+Ivan Kohler <ivan-ocv@420.am>
+
+=head1 SEE ALSO
+
+perl(1). L<Business::OnlinePayment>, L<Business::OCV>.
+
+=cut
+
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..29e8dd2
--- /dev/null
+++ b/README
@@ -0,0 +1,24 @@
+Copyright (c) 1999/2000 University of New South Wales
+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::OCV, an Business::OnlinePayment backend
+module for the Ingenico Online Credit Verification Server (OCV).  It is only
+useful if you have a merchant account with Ingenico:
+http://www.ingenico.com.au
+
+Currently, it is mostly a wrapper around Business::OCV written by Benjamin
+Low <b.d.low@unsw.edu.au>.  Eventually it will be self-contained.
+
+There are tests in t2/ that may be useful to you once you have a test server
+setup.
+
+Ivan Kohler <ivan-ocv@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/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/load.t b/t/load.t
new file mode 100644 (file)
index 0000000..e414beb
--- /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::OCV;
+$loaded = 1;
+print "ok 1\n";
diff --git a/t2/bad_auth.t b/t2/bad_auth.t
new file mode 100644 (file)
index 0000000..4c4f610
--- /dev/null
@@ -0,0 +1,35 @@
+BEGIN { $| = 1; print "1..1\n"; }
+
+use Business::OnlinePayment;
+
+my $tx = new Business::OnlinePayment("OCV",
+  account => '0',
+  server  => 'localhost',
+  port    => 3005,
+);
+$tx->content(
+    type           => 'CC',
+    login          => '10009', #ClientID
+    action         => 'Normal Authorization',
+    description    => 'Business::OnlinePayment visa 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',
+    card_number    => '4111111111111112',
+    expiration     => '08/06',
+);
+$tx->test_transaction(1); # test, dont really charge (NOP for this gateway)
+$tx->submit();
+
+if($tx->is_success()) {
+    print "not ok 1\n";
+    warn $tx->error_message;
+} else {
+    print "ok 1\n";
+}
diff --git a/t2/credit_card.t b/t2/credit_card.t
new file mode 100644 (file)
index 0000000..30056d9
--- /dev/null
@@ -0,0 +1,36 @@
+BEGIN { $| = 1; print "1..1\n"; }
+
+use Business::OnlinePayment;
+
+my $tx = new Business::OnlinePayment("OCV",
+  account => '0',
+  server  => 'localhost',
+  port    => 3005,
+);
+$tx->content(
+    type           => 'CC',
+    login          => '10009', #ClientID
+    action         => 'Normal Authorization',
+    description    => 'Business::OnlinePayment visa 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',
+    card_number    => '4111111111111111',
+    expiration     => '08/06',
+);
+$tx->test_transaction(1); # test, dont really charge (NOP for this gateway)
+$tx->submit();
+
+if($tx->is_success()) {
+    print "ok 1\n";
+} else {
+    warn "*******". $tx->error_message. "*******";
+    print "not ok 1\n";
+}