1 package Business::BatchPayment::CardFortress;
10 Business::BatchPayment::CardFortress
14 Batch payment processing via the CardFortress secure payment proxy service.
18 See Business::BatchPayment for general usage information.
20 =head2 PROCESSOR ATTRIBUTES
26 Your login credentials for CardFortress.
30 The L<Business::BatchPayment> module to use for upstream processing. You
31 don't need to have this module installed, but the proxy server does.
35 Processor options to pass along to the gateway module. The 'gateway_' prefix
42 use Business::BatchPayment;
44 with 'Business::BatchPayment::Processor';
45 with 'Business::BatchPayment::TestMode';
46 with 'Business::BatchPayment::Debug';
50 has [ qw(login password private_key gateway) ] => (
56 has 'gateway_opts' => (
59 default => sub { {login => ''} },
65 handles => [qw(serialize deserialize)],
67 # doesn't have to be Storable, but it must support blessed objects
68 Data::Serializer->new(serializer => 'Storable', encoding => 'b64')
72 # pull any arg named "gateway_foo" into gateway_opts
73 around 'BUILDARGS' => sub {
74 my ($orig, $class, %args) = @_;
75 foreach (keys %args) {
76 if (/^gateway_(.*)/) {
77 $args{'gateway_opts'}->{$1} = delete $args{$_};
83 sub default_transport {
85 Business::BatchPayment->create('CardFortress::Transport',
86 login => $self->login,
87 password => $self->password,
88 debug => $self->debug,
89 test_mode => $self->test_mode,
90 private_key => $self->private_key,
91 serializer => $self->serializer,
98 bless $batch, 'Business::BatchPayment::CardFortress::Batch';
99 # things that get encoded in the batch:
100 $batch->gateway($self->gateway);
101 $batch->gateway_opts($self->gateway_opts);
102 $self->serialize($batch); # that's all folks
108 my $batch = $self->deserialize($input);
111 package Business::BatchPayment::CardFortress::Batch;
114 extends 'Business::BatchPayment::Batch';
120 has 'gateway_opts' => (
125 package Business::BatchPayment::CardFortress::Transport;
128 use Moose::Util::TypeConstraints;
129 extends 'Business::BatchPayment::Transport::HTTPS';
130 with 'Business::BatchPayment::TestMode';
134 use Crypt::OpenSSL::RSA;
139 $self->test_mode ? 'gw.cardfortress.com'
140 : 'test.cardfortress.com'
145 has ['login', 'password', 'private_key'] => (isa => 'Str', is => 'rw');
147 has 'serializer' => ( handles => [qw(serialize deserialize)] );
150 my ($self, $content) = @_;
151 warn "Sending batch...\n" if $self->debug;
152 my ($page, $response, %reply_headers) =
153 $self->https_post('/batch/submit', {
154 login => $self->login,
155 password => $self->password,
158 $page = $self->deserialize($page);
159 die $page->{error} if $page->{error};
160 my $batchid = $page->{batchid};
162 my $private_key = read_file($self->private_key)
163 or die "No private key available";
164 my $rsa = Crypt::OpenSSL::RSA->new_private_key($private_key);
167 foreach my $item (@{ $page->{items} }) {
168 if ( $item->{error} ) {
169 # We have no reliable way to report an error in a specific transaction
170 # at this stage. The server will send the error in the reply batch.
171 # For now do nothing.
172 } elsif ( $item->{challenge} ) {
173 my $challenge = $item->{challenge};
174 $answers{ $item->{tid} } = $rsa->decrypt( decode_base64($challenge) );
176 # newly created card--doesn't have a challenge, so do nothing
180 warn "Answering cryptographic challenge...\n" if $self->debug;
182 $self->serialize({ batchid => $batchid, answers => \%answers });
183 ($page, $response, %reply_headers) =
184 $self->https_post('/batch/run', {
185 login => $self->login,
186 password => $self->password,
187 content => $answer_content,
189 $page = $self->deserialize($page);
190 die $page->{error} if $page->{error};
196 Mark Wells, C<< <mark at freeside.biz> >>
200 You can find documentation for this module with the perldoc command.
202 perldoc Business::BatchPayment::CardFortress
204 Commercial support is available from Freeside Internet Services, Inc.
206 L<http://www.freeside.biz>
208 =head1 ACKNOWLEDGEMENTS
210 =head1 LICENSE AND COPYRIGHT
212 Copyright 2012 Mark Wells.
214 This program is free software; you can redistribute it and/or modify it
215 under the terms of either: the GNU General Public License as published
216 by the Free Software Foundation; or the Artistic License.
218 See http://dev.perl.org/licenses/ for more information.
223 1; # End of Business::BatchPayment::Paymentech