1package Business::OnlinePayment::PayConnect; 2 3use strict; 4use Carp; 5use Business::OnlinePayment; 6#use Business::CreditCard; 7use Net::SSLeay qw( make_form post_https get_https make_headers ); 8use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $DEBUG); 9 10require Exporter; 11 12@ISA = qw(Exporter AutoLoader Business::OnlinePayment); 13@EXPORT = qw(); 14@EXPORT_OK = qw(); 15$VERSION = '0.02'; 16 17$DEBUG = 0; 18 19sub set_defaults { 20 my $self = shift; 21 22 #test 23 $self->server('zavijah.e-ebi.net'); 24 $self->port('443'); 25 $self->path('/rtv/servlet/aio'); 26 27 $self->build_subs(qw( partner )); 28} 29 30sub revmap_fields { 31 my($self, %map) = @_; 32 my %content = $self->content(); 33 foreach(keys %map) { 34 $content{$_} = ref($map{$_}) 35 ? ${ $map{$_} } 36 : $content{$map{$_}}; 37 } 38 $self->content(%content); 39} 40 41sub submit { 42 my $self = shift; 43 my %content = $self->content(); 44 45 my $action = lc($content{'action'}); 46 if ( $action eq 'authorization only' ) { 47 } else { 48 croak "$action not (yet) supported"; 49 } 50 51 my $type = lc($content{'type'}); 52 if ( $type eq 'lec' ) { 53 } else { 54 croak "$type not (yet) supported"; 55 } 56 57 $content{'zip'} =~ s/\D//g; 58 $content{'zip'} =~ /^(\d{5})(\d*)$/; 59 my($zip, $zip4) = ($1, $2); 60 61 my $phone = $content{'phone'}; 62 $phone =~ s/\D//g; 63 64 $self->revmap_fields( 65 ebiinfo => \'AIO-1.0', 66 clientid => 'login', 67 password => 'password', 68 partner => \($self->partner()), 69 #sysid 70 transtype => \'A', #action 71 paytype => \'lec', #type 72 trackid => 'invoice_number', 73 acctid => 'customer_id', 74 billname => 'name', 75 billaddr1 => 'address', 76 #billaddr2 => 77 billcity => 'city', 78 billstate => 'state', 79 billzip => \$zip, 80 billzip4 => \$zip4, 81 amt => 'amount', 82 83 #LEC 84 #ani 85 btn => \$phone, 86 #dni 87 #traffic 88 #planid 89 #pincode 90 ); 91 92 my %post_data = $self->get_fields(qw( 93 ebiinfo clientid password partner transtype paytype trackid acctid 94 billname billaddr1 billcity billstate billzip billzip4 amt btn 95 )); 96 97 my $s = $self->server(); 98 my $p = $self->port(); 99 my $t = $self->path(); 100 101 my $pd = make_form(%post_data); 102 my($page,$server_response,%headers) = post_https($s,$p,$t,'',$pd); 103 104 $page =~ s/\r*\n*$//; 105 106 #warn join('-',%headers); 107 #warn $page; 108 my %response = map { split('=',$_,2) } split(/\|/,$page); 109 #warn "$_: $response{$_}\n" foreach keys %response; 110 111 if ( $response{'response'} eq '0000' ) { 112 $self->is_success(1); 113 $self->result_code('0000'); 114 $self->authorization($response{'trackid'}); 115 } else { 116 $self->is_success(0); 117 $self->result_code($response{'response'}); 118 $self->error_message($response{'respmsg'}); 119 } 120 121} 122 1231; 124__END__ 125 126=head1 NAME 127 128Business::OnlinePayment::PayConnect - PaymentOne (formerly eBillit) PayConnect backend for Business::OnlinePayment 129 130=head1 SYNOPSIS 131 132 use Business::OnlinePayment; 133 134 my $tx = new Business::OnlinePayment("PayConnect", 135 'partner' => '', 136 ); 137 $tx->content( 138 type => 'LEC', 139 login => 'test', #ClientID 140 password => 'test', 141 action => 'Authorization Only', 142 description => 'Business::OnlinePayment test', 143 amount => '49.95', 144 invoice_number => '100100', 145 name => 'Tofu Beast', 146 phone => '4155554321', 147 ); 148 $tx->submit(); 149 150 if($tx->is_success()) { 151 print "LEC billing authorized successfully: ".$tx->authorization."\n"; 152 } else { 153 print "LEC billing was rejected: ".$tx->error_message."\n"; 154 } 155 156=head1 DESCRIPTION 157 158For detailed information see L<Business::OnlinePayment>. 159 160=head1 NOTE 161 162This module only implements 'LEC' (phone bill billing) functionality at this 163time. Credit card and ACH transactions are not (yet) supported. 164 165=head1 COMPATIBILITY 166 167This module implements an interface the "HTTPS AIO Validation Protocol 168version 3.0" of PaymentOne (formerly eBillit) PayConnect 169<http://www.paymentone.com/products/paycon.asp>. Unfortunately, no 170documentation is publicly available. 171 172=head1 AUTHOR 173 174Ivan Kohler <ivan-payconnect@420.am> 175 176=head1 SEE ALSO 177 178perl(1). L<Business::OnlinePayment> 179 180=cut 181 182