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',
40 'TransID' => 'order_number',
41 'TRANSROUTE' => 'routing_code',
44 #XXX also set required fields here...
46 my @required_fields = qw(login password);
47 my %content = $self->content();
48 my $action = $content{'action'};
49 my $url = $self->path;
51 $content{'type'} =~ /^(cc|visa|mastercard|american express|discover)$/i
54 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
55 $url .= 'processCC.asp';
58 $content{'REFID'} = int(rand(2**31));
61 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
62 or croak "unparsable expiration ". $content{'expiration'};
63 my( $month, $year ) = ( $1, $2 );
64 $month = '0'. $month if $month =~ /^\d$/;
65 $content{'CCMonth'} = $month;
66 $content{'CCYear'} = $year;
68 push @required_fields, qw( amount card_number expiration
72 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
73 croak "Authorizaiton Only is not supported by Transaction Central";
74 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
75 croak "Post Authorizaiton is not supported by Transaction Central";
76 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
77 $url .= 'voidcreditcconline.asp';
79 $content{'CreditAmount'} = delete $content{'Amount'};
82 croak "Unknown action $action";
85 } elsif ( $content{'type'} =~ /^e?check$/i ) {
87 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
88 $url .= 'processcheckonline.asp';
89 $content{'AccountNo'} = $content{'account_number'};
90 $content{'TRANSTYPE'} =
91 ( exists($content{account_type}) && $content{account_type} =~ /^s/i )
95 push @required_fields, qw( amount account_number routing_code
99 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
100 croak "Authorizaiton Only is not supported by Transaction Central";
101 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
102 croak "Post Authorizaiton is not supported by Transaction Central";
103 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
104 $url .= 'addckcreditupdtonline.asp';
106 croak "Unknown action $action";
110 croak 'Unknown type: '. $content{'type'};
113 $self->content(%content);
115 $self->required_fields(@required_fields);
118 MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount
119 AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData
121 DESCRIPTION DESCDATE TRANSTYPE TRANSROUTE
124 my( $page, $response, %reply_headers ) =
125 $self->https_post( $self->get_fields( @fields ) );
127 $self->response_code( $response );
128 $self->response_page( $page );
129 $self->response_headers( \%reply_headers );
131 #trim off <html><body> </body></html> around the response we want
132 $page =~ s/^[\s\n]*<html>[\s\n]*<body>[\s\n]*//;
133 $page =~ s/[\s\n]*<\/body>[\s\n]*<\/html>[\s\n]*$//;
135 my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page);
137 if ( $DEBUG ) { warn "$_ => $return{$_}\n" foreach keys %return; }
139 #$self->result_code( $return{'AVSCode'} );
140 $self->avs_code( $return{'AVSCode'} );
141 $self->cvv2_response( $return{'CVV2ResponseMsg'} );
143 if ( $return{'Auth'} =~ /^\s*(\w+)\s*$/ ) {
145 $self->is_success(1);
146 $self->authorization( $return{'Auth'} );
147 $self->order_number( $return{'TransID'} );
151 $self->is_success(0);
152 $self->error_message( $return{'Notes'} );
159 my($self, %map) = @_;
160 my %content = $self->content();
162 # warn "$_ = ". ( ref($map{$_})
164 # : $content{$map{$_}} ). "\n";
165 $content{$_} = ref($map{$_})
167 : $content{$map{$_}};
169 $self->content(%content);
178 Business::OnlinePayment::TransactionCentral - Transaction Central backend module for Business::OnlinePayment
182 use Business::OnlinePayment;
185 # One step transaction, the simple case.
188 my $tx = new Business::OnlinePayment("TransactionCentral");
191 login => '10011', #MerchantID
192 password => 'KK48NPYEJHMAH6DK', #Regkey
193 action => 'Normal Authorization',
194 description => 'Business::OnlinePayment test',
196 name => 'Tofu Beast',
197 address => '123 Anystreet',
201 phone => '420-867-5309',
202 email => 'tofu.beast@example.com',
203 card_number => '4012000000001',
204 expiration => '08/06',
205 cvv2 => '1234', #optional
209 if($tx->is_success()) {
210 print "Card processed successfully: ".$tx->authorization."\n";
212 print "Card was rejected: ".$tx->error_message."\n";
216 This is a Business::OnlinePayment backend module for the Transaction Central
217 (MerchantAnywhere, PRIMerchants) gateway. It is only useful if you have a
218 merchant account with MerchantAnywhere / PRIMerchants:
220 http://www.merchantanywhere.com/
221 http://www.merchantanywhere.com/ecshop/TC_elink.htm
223 http://www.primerchants.com/
224 http://www.primerchants.com/info/transactioncentral.asp
226 =head1 SUPPORTED TRANSACTION TYPES
228 =head2 CC, Visa, MasterCard, American Express, Discover
230 Content required: type, login, password, action, amount, card_number, expiration, name, address, zip.
234 Content required: type, login, password, action, amount, account_number, routing_code, name
240 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
244 For detailed information see L<Business::OnlinePayment>.
248 The newest publicly available documentation is available at:
250 http://www.merchantanywhere.com/ecshop/TC%20Interface%20NEW.pdf
252 It is somewhat out-of-date and contains a few discrepancies. Google
253 "TCInterfaceGuide" for current documentation.
257 Ivan Kohler <ivan-transactioncentral@420.am>
259 =head1 COPYRIGHT AND LICENSE
261 Copyright (C) 2006 by Ivan Kohler
262 Copyright (C) 2007 Freeside Internet Services, Inc.
264 This library is free software; you can redistribute it and/or modify
265 it under the same terms as Perl itself.
269 perl(1). L<Business::OnlinePayment>.