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_numb
69 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
70 croak "Authorizaiton Only is not supported by Transaction Central";
71 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
72 croak "Post Authorizaiton is not supported by Transaction Central";
73 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
74 $url .= 'voidcreditcconline.asp';
76 $content{'CreditAmount'} = delete $content{'Amount'};
79 croak "Unknown action $action";
82 } elsif ( $content{'type'} =~ /^check$/i ) {
84 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
85 $url .= 'processcheck.asp';
86 $content{'AccountNo'} = $content{'account_number'};
87 $content{'TRANSTYPE'} = $content{'account_type'} =~ /^s/i ? 'SA' : 'CK';
89 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
90 croak "Authorizaiton Only is not supported by Transaction Central";
91 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
92 croak "Post Authorizaiton is not supported by Transaction Central";
93 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
94 $url .= 'addckcreditupdtonline.asp';
96 croak "Unknown action $action";
100 croak 'Unknown type: '. $content{'type'};
103 $self->content(%content);
106 MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount
107 AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData
109 DESCRIPTION DESCDATE TRANSTYPE TRANSROUTE
112 my( $page, $response, %reply_headers ) =
113 $self->https_post( $self->get_fields( @fields ) );
115 $self->response_code( $response );
116 $self->response_page( $page );
117 $self->response_headers( \%reply_headers );
119 warn "\n" if $DEBUG > 1;
121 warn "response: $response\n";
122 # warn "reply headers: ".
123 # join(', ', map "$_ => $reply_headers{$_}", keys %reply_headers ). "\n";
125 warn "raw response: $page\n" if $DEBUG > 1;
127 my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page);
129 if ( $DEBUG ) { warn "$_ => $return{$_}\n" foreach keys %return; }
131 #$self->result_code( $return{'AVSCode'} );
132 $self->avs_code( $return{'AVSCode'} );
133 $self->cvv2_response( $return{'CVV2ResponseMsg'} );
135 if ( $return{'Auth'} =~ /^(\w+)$/ ) {
137 $self->is_success(1);
138 $self->authorization( $return{'Auth'} );
139 $self->order_number( $return{'TransID'} );
143 $self->is_success(0);
144 $self->error_message( $return{'Notes'} );
151 my($self, %map) = @_;
152 my %content = $self->content();
154 # warn "$_ = ". ( ref($map{$_})
156 # : $content{$map{$_}} ). "\n";
157 $content{$_} = ref($map{$_})
159 : $content{$map{$_}};
161 $self->content(%content);
170 Business::OnlinePayment::TransactionCentral - Transaction Central backend module for Business::OnlinePayment
174 use Business::OnlinePayment::TransactionCentral;
179 use Business::OnlinePayment;
182 # One step transaction, the simple case.
185 my $tx = new Business::OnlinePayment("TransactionCentral");
188 login => '10011', #MerchantID
189 password => 'KK48NPYEJHMAH6DK', #Regkey
190 action => 'Normal Authorization',
191 description => 'Business::OnlinePayment test',
193 name => 'Tofu Beast',
194 address => '123 Anystreet',
198 phone => '420-867-5309',
199 email => 'tofu.beast@example.com',
200 card_number => '4012000000001',
201 expiration => '08/06',
202 cvv2 => '1234', #optional
206 if($tx->is_success()) {
207 print "Card processed successfully: ".$tx->authorization."\n";
209 print "Card was rejected: ".$tx->error_message."\n";
212 =head1 SUPPORTED TRANSACTION TYPES
214 =head2 CC, Visa, MasterCard, American Express, Discover
216 Content required: type, login, password, action, amount, card_number, expiration.
223 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
227 For detailed information see L<Business::OnlinePayment>.
233 Ivan Kohler <ivan-transactioncentral@420.am>
235 =head1 COPYRIGHT AND LICENSE
237 Copyright (C) 2006 by Ivan Kohler
239 This library is free software; you can redistribute it and/or modify
240 it under the same terms as Perl itself.
244 perl(1). L<Business::OnlinePayment>.