[Catalyst-commits] r8014 - in trunk/Catalyst-Model-PayPal-IPN: .
lib/Catalyst/Model/PayPal t
edenc at dev.catalyst.perl.org
edenc at dev.catalyst.perl.org
Fri Jun 27 15:54:48 BST 2008
Author: edenc
Date: 2008-06-27 15:54:47 +0100 (Fri, 27 Jun 2008)
New Revision: 8014
Modified:
trunk/Catalyst-Model-PayPal-IPN/Makefile.PL
trunk/Catalyst-Model-PayPal-IPN/lib/Catalyst/Model/PayPal/IPN.pm
trunk/Catalyst-Model-PayPal-IPN/t/02.encrypt.t
Log:
Business::PayPal::EWP is now optional
Modified: trunk/Catalyst-Model-PayPal-IPN/Makefile.PL
===================================================================
--- trunk/Catalyst-Model-PayPal-IPN/Makefile.PL 2008-06-27 14:31:32 UTC (rev 8013)
+++ trunk/Catalyst-Model-PayPal-IPN/Makefile.PL 2008-06-27 14:54:47 UTC (rev 8014)
@@ -8,9 +8,10 @@
requires 'Catalyst::Runtime' => '5.7006';
requires 'Moose' => '0.20';
requires 'namespace::clean' => '0.04';
-requires 'Business::PayPal::EWP';
requires 'Business::PayPal::IPN';
requires 'Crypt::SSLeay'; # should be installed by IPN but isn't always
+features('Form Encryption' => [ -default => 0, 'Business::PayPal::EWP']);
+
auto_install;
WriteAll;
Modified: trunk/Catalyst-Model-PayPal-IPN/lib/Catalyst/Model/PayPal/IPN.pm
===================================================================
--- trunk/Catalyst-Model-PayPal-IPN/lib/Catalyst/Model/PayPal/IPN.pm 2008-06-27 14:31:32 UTC (rev 8013)
+++ trunk/Catalyst-Model-PayPal-IPN/lib/Catalyst/Model/PayPal/IPN.pm 2008-06-27 14:54:47 UTC (rev 8014)
@@ -3,7 +3,6 @@
use Moose;
use namespace::clean -except => ['meta'];
use Business::PayPal::IPN;
-use Business::PayPal::EWP qw(SignAndEncrypt);
our $VERSION = '0.02';
our $AUTHORITY = 'cpan:MSTROUT';
@@ -75,7 +74,8 @@
has 'debug_mode' => ( is => 'rw', required => 1, default => sub { 0 } );
-has 'encrypt_mode' => ( is => 'rw', required => 1, default => sub { 0 } );
+has 'encrypt_mode' => ( is => 'rw', required => 1, default => sub { 0 },
+ trigger => sub {shift->check_encrypt_mode} );
has 'cert' => (
is => 'rw',
@@ -118,6 +118,15 @@
default => sub { shift->build_ipn_object },
);
+sub BUILD {
+ shift->check_encrypt_mode;
+}
+
+sub check_encrypt_mode {
+ Catalyst::Utils::ensure_class_loaded('Business::PayPal::EWP')
+ if shift->encrypt_mode;
+}
+
sub ACCEPT_CONTEXT {
my ( $self, $c ) = @_;
return $c->stash->{ ref($self) } ||= $self->build_context_copy($c);
@@ -223,8 +232,9 @@
$form .= $form_param . '=' . $form_args->{$form_param} . ',';
}
- return SignAndEncrypt( $form, $self->cert_key, $self->cert,
- $self->paypal_cert, );
+ return Business::PayPal::EWP::SignAndEncrypt(
+ $form, $self->cert_key, $self->cert, $self->paypal_cert
+ );
}
package Catalyst::Model::PayPal::IPN::ErrorHandle;
Modified: trunk/Catalyst-Model-PayPal-IPN/t/02.encrypt.t
===================================================================
--- trunk/Catalyst-Model-PayPal-IPN/t/02.encrypt.t 2008-06-27 14:31:32 UTC (rev 8013)
+++ trunk/Catalyst-Model-PayPal-IPN/t/02.encrypt.t 2008-06-27 14:54:47 UTC (rev 8014)
@@ -18,9 +18,10 @@
use strict;
use warnings;
-use Test::More tests => 2; # last test to print
+use Test::More; # last test to print
+eval 'Business::PayPal::EWP';
+plan $@? ( skip_all => 'Business::PayPal::EWP not installed' ) : ( tests => 1 );
-BEGIN { use_ok('Business::PayPal::EWP') };
TODO: {
local $TODO="PKCS7 block seems to differ each time";
is(Business::PayPal::EWP::SignAndEncrypt("Testing, 123!","test.key","test.crt","paypal.pem"),join("",<DATA>),"Ran SignAndEncrypt");
More information about the Catalyst-commits
mailing list