[bop-devel] Patch to Business-OnlinePayment 3.00_03
Phil Lobbes
phil at perkpartners.com
Mon Aug 28 20:29:15 PDT 2006
Hi Ivan,
Any hope of getting this diff/patch applied to BOP 3.x? I'll generate a
similar patch to 2.x if you're willing to apply it. In fact I could
add/enhance the test cases for 2.x/3.x if you are interested (you can
take a look at my tests for things I have done for my new PayPal
backend:
http://search.cpan.org/src/PLOBBES/Business-OnlinePayment-PayPal-0.10/t/Business-OnlinePayment-PayPal.t
Sincerely,
Phil
PS. I'd be happy to apply these myself if you're willing to give me some
access.
Here's the diff against Business-OnlinePayment 3.00_03:
* get rid of possible use an undefined value as a HASH reference
* stop redefining subs if they already exist
- NOTE: it might be nice to do away with this completely and use a
notion of $self->param('name' => 'value') and $self->delete('name')
instead of creating subs on the fly. This would be a little cleaner
design for v3 I would think. It would get rid of some (in theory)
unnecesary subs and remove some uses of eval which might be a little
better for performance (probably minor but haven't benchmarked to
know for sure) and perhaps a bit more friendly to people that use
mod_perl too.
* fix "typo" in docs cardnumber becomes card_number which seems to be
the "standard" name (based on several backend implementations I looked
at)
diff -u OnlinePayment.pm.ORIG OnlinePayment.pm
--- OnlinePayment.pm.ORIG 2005-03-16 05:46:15.000000000 -0500
+++ OnlinePayment.pm 2006-08-28 11:24:42.000000000 -0400
@@ -68,7 +68,7 @@
if($params{'type'}) { $self->transaction_type($params{'type'}); }
%{$self->{'_content'}} = %params;
}
- return %{$self->{'_content'}};
+ return exists $self->{'_content'} ? %{$self->{'_content'}} : ();
}
sub required_fields {
@@ -123,7 +123,9 @@
sub build_subs {
my $self = shift;
foreach(@_) {
- eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
+ unless ( $self->can($_) ) {
+ eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }";
+ }
}
}
@@ -141,11 +143,11 @@
my $transaction = new Business::OnlinePayment($processor, %processor_info);
$transaction->content(
- type => 'Visa',
- amount => '49.95',
- cardnumber => '1234123412341238',
- expiration => '0100',
- name => 'John Q Doe',
+ type => 'Visa',
+ amount => '49.95',
+ card_number => '1234123412341238',
+ expiration => '0100',
+ name => 'John Q Doe',
);
$transaction->submit();
More information about the bop-devel
mailing list