1 package Business::OnlinePayment::CardFortress;
3 use base qw( Business::OnlinePayment::HTTPS );
7 #use vars qw( $DEBUG $me );
9 use Crypt::OpenSSL::RSA;
15 'info_version' => '0.01',
16 'module_version' => $VERSION,
17 'supported_types' => [ 'CC' ],
18 'supported_actions' => { 'CC' => [
19 'Normal Authorization',
26 'token_support' => 'challenge/response',
27 #need to figure out how to pass through for gateways that do... an option?
28 #'CC_void_requires_card' => 1,
36 $self->server('gw.cardfortress.com') unless $self->server;
38 $self->port('443') unless $self->port;
39 $self->path('/bop/index.html') unless $self->path;
41 $self->build_subs(qw( order_number avs_code cvv2_response
42 response_page response_code response_headers
43 card_token private_key
50 $self->server('test.cardfortress.com') if $self->test_transaction;
52 my %content = $self->content;
53 $content{$_} = $self->$_() for qw( gateway gateway_login gateway_password );
55 my ($page,$server_response,%headers) = $self->https_post(%content);
57 die "$server_response\n" unless $server_response =~ /^200/;
60 #this encoding good enough? wfm... if something's easier for other
61 #languages they can always use a different URL
62 foreach my $line ( grep /^\w+=/, split(/\n/, $page) ) {
63 $line =~ /^(\w+)=(.*)$/ or next;
67 foreach (qw( is_success error_message failure_status
68 authorization order_number
69 fraud_score fraud_transaction_id
70 result_code avs_code cvv2_response
73 $self->$_($response{$_});
76 #map these to gateway_response_code, etc?
81 #handle the challenge/response handshake
82 if ( $self->error_message eq '_challenge' ) { #XXX infinite loop protection?
84 die "no private key available" unless $self->private_key;
86 #decrypt the challenge with the private key
87 my $challenge = decode_base64($response{'card_challenge'});
89 #here is the hardest part to implement at each client side
90 my $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($self->private_key);
91 my $response = $rsa_priv->decrypt($challenge);
93 #try the transaction again with the challenge response
94 # (B:OP could sure use a better way to alter one value)
95 my %content = $self->content;
96 $content{'card_response'} = encode_base64($response, '');
97 $self->content(%content);
109 Business::OnlinePayment::CardFortress - CardFortress backend for Business::OnlinePayment
113 use Business::OnlinePayment;
115 my $tx = new Business::OnlinePayment( 'CardFortress',
116 'gateway' => 'ProcessingGateway',
117 'gateway_login' => 'gwlogin',
118 'gateway_password' => 'gwpass',
119 #private_key not necessary
124 login => 'cardfortress_login',
125 password => 'cardfortress_pass',
126 action => 'Normal Authorization',
127 description => 'Business::OnlinePayment test',
129 customer_id => 'tfb',
130 name => 'Tofu Beast',
131 address => '123 Anystreet',
135 card_number => '4007000000027',
136 expiration => '09/02',
137 cvv2 => '1234', #optional (not stored)
141 if($tx->is_success()) {
142 print "Card processed successfully: ".$tx->authorization."\n";
143 $token = $tx->card_token;
144 print "Card token is: $token\n";
146 print "Card was rejected: ".$tx->error_message."\n";
149 # ... time slips by ...
151 my $rx = new Business::OnlinePayment( 'CardFortress',
152 'gateway' => 'ProcessingGateway',
153 'gateway_login' => 'gwlogin',
154 'gateway_password' => 'gwpass',
155 'private_key' => $private_key_string,
160 login => 'cardfortress_login',
161 password => 'cardfortress_pass',
162 action => 'Normal Authorization',
163 description => 'Business::OnlinePayment test',
165 card_token => $card_token
166 cvv2 => '1234', #optional, typically not necessary w/followup tx
172 This is a Business::OnlinePayment backend module for the gateway-independent
173 CardFortress storage service (http://cardfortress.com/).
175 =head1 SUPPORTED TRANSACTION TYPES
177 =head2 CC, Visa, MasterCard, American Express, Discover
179 Content required: type, login, action, amount, card_number, expiration.
181 =head1 METHODS AND FUNCTIONS
183 See L<Business::OnlinePayment> for the complete list. The following methods either override the methods in L<Business::OnlinePayment> or provide additional functions.
187 Returns the card token for any transaction. The card token can be used in
188 a subsequent transaction as a replacement for the card number and expiration
189 (as well as customer/AVS data).
193 Returns the response error code.
197 Returns the response error description text.
199 =head2 server_response
201 Returns the complete response from the server.
205 Ivan Kohler C<< <ivan-bop-cardfortress at freeside.biz> >>
207 =head1 COPYRIGHT & LICENSE
209 Copyright 2008-2010 Freeside Internet Services, Inc. (http://freeside.biz/)
212 This program is free software; you can redistribute it and/or modify it
213 under the same terms as Perl itself.