X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=eSelectPlus.pm;h=806fb65ad6a7127ffe85badc19e55d54dde1b92c;hb=5d6d9f2bb7de1d5efa60172d351e7ae64676ddf5;hp=ebe02034942bb4fb9ddc9c36a0b478e983504951;hpb=f1a879e6989d8d9687fd5033a46488e8b13448e1;p=Business-OnlinePayment-eSelectPlus.git diff --git a/eSelectPlus.pm b/eSelectPlus.pm index ebe0203..806fb65 100644 --- a/eSelectPlus.pm +++ b/eSelectPlus.pm @@ -8,11 +8,12 @@ use Business::OnlinePayment::HTTPS 0.03; use vars qw($VERSION $DEBUG @ISA); @ISA = qw(Business::OnlinePayment::HTTPS); -$VERSION = '0.07'; +$VERSION = '0.08_02'; $DEBUG = 0; sub set_defaults { my $self = shift; + my %opts = @_; #USD #$self->server('esplusqa.moneris.com'); # development @@ -26,8 +27,11 @@ sub set_defaults { $self->port('443'); - $self->build_subs(qw( order_number avs_code )); + $self->build_subs(qw( order_number avs_code skip_avs skip_cvv )); # avs_code order_type md5 cvv2_response cavv_response + + $self->skip_avs( $opts{skip_avs} ); + $self->skip_cvv( $opts{skip_cvv} ); } sub submit { @@ -66,30 +70,30 @@ sub submit { # => 'transaction_type', #login => 'store_id', #password => 'api_token', + #authorization => - #customer_ip => #name => #first_name => #last_name => #company => - #address => + #address => 'avs_street_number'/'avs_street_name' handled below #city => #state => - #zip => + zip => 'avs_zipcode', #country => - phone => + phone => 'avs_custphone', #fax => - email => + email => 'avs_email', + customer_ip => 'avs_custip', + card_number => 'pan', - #expiration => - # => 'expdate', + #expiration => 'expdate', #handled below + cvv2 => 'cvd_value', 'amount' => 'amount', customer_id => 'cust_id', order_number => 'order_id', # must be unique number - authorization => 'txn_number' # reference to previous trans - - #cvv2 => + authorization => 'txn_number', # reference to previous trans ); my $action = $self->{_content}{'action'}; @@ -122,6 +126,13 @@ sub submit { $month = '0'. $month if $month =~ /^\d$/; $self->{_content}{expdate} = $year.$month; + #CVD Indicator + #0 = CVD value is deliberately bypassed or is not provided by the merchant + #1 = CVD value is present. + #2 = CVD value is on the card, but is illegible. + #9 = Cardholder states that the card has no CVD imprint. + $self->{_content}{cvd_indicator} = $self->{_content}{cvd_value} ? 1 : 0; + $self->generate_order_id; $self->{_content}{order_id} .= '-'. ($invoice_number || 0); @@ -143,6 +154,20 @@ sub submit { } + if ( $self->{_content}{address} ) { + my $number = ''; + my $name = $self->{_content}{address}; + if ( $name =~ s/^\s*(\d+)\w\s+// ) { + $number = $1; + } + $name = substr( $name, 0, 19 - length($number) ); + $self->{_content}{avs_street_number} = $number; + $self->{_content}{avs_street_name} = $name; + } + + $self->{_content}{avs_zipcode} =~ s/\W//g + if defined $self->{_content}{avs_zipcode}; + # E-Commerce Indicator (see eSelectPlus docs) $self->{_content}{'crypt_type'} ||= 7; @@ -159,7 +184,25 @@ sub submit { ''. $self->{_content}{'login'}. ''. ''. $self->{_content}{'password'}. ''. "<$action>". - join('', map "<$_>$fields{$_}", keys %fields ). + join('', map "<$_>$fields{$_}", keys %fields ); + + if ( $action =~ /^(purchase|preauth|ind_refund)$/ ) { + tie my %avs_fields, 'Tie::IxHash', $self->get_fields( $self->avs_fields ); + $post_data .= + ''. + join('', map "<$_>$avs_fields{$_}", keys %avs_fields ). + '' + if ! $self->skip_avs && grep $_, values %avs_fields; + + tie my %cvd_fields, 'Tie::IxHash', $self->get_fields( $self->cvd_fields ); + $post_data .= + ''. + join('', map "<$_>$cvd_fields{$_}", keys %cvd_fields ). + '' + if ! $self->skip_cvv && grep $_, values %cvd_fields; + } + + $post_data .= "". ''; @@ -270,6 +313,35 @@ sub fields { ); } +sub avs_fields { + my $self = shift; + + #order is important to this processor + qw( + avs_street_number + avs_street_name + avs_zipcode + avs_email + avs_hostname + avs_browser + avs_shiptocountry + avs_shipmethod + avs_merchprodsku + avs_custip + avs_custphone + ); +} + +sub cvd_fields { + my $self = shift; + + #order is important to this processor + qw( + cvd_indicator + cvd_value + ); +} + sub GetXMLProp { my( $self, $raw, $prop ) = @_; local $^W=0; @@ -363,6 +435,17 @@ so that authorization() and order_number() can return the 2 fields needed for capture. See also cpansearch.perl.org/src/IVAN/Business-OnlinePayment-3.02/notes_for_module_writers_v3 +=head2 Note for upgrading to 0.08 without AVS/CVV enabled with Moneris + +This version now passes AVS and CVV info (previous versions did not). If your +Moneris account is not enabled for these services, you can omit them by passing +the "skip_avs" and/or "skip_cvv" options set to a true value: + + my $tx = new Business::OnlinePayment('eSelectPlus', + 'skip_avs' => 1, + 'skip_cvv' => 1, + ); + =head1 AUTHOR Ivan Kohler