Revision history for Business-OnlinePayment-CardFortress
-0.01 Date/time
+0.01 unreleased
First version, released on an unsuspecting world.
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
+ 'Crypt::OpenSSL::RSA' => 0,
+ 'Business::OnlinePayment' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Business-OnlinePayment-CardFortress-*' },
use warnings;
use strict;
#use vars qw( $DEBUG $me );
+use MIME::Base64;
+use Crypt::OpenSSL::RSA;
our $VERSION = 0.01;
$self->build_subs(qw( order_number avs_code cvv2_response
response_page response_code response_headers
- card_token
+ card_token private_key
));
}
sub submit {
my $self = shift;
- $self->server('test.cardfortress.com');
+ $self->server('test.cardfortress.com') if $self->test_transaction;
- my ($page,$server_response,%headers) = $self->https_post($self->content);
+ my %content = $self->content;
+ $content{$_} = $self->$_() for qw( gateway gateway_login gateway_password );
- die $server_response unless $server_response =~ /^200/;
+ my ($page,$server_response,%headers) = $self->https_post(%content);
- my %response = {};
+ die "$server_response\n" unless $server_response =~ /^200/;
+
+ my %response = ();
#this encoding good enough? wfm... if something's easier for other
#languages they can always use a different URL
foreach my $line ( grep /^\w+=/, split(/\n/, $page) ) {
# response_headers()
# response_page()
+ #handle the challenge/response handshake
+ if ( $self->error_message eq '_challenge' ) { #XXX infinite loop protection?
+
+ die "no private key available" unless $self->private_key;
+
+ #decrypt the challenge with the private key
+ my $challenge = decode_base64($response{'card_challenge'});
+
+ #here is the hardest part to implement at each client side
+ my $rsa_priv = Crypt::OpenSSL::RSA->new_private_key($self->private_key);
+ my $response = $rsa_priv->decrypt($challenge);
+
+ #try the transaction again with the challenge response
+ # (B:OP could sure use a better way to alter one value)
+ my %content = $self->content;
+ $content{'card_response'} = encode_base64($response, '');
+ $self->content(%content);
+ $self->submit;
+ }
+
}
1;
'gateway' => 'ProcessingGateway',
'gateway_login' => 'gwlogin',
'gateway_password' => 'gwpass',
- 'private_key' => '/path/to/keyfile',
+ 'private_key' => $private_key_string,
);
$rx->content(
);
}
-TODO: {
- local $TODO = "Need to replace the boilerplate text";
-
not_in_file_ok(README =>
"The README is used..." => qr/The README is used/,
"'version information here'" => qr/to provide version information/,
module_boilerplate_ok('lib/Business/OnlinePayment/CardFortress.pm');
-
-}
-
use strict;
use warnings;
-use Test::More;
+use Test::More skip_all => "don't care about POD coverage right now";
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
--- /dev/null
+use Test::More tests => 4;
+use File::Slurp;
+use Business::OnlinePayment;
+
+my @opt = (
+ 'CardFortress',
+ 'gateway' => 'IPPay',
+ 'gateway_login' => 'TESTMERCHANT',
+ 'gateway_password' => '',,
+);
+
+my $tx = new Business::OnlinePayment(@opt);
+
+$tx->test_transaction(1);
+
+$tx->content(
+ type => 'VISA',
+ login => 'user',
+ password => 'secret',
+ action => 'Normal Authorization',
+ description => 'Business::OnlinePayment test',
+ amount => '49.95',
+ customer_id => 'tfb',
+
+ #have to specify both for now... maybe some auto-transforming later
+ name => 'Tofu Beast',
+ first_name => 'Tofu',
+ last_name => 'Beast',
+
+ address => '123 Anystreet',
+ city => 'Anywhere',
+ state => 'UT',
+ zip => '84058',
+ card_number => '4007000000027',
+ expiration => '09/12',
+ cvv2 => '1234', #optional (not stored)
+);
+$tx->submit();
+
+ok($tx->is_success, 'Transaction successful');
+warn $tx->error_message."\n" unless $tx->is_success;
+
+#use Data::Dumper; warn Dumper($tx);
+
+my $token = $tx->card_token;
+ok(length($token), 'Token returned');
+
+
+SKIP: {
+ my $private_key = read_file('t/private_key.txt') or skip 'no private key', 2;
+
+ like( $private_key, qr/-----BEGIN RSA PRIVATE KEY-----/, 'private key good' );
+
+ my $rx = new Business::OnlinePayment( @opt,
+ 'private_key' => $private_key,
+ );
+
+ $rx->test_transaction(1);
+
+ $rx->content(
+ type => 'VISA',
+ login => 'user',
+ password => 'secret',
+ action => 'Normal Authorization',
+ description => 'Business::OnlinePayment test',
+ amount => '12.95',
+ #card_token => $token
+ card_number => $token,
+ );
+ $rx->submit();
+
+ ok($rx->is_success, 'Token transaction successful');
+
+ #use Data::Dumper; warn Dumper($rx);
+
+}
+