Subject: | Enhancement, not a bug |
This is just a patch adding sandbox detection and getting rid of double subroutine calls (with included documentation).
--- IPN.orig 2003-08-19 01:47:08.000000000 -0600
+++ IPN.pm 2005-08-08 09:10:12.000000000 -0600
@@ -83,6 +83,17 @@
$errstr = "Insufficient content from the invoker:\n" . $self->dump();
return undef;
}
+
+ # Instead of creating a double subroutine call, link the shortcut in the
+ # _PAYPAL_VARS hash and let AUTOLOAD handle it
+
+ $self->{_PAYPAL_VARS}->{'status'} = \$self->{_PAYPAL_VARS}->{'payment_status'};
+ $self->{_PAYPAL_VARS}->{'sandbox'} = \$self->{_PAYPAL_VARS}->{'test_ipn'};
+
+ # Are we live or are we memorex?
+
+ $GTW =~ s/www\.paypal/www.sandbox.paypal/ if $self->sandbox;
+
return 1;
}
@@ -199,13 +210,6 @@
-# The same as payment_status(), but shorter :-).
-sub status {
- my $self = shift;
- return $self->{_PAYPAL_VARS}{payment_status};
-}
-
-
# returns true if the payment status is completed
sub completed {
my $self = shift;
@@ -468,6 +472,11 @@
C<denied()> - returns true if C<payment_status> is "Denied".
+=item *
+
+C<sandbox()> - returns true if the notification came from the sandbox, false if
+this is a live transaction.
+
=back
=head1 RETURN VALUES OF METHODS
@@ -539,6 +548,9 @@
is "https://www.paypal.com/cgi-bin/webscr", which you may not want to
change. But it comes handy while testing your application through a PayPal simulator.
+The script now detects whether this is a live or test call and modifies the
+URL appropriately. Currently, it is set to "https://www.sandbox.paypal.com/cgi-bin/webscr".
+
=item *
$Business::PayPal::IPN::SUPPORTEDV - supported version of PayPal's IPN API.
@@ -570,6 +582,10 @@
Documentation fixes. F<patches/thomas-mather.patch>
+=item B<Alan Young>
+
+Added sandbox detection (source and docs). F<patches/alan-young.patch>
+
=back
=head1 COPYRIGHT AND LICENSE