1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
|