X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=InternetSecure.pm;h=65847f1aed8cc70bd5c7009aa202f4f129a602ab;hb=e97a2d3512479f30718872b70196a2be18ec2b2e;hp=b84e15b593ef083f2cb7dc45d7419d0bcda29ff6;hpb=002359cd978ff1479f276f0fa8a03a39596565cb;p=Business-OnlinePayment-InternetSecure.git diff --git a/InternetSecure.pm b/InternetSecure.pm index b84e15b..65847f1 100755 --- a/InternetSecure.pm +++ b/InternetSecure.pm @@ -12,7 +12,7 @@ use XML::Simple qw(xml_in xml_out); use base qw(Business::OnlinePayment Exporter); -our $VERSION = '0.02'; +our $VERSION = '0.03'; use constant SUCCESS_CODES => qw(2000 90000 900P1); @@ -50,37 +50,20 @@ sub set_defaults { $self->tax_amounts( {} ); } -# OnlinePayment's get_fields now filters out undefs in 3.x. :( +# Combine get_fields and remap_fields for convenience. Unlike OnlinePayment's +# remap_fields, this doesn't modify content(), and can therefore be called +# more than once. Also, unlike OnlinePayment's get_fields in 3.x, this doesn't +# exclude undefs. # -sub get_fields { - my ($self, @fields) = @_; - - my %content = $self->content; - - my %new = map +($_ => $content{$_}), @fields; - - return %new; -} - -# OnlinePayment's remap_fields is buggy in 2.x; this is copied from 3.x -# -sub remap_fields { +sub get_remap_fields { my ($self, %map) = @_; my %content = $self->content(); - foreach (keys %map) { - $content{$map{$_}} = delete $content{$_}; - } - $self->content(%content); -} - -# Combine get_fields and remap_fields for convenience -# -sub get_remap_fields { - my ($self, %map) = @_; + my %data; - $self->remap_fields(reverse %map); - my %data = $self->get_fields(keys %map); + while (my ($to, $from) = each %map) { + $data{$to} = $content{$from}; + } return %data; } @@ -152,7 +135,13 @@ sub to_xml { my %content = $self->content; - $self->required_fields(qw(action card_number exp_date)); + # Backwards-compatible support for exp_date + if (exists $content{exp_date} && ! exists $content{expiration}) { + $content{expiration} = delete $content{exp_date}; + $self->content(%content); + } + + $self->required_fields(qw(action card_number expiration)); croak "Unsupported transaction type: $content{type}" if $content{type} && @@ -195,7 +184,7 @@ sub to_xml { $data{xxxCard_Number} =~ tr/- //d; $data{xxxCard_Number} =~ s/^[^3-6]/4/ if $self->test_transaction; - my ($y, $m) = $self->parse_expdate($content{exp_date}); + my ($y, $m) = $self->parse_expdate($content{expiration}); $data{xxxCCYear} = sprintf '%.4u' => $y; $data{xxxCCMonth} = sprintf '%.2u' => $m; @@ -364,7 +353,7 @@ Business::OnlinePayment::InternetSecure - InternetSecure backend for Business::O type => 'Visa', # Optional card_number => '4111 1111 1111 1111', - exp_date => '2004-07', + expiration => '2004-07', cvv2 => '000', # Optional name => "Fr\x{e9}d\x{e9}ric Bri\x{e8}re", @@ -448,7 +437,7 @@ Transaction type, being one of the following: Credit card number. Spaces and dashes are automatically removed. -=item exp_date (required) +=item expiration (required) Credit card expiration date. Since C does not specify any syntax, this module is rather lax regarding what it will accept. The