[bop-devel] quick fix for LinkPoint.pm

Ivan Kohler ivan at 420.am
Fri Jan 19 11:32:19 PST 2007


On Thu, Jan 18, 2007 at 09:48:40AM -0800, Jo Rhett wrote:
> LinkPoint actually croaks when it receives input that it doesn't like, 
> instead of returning the error using the normal error_message mechanism. 

This is the intended behavior.  From "notes_for_module_writers_v3":

- Handling failures:

    - If your processor module encounters a setup problem, communication
      error or other problem that's prevents the card from even being
      run, you should die (or croak) with a useful error message.  Setting
      is_success to 0 and returning normally should only be done when the
      transaction *processing* was sucessful (or at least elicited some sort
      of result from the gateway), but the transaction itself returned a
      "normal" decline status of some sort.

>  This produces a server error for the user instead of a useful response.

Use eval { } to trap these sort of "out-of-band" errors and handle them 
differently than normal declines.

Now, that said, I'm totally up for changing how we do our error 
handling, but we'd have to define what the change is first, not just 
start patching processor modules inconsistently.  :)

I do think it is important to distinguish between these sorts of errors 
and errors that come back from the processor, not just set is_success to 
0.  I'm not particularly attached to the whole die/croak think if folks 
would prefer some sort of special return instead.

-- 
_ivan


> 
> This is a super-quick fix for that.
> 
> -- 
> Jo Rhett
> Network/Software Engineer
> Net Consonance

> --- LinkPoint.pm_orig	Thu Jan 18 09:41:50 2007
> +++ LinkPoint.pm	Thu Jan 18 09:44:52 2007
> @@ -4,7 +4,6 @@
>  
>  use strict;
>  use vars qw($VERSION @ISA $DEBUG @EXPORT @EXPORT_OK);
> -use Carp qw(croak);
>  use AutoLoader;
>  use Business::OnlinePayment;
>  
> @@ -109,12 +108,19 @@
>                  /^(cc|visa|mastercard|american express|discover)$/i
>             ) {
>          } else {
> -            Carp::croak("LinkPoint can't handle transaction type: ".
> -                        $self->transaction_type());
> +      		$self->error_message("LinkPoint can't handle transaction type: ".  $self->transaction_type());
> +      		$self->is_success(0);
> +      		$self->result_code('');
> +			return;
>          }
>  
>        $content{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
> -        or croak "unparsable expiration $content{expiration}";
> +        or do {
> +      		$self->error_message("unparsable expiration $content{expiration}");
> +      		$self->is_success(0);
> +      		$self->result_code('');
> +			return;
> +		}
>  
>        ( $month, $year ) = ( $1, $2 );
>        $month = '0'. $month if $month =~ /^\d$/;

> _______________________________________________
> bop-devel mailing list
> bop-devel at 420.am
> http://420.am/cgi-bin/mailman/listinfo/bop-devel




More information about the bop-devel mailing list