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 ));
28 'MerchantID' => 'login',
29 'RegKey' => 'password',
31 # 'CreditAmount' => 'amount',
32 'AccountNo' => 'card_number',
33 'NameonAccount' => 'name',
34 'AVSADDR' => 'address',
38 'TransID' => 'order_number',
39 'TRANSROUTE' => 'routing_code',
42 #XXX also set required fields here...
44 my @required_fields = qw(login password);
45 my %content = $self->content();
46 my $action = $content{'action'};
47 my $url = $self->path;
49 $content{'type'} =~ /^(cc|visa|mastercard|american express|discover)$/i
52 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
53 $url .= 'processCC.asp';
56 $content{'REFID'} = int(rand(2**31));
59 $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
60 or croak "unparsable expiration ". $content{'expiration'};
61 my( $month, $year ) = ( $1, $2 );
62 #$month = '0'. $month if $month =~ /^\d$/;
63 $content{'CCMonth'} = $month;
64 $content{'CCYear'} = $year;
66 #push @required_fields, qw( amount card_numb
67 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
68 croak "Authorizaiton Only is not supported by Transaction Central";
69 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
70 croak "Post Authorizaiton is not supported by Transaction Central";
71 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
72 $url .= 'voidcreditcconline.asp';
74 $content{'CreditAmount'} = delete $content{'Amount'};
77 croak "Unknown action $action";
80 } elsif ( $content{'type'} =~ /^check$/i ) {
82 if ( $action =~ /^\s*normal\s*authorization\s*$/i ) {
83 $url .= 'processcheck.asp';
84 $content{'AccountNo'} = $content{'account_number'};
85 $content{'TRANSTYPE'} = $content{'account_type'} =~ /^s/i ? 'SA' : 'CK';
87 } elsif ( $action =~ /^\s*authorization\s*only\s*$/i ) {
88 croak "Authorizaiton Only is not supported by Transaction Central";
89 } elsif ( $action =~ /^\s*post\s*authorization\s*$/i ) {
90 croak "Post Authorizaiton is not supported by Transaction Central";
91 } elsif ( $action =~ /^\s*(void|credit)\s*$/i ) {
92 $url .= 'addckcreditupdtonline.asp';
94 croak "Unknown action $action";
98 croak 'Unknown type: '. $content{'type'};
101 $self->content(%content);
104 MerchantID RegKey Amount REFID AccountNo CCMonth CCYear NameonAccount
105 AVSADDR AVSZIP CCRURL CVV2 USER1 USER2 USER3 USER4 TrackData
107 DESCRIPTION DESCDATE TRANSTYPE TRANSROUTE
110 #my( $page, $response, %reply_headers ) =
111 my( $page, $response ) =
112 $self->https_post( $self->get_fields( @fields ) );
114 warn "\n" if $DEBUG > 1;
116 warn "response: $response\n";
117 # warn "reply headers: ".
118 # join(', ', map "$_ => $reply_headers{$_}", keys %reply_headers ). "\n";
120 warn "raw response: $page\n" if $DEBUG > 1;
122 my %return = map { /^(\w+)=(.*)$/ ? ( $1 => $2 ) : () } split(/&/, $page);
124 if ( $DEBUG ) { warn "$_ => $return{$_}\n" foreach keys %return; }
126 #$self->result_code( $return{'AVSCode'} );
127 $self->avs_code( $return{'AVSCode'} );
128 $self->cvv2_response( $return{'CVV2ResponseMsg'} );
130 if ( $return{'Auth'} =~ /^(\d+)$/ ) {
132 $self->is_success(1);
133 $self->authorization( $return{'Auth'} );
134 $self->order_number( $return{'TransID'} );
138 $self->is_success(0);
139 $self->error_message( $return{'Notes'} );
146 my($self, %map) = @_;
147 my %content = $self->content();
149 # warn "$_ = ". ( ref($map{$_})
151 # : $content{$map{$_}} ). "\n";
152 $content{$_} = ref($map{$_})
154 : $content{$map{$_}};
156 $self->content(%content);
165 Business::OnlinePayment::TransactionCentral - Transaction Central backend module for Business::OnlinePayment
169 use Business::OnlinePayment::TransactionCentral;
174 use Business::OnlinePayment;
177 # One step transaction, the simple case.
180 my $tx = new Business::OnlinePayment("Capstone");
183 login => '10011', #MerchantID
184 password => 'KK48NPYEJHMAH6DK', #Regkey
185 action => 'Normal Authorization',
186 description => 'Business::OnlinePayment test',
188 name => 'Tofu Beast',
189 address => '123 Anystreet',
193 phone => '420-867-5309',
194 email => 'tofu.beast@example.com',
195 card_number => '4012000000001',
196 expiration => '08/06',
197 cvv2 => '1234', #optional
201 if($tx->is_success()) {
202 print "Card processed successfully: ".$tx->authorization."\n";
204 print "Card was rejected: ".$tx->error_message."\n";
207 =head1 SUPPORTED TRANSACTION TYPES
209 =head2 CC, Visa, MasterCard, American Express, Discover
211 Content required: type, login, password, action, amount, card_number, expiration.
218 Net::SSLeay _or_ ( Crypt::SSLeay and LWP )
222 For detailed information see L<Business::OnlinePayment>.
228 Ivan Kohler <ivan-transactioncentral@420.am>
230 =head1 COPYRIGHT AND LICENSE
232 Copyright (C) 2006 by Ivan Kohler
234 This library is free software; you can redistribute it and/or modify
235 it under the same terms as Perl itself.
239 perl(1). L<Business::OnlinePayment>.