specify the private key as a string or a filename
authorivan <ivan>
Tue, 25 May 2010 09:53:14 +0000 (09:53 +0000)
committerivan <ivan>
Tue, 25 May 2010 09:53:14 +0000 (09:53 +0000)
lib/Business/OnlinePayment/CardFortress.pm

index 1946624..db6f422 100644 (file)
@@ -5,6 +5,7 @@ use base qw( Business::OnlinePayment::HTTPS );
 use warnings;
 use strict;
 #use vars qw( $DEBUG $me );
+use File::Slurp;
 use MIME::Base64;
 use Crypt::OpenSSL::RSA;
 
@@ -23,7 +24,7 @@ sub _info {
                                        'Credit',
                                      ],
                            },
-    'token_support'     => 'challenge/response',
+    'token_support'     => 1,
     #need to figure out how to pass through for gateways that do... an option?
     #'CC_void_requires_card' => 1,
   };
@@ -81,7 +82,11 @@ sub submit {
   #handle the challenge/response handshake
   if ( $self->error_message eq '_challenge' ) { #XXX infinite loop protection?
 
-    die "no private key available" unless $self->private_key;
+    my $private_key = $self->private_key
+      or die "no private key available";
+
+    $private_key = read_file($private_key)
+      if $private_key !~ /-----BEGIN/ && -r $private_key;
 
     #decrypt the challenge with the private key
     my $challenge = decode_base64($response{'card_challenge'});
@@ -112,12 +117,13 @@ Business::OnlinePayment::CardFortress - CardFortress backend for Business::Onlin
 
   use Business::OnlinePayment;
 
-  my $tx = new Business::OnlinePayment( 'CardFortress',
-                                          'gateway' => 'ProcessingGateway',
-                                          'gateway_login' => 'gwlogin',
-                                          'gateway_password' => 'gwpass',
-                                          #private_key not necessary
-                                      );
+  my $tx = new Business::OnlinePayment(
+    'CardFortress',
+      'gateway'          => 'ProcessingGateway',
+      'gateway_login'    => 'gwlogin',
+      'gateway_password' => 'gwpass',
+      #private_key not necessary
+  );
 
   $tx->content(
       type           => 'VISA',
@@ -148,12 +154,13 @@ Business::OnlinePayment::CardFortress - CardFortress backend for Business::Onlin
 
   # ... time slips by ...
 
-  my $rx = new Business::OnlinePayment( 'CardFortress',
-                                          'gateway' => 'ProcessingGateway',
-                                          'gateway_login' => 'gwlogin',
-                                          'gateway_password' => 'gwpass',
-                                          'private_key' => $private_key_string,
-                                      );
+  my $rx = new Business::OnlinePayment(
+    'CardFortress',
+      'gateway'          => 'ProcessingGateway',
+      'gateway_login'    => 'gwlogin',
+      'gateway_password' => 'gwpass',
+      'private_key'      => $private_key_string, #or filename
+  );
 
   $rx->content(
       type           => 'VISA',