1 package Business::OnlinePayment::eSec;
5 use Business::OnlinePayment;
6 use Business::CreditCard;
7 use Net::SSLeay qw( make_form post_https );
8 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG);
12 @ISA = qw(Exporter AutoLoader Business::OnlinePayment);
21 $self->server('sec.aba.net.au');
23 $self->path('/cgi-bin/service/authint');
28 my %content = $self->content();
30 $content{$_} = ref($map{$_})
34 $self->content(%content);
38 my($self,@fields) = @_;
40 my %content = $self->content();
42 foreach( grep defined $content{$_}, @fields) { $new{$_} = $content{$_}; }
48 my %content = $self->content;
50 my $action = lc($content{'action'});
51 die 'eSec only supports "Authorization Only" transactions'
52 unless $action eq 'authorization only';
55 "VISA card" => 'visa',
56 "MasterCard" => 'mastercard',
57 "Discover card" => 'discover', #not supported...
58 "American Express card" => 'amex',
59 "Diner's Club/Carte Blanche" => 'dinersclub',
60 "enRoute" => 'enroute', #not supported...
62 "BankCard" => 'bankcard',
64 my $cardtype = $self->test_transaction
66 : $typemap{cardtype($content{'card_number'})};
68 $content{'expiration'} =~ /^(\d+)\D+(\d+)$/
69 or croak "unparsable expiration $content{expiration}";
70 my ($month, $year) = ( $1, $2 );
72 $year += 2000 if $year < 2000; #not y4k safe, oh shit
75 EPS_MERCHANT => 'login',
76 EPS_REFERENCEID => 'invoice_number',
77 EPS_CARDNUMBER => 'card_number',
78 EPS_CARDTYPE => \$cardtype,
79 EPS_EXPIRYMONTH => \$month,
80 EPS_EXPIRYYEAR => \$year,
81 EPS_NAMEONCARD => 'name',
82 EPS_AMOUNT => 'amount',
85 EPS_TEST => \( $self->test_transaction() ? 'true' : 'false' ),
87 %content = $self->content;
89 warn "content:$_ => $content{$_}\n" foreach keys %content;
92 if ($self->transaction_type() eq 'CC' ) {
93 $self->required_fields(qw/type action amount card_number expiration/);
95 croak("eSec can't handle transaction type: ".
96 $self->transaction_type());
99 my %post_data = $self->get_fields( map "EPS_$_", qw(
100 MERCHANT REFERENCEID CARDNUMBER CARDTYPE EXPIRYMONTH EXPIRYYEAR
101 NAMEONCARD AMOUNT CCV VERSION TEST
104 warn "post_data:$_ => $post_data{$_}\n" foreach keys %post_data;
107 my $pd = make_form(%post_data);
108 my $server = $self->server();
109 my $port = $self->port();
110 my $path = $self->path();
111 my($page,$server_response,%headers) =
112 post_https($server,$port,$path,'',$pd);
114 my( $r, $a, $m, $s, $e ) =
115 map { /^\s*\w+\s*\=\s*(.*)$/; $1; } split("\n", $page);
117 if ( $m =~ /^200/ ) {
118 $self->is_success(1);
119 $self->result_code($e);
120 $self->authorization($a);
122 $self->is_success(0);
123 $self->result_code($e);
124 $self->error_message($m);
134 Business::OnlinePayment::eSec - eSec backend for Business::OnlinePayment
138 use Business::OnlinePayment;
140 my $tx = new Business::OnlinePayment("eSec");
143 login => 'test', #EPS_MERCHANT
144 action => 'Authorization Only',
145 description => 'Business::OnlinePayment test',
147 invoice_number => '100100',
148 name => 'Tofu Beast',
149 card_number => '4007000000027',
150 expiration => '09/02',
154 if($tx->is_success()) {
155 print "Card processed successfully: ".$tx->authorization."\n";
157 print "Card was rejected: ".$tx->error_message."\n";
162 For detailed information see L<Business::OnlinePayment>.
168 This module implements eSec's API verison 2. See
169 http://www.esec.com.au/sep/content/eps_support/integrate/integrate_use.html
174 Ivan Kohler <ivan-esec@420.am>
178 perl(1). L<Business::OnlinePayment>.