File Coverage

blib/lib/Business/OnlinePayment/OCV.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Business::OnlinePayment::OCV;
2              
3 1     1   694 use strict;
  1         2  
  1         29  
4 1     1   4 use Carp;
  1         2  
  1         76  
5 1     1   860 use Business::OnlinePayment;
  1         3072  
  1         31  
6             #use Business::CreditCard;
7             #use Net::SSLeay qw( make_form post_https );
8 1     1   1521 use Business::OCV; #qw( :transaction );
  0            
  0            
9             use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
10              
11             require Exporter;
12              
13             @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
14             @EXPORT = qw();
15             @EXPORT_OK = qw();
16             $VERSION = '0.01';
17              
18             #Business::OCV exporting is broken
19             use subs qw(TRANS_APPROVED);
20             sub TRANS_APPROVED (){ '0' } # transaction status result - approved
21              
22             $DEBUG = 0;
23              
24              
25             sub set_defaults {
26             my $self = shift;
27             # $self->server('sec.aba.net.au');
28             # $self->port('443');
29             # $self->path('/cgi-bin/service/authint');
30             $self->build_subs(qw( account ));
31             }
32              
33             sub submit {
34             my $self = shift;
35             my %content = $self->content;
36              
37             my $action = lc($content{'action'});
38             if ( $action eq 'normal authorization' ) {
39             } else {
40             croak "$action not (yet) supported";
41             }
42              
43             $content{'expiration'} =~ /^(\d+)\D+\d{0,2}(\d{2})$/
44             or croak "unparsable expiration $content{expiration}";
45             my ($month, $year) = ( $1, $2 );
46             $month += 0;
47             $month = "0$month" if $month < 10;
48             my $exp = "$month$year";
49              
50             my $ocv = new OCV (
51             Server => $self->server. ':'. $self->port,
52             ClientID => $content{login},
53             AccountNum => $self->account,
54             ) or die "can't create Business::OCV object: $@!";
55              
56             my $m = $ocv->purchase(
57             'CardData' => $content{card_number},
58             'CardExpiry' => $exp,
59             'Amount' => $content{'amount'} * 100,
60             );
61             croak $@ unless $m;
62              
63             warn "Result: ". $m->Result, "\n";
64              
65             if ( $m->Result == TRANS_APPROVED ) {
66             $self->is_success(1);
67             $self->result_code($m->Result);
68             $self->authorization($m->PreAuth); #?
69             } else {
70             $self->is_success(0);
71             $self->result_code($m->Result);
72             $self->error_message($m->ResponseText);
73             }
74              
75             }
76              
77             1;
78             __END__