1 package Business::OnlinePayment::TransactionCentral;
6 use Business::OnlinePayment 3;
7 use Business::OnlinePayment::HTTPS 0.02;
8 use vars qw($VERSION @ISA $DEBUG);
10 @ISA = qw(Business::OnlinePayment::HTTPS);
17 $self->server('webservices.primerchants.com');
19 $self->path('/billing/TransactionCentral/');
21 $self->build_subs(qw( order_number avs_code cvv2_response
22 response_page response_code response_headers
30 'MerchantID' => 'login',
31 'RegKey' => 'password',
33 # 'CreditAmount' => 'amount',
34 'AccountNo' => 'card_number',
35 'NameonAccount' => 'name',
36 'AVSADDR' => 'address',
41 'TransID' => 'order_number',
42 'TRANSROUTE' => 'routing_code',
45 #XXX also set required fields here...
47 my @required_fields = qw(login password);
48 my %content = $self->content();
49 my $action = $content{'action'};
50 my $url = $self->path;
52 $content{'type'} =~ /^(cc|visa|mastercard|american express|discover)$/i
55 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
56 $url .= 'processCC.asp';
59 $content{'REFID'} = int(rand(2**31));
62 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
63 or croak "unparsable expiration ". $content{'expiration'};
64 my( $month, $year ) = ( $1, $2 );
65 $month = '0'. $month if $month =~ /^\d$/;
66 $content{'CCMonth'} = $month;
67 $content{'CCYear'} = $year;
69 push @required_fields, qw( amount card_number expiration
73 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
74 croak "Authorizaiton Only is not supported by Transaction Central";
75 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
76 croak "Post Authorizaiton is not supported by Transaction Central";
77 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
78 $url .= 'voidcreditcconline.asp';
80 $content{'CreditAmount'} = delete $content{'Amount'};
83 croak "Unknown action $action";
86 } elsif ( $content{'type'} =~ /^e?check$/i ) {
88 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
89 $url .= 'processcheckonline.asp';
90 $content{'AccountNo'} = $content{'account_number'};
91 $content{'TRANSTYPE'} =
92 ( exists($content{account_type}) && $content{account_type} =~ /^s/i )
96 push @required_fields, qw( amount account_number routing_code
100 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
101 croak "Authorizaiton Only is not supported by Transaction Central";
102 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
103 croak "Post Authorizaiton is not supported by Transaction Central";
104 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
105 $url .= 'addckcreditupdtonline.asp';
107 croak "Unknown action $action";
111 croak 'Unknown type: '. $content{'type'};
114 $self->content(%content);
116 $self->required_fields(@required_fields);
119 MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount
120 AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData
122 DESCRIPTION DESCDATE TRANSTYPE TRANSROUTE
125 my( $page, $response, %reply_headers ) =
126 $self->https_post( $self->get_fields( @fields ) );
128 $self->response_code( $response );
129 $self->response_page( $page );
130 $self->response_headers( \%reply_headers );
132 #trim off <html><body> </body></html> around the response we want
133 $page =~ s/^[\s\n]*<html>[\s\n]*<body>[\s\n]*//;
134 $page =~ s/[\s\n]*<\/body>[\s\n]*<\/html>[\s\n]*$//;
136 my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page);
138 if ( $DEBUG ) { warn "$_ => $return{$_}\n" foreach keys %return; }
140 #$self->result_code( $return{'AVSCode'} );
141 $self->avs_code( $return{'AVSCode'} );
142 $self->cvv2_response( $return{'CVV2ResponseMsg'} );
144 if ( $return{'Auth'} =~ /^\s*(\w+)\s*$/ && lc($1) ne 'declined' ) {
146 $self->is_success(1);
147 $self->authorization( $return{'Auth'} );
148 $self->order_number( $return{'TransID'} );
152 $self->is_success(0);
153 $self->error_message( $return{'Notes'} );
160 my($self, %map) = @_;
161 my %content = $self->content();
163 # warn "$_ = ". ( ref($map{$_})
165 # : $content{$map{$_}} ). "\n";
166 $content{$_} = ref($map{$_})
168 : $content{$map{$_}};
170 $self->content(%content);
179 Business::OnlinePayment::TransactionCentral - Transaction Central backend module for Business::OnlinePayment
183 use Business::OnlinePayment;
186 # One step transaction, the simple case.
189 my $tx = new Business::OnlinePayment("TransactionCentral");
192 login => '10011', #MerchantID
193 password => 'KK48NPYEJHMAH6DK', #Regkey
194 action => 'Normal Authorization',
195 description => 'Business::OnlinePayment test',
197 name => 'Tofu Beast',
198 address => '123 Anystreet',
202 phone => '420-867-5309',
203 email => 'tofu.beast@example.com',
204 card_number => '4012000000001',
205 expiration => '08/06',
206 cvv2 => '1234', #optional
210 if($tx->is_success()) {
211 print "Card processed successfully: ".$tx->authorization."\n";
213 print "Card was rejected: ".$tx->error_message."\n";
217 This is a Business::OnlinePayment backend module for the Transaction Central
218 (MerchantAnywhere, PRIMerchants) gateway. It is only useful if you have a
219 merchant account with MerchantAnywhere / PRIMerchants:
221 http://www.merchantanywhere.com/
222 http://www.merchantanywhere.com/ecshop/TC_elink.htm
224 http://www.primerchants.com/
225 http://www.primerchants.com/info/transactioncentral.asp
227 =head1 SUPPORTED TRANSACTION TYPES
229 =head2 CC, Visa, MasterCard, American Express, Discover
231 Content required: type, login, password, action, amount, card_number, expiration, name, address, zip.
235 Content required: type, login, password, action, amount, account_number, routing_code, name
241 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
245 For detailed information see L<Business::OnlinePayment>.
249 The newest publicly available documentation is available at:
251 http://www.merchantanywhere.com/ecshop/TC%20Interface%20NEW.pdf
253 It is somewhat out-of-date and contains a few discrepancies. Google
254 "TCInterfaceGuide" for current documentation.
258 Ivan Kohler <ivan-transactioncentral@420.am>
260 =head1 COPYRIGHT AND LICENSE
262 Copyright (C) 2006 by Ivan Kohler
263 Copyright (C) 2007 Freeside Internet Services, Inc.
265 This library is free software; you can redistribute it and/or modify
266 it under the same terms as Perl itself.
270 perl(1). L<Business::OnlinePayment>.