Business-OnlinePayment-StoredTransaction
view release on metacpan or search on metacpan
lib/Business/OnlinePayment/StoredTransaction/Unstore.pm view on Meta::CPAN
our @ISA = qw();
our @EXPORT_OK = ();
our @EXPORT = ();
our $VERSION = '0.01';
#takes private RSA key and string returned by StoredTransaction->authorization
#takes arguments (private_key => $privkey, authorization => $auth)
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {
@_,
};
bless $self, $class;
croak "missing 'private_key'" unless $self->{'private_key'};
my $privkey = $self->{'private_key'};
croak "missing 'authorization'" unless $self->{'authorization'};
croak "bad authorization" unless $self->{'authorization'} =~ /:/;
my ($seckey, $ciphertext) = split /:/, $self->{'authorization'};
$seckey = decode_base64($seckey);
$ciphertext = decode_base64($ciphertext);
my $rsa_priv;
eval {$rsa_priv = Crypt::OpenSSL::RSA->new_private_key($privkey)};
croak $@ if $@;
eval {$seckey = $rsa_priv->decrypt($seckey)};
croak $@ if $@;
my $cipher = Crypt::CBC->new( {'key' => $seckey,
'cipher' => 'Blowfish',
});
my $plaintext = $cipher->decrypt($ciphertext);
croak "no plaintext" unless $plaintext;
my $data = Storable::thaw($plaintext);
$self->{data} = $data;
lib/Business/OnlinePayment/StoredTransaction/Unstore.pm view on Meta::CPAN
=head1 NAME
Business::OnlinePayment::StoredTransaction::Unstore - Perl extension for
retrieval of credit card details stored using
Business::OnlinePayment::StoredTransaction
=head1 SYNOPSIS
use Business::OnlinePayment::StoredTransaction::Unstore;
my $bitz = Business::OnlinePayment::StoredTransaction::Unstore->new(
private_key => '-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDqCih9AmZurFhxoOEsoIpL7wHnA0vi8eopVGfJiFSXldnemIxC
UY8tdk0hXSUwtEogQ2yeFB8+Wsl4S0oStFb2kGPrH2cDF9UjWTWFMjvE+4GO0Asz
q3Ek0gnAQazVs89AjFlDuaDiCGHryhIprbA7wbZVWmCQKyXcCavSgf0Y0QIDAP//
AoGABlQEpEXw4vbz6yZwvRGkTunpSxRV5ZzIHZ4x3JjYQmGDoZRpf0SLz5p+eGFp
HtY+x1YaCfA9OIDU62GUhk3+l+QIuhjV0/2cnAQ8x81r82zmbioWcmkAyLYKrkgS
mKJHfWB2u7YRnTJLTPQ03GnTTNSJvxCRm9ns3xCJbe4dig8CQQD9ZMYMSRynzRXT
ri/yvEepml/Evs7M1aRsnGW19VddPi2HEFlbuHUiHxN661wH14fovMQfHyLHjRa4
GL9HovzLAkEA7HJsI1YTixoyjz4BXPLGksToA77EbZQIBA8f+p+4K/gRJXM1lkPb
LQlAMkVmpW3wWI23iqKdTqVRypZXUYYJUwJASNd7wc3aGZqOy8tTNdMTULVgEveI
e+w50y58b124/de4gBbUNrDp5Lvhnmw8fcGTpBu/YE2clgeFumtfj6BK2QJBAMPB
makepubprivkey.pl view on Meta::CPAN
use Crypt::OpenSSL::RSA;
#This will print out a public and private RSA key suitable for use by
#Business::OnlinePayment::StoredTransaction
$rsa = Crypt::OpenSSL::RSA->generate_key(1024); # or
print "private key is:\n", $rsa->get_private_key_string();
print "public key (in PKCS1 format) is:\n",
$rsa->get_public_key_string();
t/Business-OnlinePayment-StoredTransaction.t view on Meta::CPAN
qkO/USX24l9TfRa0S+zPCnvgjnzEjBTsH6eF2S/wK2K5
-----END RSA PRIVATE KEY-----';
my ($key, $cipher) = split /:/, $auth;
$cipher = decode_base64($cipher);
$key = decode_base64($key);
ok($cipher, 'better have some data');
ok($key, 'better have some data here too');
my $rsa_priv;
eval {$rsa_priv = Crypt::OpenSSL::RSA->new_private_key($privkey)};
ok(!$@, 'looks like a valid private key');
my $seckey;
eval {$seckey = $rsa_priv->decrypt($key)};
ok(!$@, 'seckey decrypted');
my $ci = Crypt::CBC->new( {'key' => $seckey,
'cipher' => 'Blowfish',
});
my $plaintext = $ci->decrypt($cipher);
t/Business-OnlinePayment-StoredTransaction.t view on Meta::CPAN
#use Data::Dumper;
#my $foo = Data::Dumper->Dump([$data]);
#diag ($foo);
ok($cardnumber eq $data->{'cardnumber'}, 'get the cardnumber back');
use_ok(Business::OnlinePayment::StoredTransaction::Unstore);
my $store;
ok($store = Business::OnlinePayment::StoredTransaction::Unstore->new(
private_key => $privkey,
authorization => $auth,
), 'new store object');
ok($cardnumber eq $store->get('cardnumber'), 'cardnumber matches');
( run in 0.251 second using v1.01-cache-2.11-cpan-a5abf4f5562 )